3 level semafor speed up.

 

This Indicator is very slow if you use backtest many candles.

But I reduced it, this light indicator only calculates needed candles.

Any Suggestion ?


In the code, startbars is the main fix.


Backtest time comparison : 


2019.08.05 21:33:27.939 2019.08.05 15:59:59  EURUSD,H1: 1097 tick events (1096 bars, 3193 bar states) processed in 0:00:09.297 (total time 0:00:09.422)

2019.08.05 21:33:51.950 2019.08.05 15:59:59  EURUSD,H1: 1097 tick events (1096 bars, 3193 bar states) processed in 0:00:01.250 (total time 0:00:01.359)


if(startbars==0) startbars=Bars-Period3;
 
Shin Joo Young: But I reduced it, this light indicator only calculates needed candles. Any Suggestion ?
  1. You should stop using the old event handlers and IndicatorCounted and start using the new ones.
              Event Handling Functions - Functions - Language Basics - MQL4 Reference
              How to do your lookbacks correctly.

  2. You have not "reduced it." You need to change it to "only calculates needed candles."
              How to do your lookbacks correctly.

 
William Roeder:
  1. You should stop using the old event handlers and IndicatorCounted and start using the new ones.
              Event Handling Functions - Functions - Language Basics - MQL4 Reference
              How to do your lookbacks correctly.

  2. You have not "reduced it." You need to change it to "only calculates needed candles."
              How to do your lookbacks correctly.

1. I edited some lines only

2. I think this correction has not helped. No more explanation needed. You understanded it already with my words.

Overcorrection. Take it easy and no concern about micro things. Thank You.