Capture a indicator value at open position
There is so many problems with you code that it's surprising it place a trade ![]()
See your issue about stoploss. Why are using this loop ?
for(int i=0;i<30;i++)
Inside this loop you set :
StopLoss=STL[i+1];
But your STL array can only have a size of 3.
CopyBuffer(STLH,0,0,3,STL);
Print your stoploss value, and the market price at the time you got the error.
I strongly suggest you to check the returned value of any function you are using, they can produce an error.
Also you have to normalize your price.
- www.mql5.com
I am trying to create a fix stoploss, using the value of indicator at the bar that gives the buy signal.
For example:
In this case, the position will be open at the new bar open.
I am trying to capture the value of indicator at the bar that gives the buy signal.
When backtest starts, the first position always works, adjusting the stoploss value, and closing the position.
The Error message starts to appear, after finished the first position and trying to place stop on second condition...
The whole code: