PDA

View Full Version : Code for Long on 3 Consecutive Closes above 50 SMA...


CyberTrader123
06-09-2009, 07:27 PM
Hi,

I am new to NinjaTrader and need a bit of help with a piece of code...

If I were to go LONG after the 3 Consecutive Closes above 50 SMA...what code would I use?

The difficultly I have is with the part 3 Consecutive Closes....If it is the first close I know how to add the condition...

I know the Programming language well...so C# is not the problem...just to be clear...

Thanks in Advance..

NinjaTrader_Bertrand
06-10-2009, 06:50 AM
CyberTrader123, welcome to NinjaTrader and our support forums! You could take a look at the CountIf() method for counting your consecutive occuring conditions before trade entry - http://www.ninjatrader-support.com/HelpGuideV6/CountIf.html

CyberTrader123
06-10-2009, 07:30 PM
Thank you... That helped...Solved my problem with

if (CountIf(delegate {return Close[0] > SMA(50)[0];}, 3) == 3)