I'm new to NJ, so please forgive me if this is not a very smart question.
I'm trying to modify a default crossover strategy that goes with NJ. I'd like to add stop and profit targets to this strategy.
In initialize() method I've added the following lines:
SetStopLoss(CalculationMode.Percent, 2);
SetProfitTarget(CalculationMode.Percent, 5);
In my onBarUpdate() I have the following:
bool isFlat = Position.MarketPosition == MarketPosition.Flat;
if (isFlat && CrossAbove(SMA(Fast), SMA(Slow), 1))
EnterLong();
else if (isFlat && CrossBelow(SMA(Fast), SMA(Slow), 1))
EnterShort();
I was assuming that the effect would be that after I enter long, the stop and profit targets would be set. But this does not seem to happen.
I'm working with EOD data from Yahoo.
Please, let me know what I'm doing wrong here.
Thanks.

Comment