I have been working with Matthew to work through adding lists to an indicator that I have built, and I am running into a few problems.
Currently I have created the lists in the Variables( ) method.
My indicator then indicates a trade, and from that trade I am adding the entry price, stop price, MAE and MFE, as well as incrementing a trade counter that was started at 0 and increments by 1 for each trade. Therefore, each trade has a unique trade number between 0 and n.
I'm then trying to run a for loop (i = 0; i <= list.Count; i++) that runs through some logic to see if the current bar's high and low increase the MFE, decrement the MAE, trigger a stop (which is defined) or do nothing. So the idea is that the for loop runs through each list and refreshes each trades MAE and MFE.
I am currently able to compile okay, but on the bar immediately after my indicated trade, the indicator stops producing trades and I am getting the "You are accessing an index with a value that is invalid since its out of range." The trade is indicated at bar 63, and the error is triggered on bar 63 (ie, so nothing happens from bar 64 on).
I do have the following code at the top of the OnBarUpdate ( ) method:
if(CurrentBar < 1)
{
return;
}
But clearly this is not the issue.
Does anyone have any ideas on why this might be happening? This is my first time using lists.
Thanks for your help in advance. I REALLY appreciate it.
All best,
Aventeren
Comment