Forum

How to let an EA (not indicator) draw lines in back test?

I have an indicator that draws a line with a logic that starts from [n] bars back and changes the value bit by bit until it reaches the right end of the chart. (as per my last post https://www.mql5.com/en/forum/382876 ) it works marvelously and I am moving to backtest albeit with a problem. Since

Indicator Coding Question: Is it possible to get the index for the newest candle when the indicator started?

I am trying to write an indicator that calculates some cumulative change over time. Let's say it starts from the bar with index [50] with an initial value and depending on the bars on the way the value will become different when it reaches the right end of the chart. It will be drawn like a line

EA doesn't close order during backtest?

void OnTick () { if ( OrdersTotal () == 0 ) { if ( iCustom ( Symbol (), PERIOD_CURRENT , "mt" , 0 , 0 ) > 1 && iCustom ( Symbol (), PERIOD_CURRENT , "mta" , 0 , 0 ) > 0 ) { OrderSend ( _Symbol ,OP_BUY,lots,Ask, 1 , 0 , 0 , NULL , 0 , 0 ,Green); } if ( iCustom