What I would like to do is look "forward" to see if the TP or SL is reached first to close the trade.
I tried a for loop, starting at the next bar and going to the right looking for the closing bar. I limited it so it wouldn't run off the right edge of the chart.
but when it got to the first bar on the right it stopped.
is there any way to look forward to bars on the right of the chart?
if not, I will have to look back from every bar to see if it closes an open trade, which would require a lot more code and processing power
[PHP][/PHP]{
DrawVerticalLine("Signal",Brushes.White,1);
SLTarget[0] = Close[0] - 2 * ATR14[0];
TPTarget[0] = Close[0] + 3 * ATR14[0];
for(int i = CurrentBar + 1; i < ChartBars.Count; i++)
{
if(High[i] > TPTarget[0])
{
int TPBar = i;
Print(CurrentBar + " " + ChartBars.Count);
break;
}
}

Comment