First post here, and just want to say a big thank you to the dev team for NinjaTrader. Now onto my question. Right now I have a strategy whereby upto 3 positions can be opened at once.
I've set it up to open positions and it working fine. The problem area is to do with the stop losses based on the ATR. So far I have this, one setup for each long position entered, (I've named EnterLong, Enterlong2...).
if (Close[0] < (Position.AvgPrice - (2*ATR(...)))
&& Position.MarketPosition == MarketPosition.Long)
{
ExitLong("", "EnterLong");
}
if (Close[0] < (Position.AvgPrice - (2*ATR(...)))
&& Position.MarketPosition == MarketPosition.Long)
{
ExitLong("", "EnterLong2");
}
etc.
The problem I have is with the Position.AvgPrice part. If I have one position open this is ok, as the average price will obviously be the opening price. However if I open the three positions then the stop is going to be based on the average price, rather than the price of the last / highest priced order entry, which is what I want. So ideally what I would like is something like:
if (Close[0] < (EnterLong2 Entry Price - (2*ATR(...)))
&& Position.MarketPosition == MarketPosition.Long)
{
ExitLong("", "EnterLong2");
}
Any ideas?
EDIT: Sorry, another bit to add. Having thought about it would also be handy if I was able to take the ATR value of the first trade and lock that value in using a variable. Thanks.

Comment