I am attempting to code a simple short term long only strategy. For Profit Target and Stop Loss exits my attempts are:
if (Position.MarketPosition == MarketPosition.Long)
//(BarsSinceEntry() > 0)
{
SetProfitTarget(CalculationMode.Price, (Position.AvgPrice + ATR(5)[0]));
SetStopLoss(CalculationMode.Price, (Position.AvgPrice - ATR(5)[0]));
}
There are no compiling errors. My problem is that the exit values when backtesting are close to the nominal ATR value (rather than nominal ATR value plus/ minus the entry price). I am a beginner coder and cannot find the correct coding on any of the forums. Any direction for the proper code or helpful links would be appreciated.
Thanks!

Comment