TDI-with alerts, wanting to set indicator to update only at first tick of new bar

 

Greetings,


I am keen to use this indicator (tdi-with alerts) seems much support for it has ended.

Issue 1: Right at the end error says: 'not all control paths return a value'

I dont know how to resolve this.

Request 1: Add function so that indicator works only at first tick of new bar, not all the time on every tick as it currently is.


I have some code here, but dont know where to insert. 


The easiest way is to use standard OnCalculate(***) function and run the main cycle only if(rates_total>prev_calculated).

Also, in the main cycle try to have for(int shift=limit-1;shift>0;shift--){ (be attentive), and by the way, are you sure that you need shift=limit-1 not just shift=limit?

 

Or

 

int start(){
    static aCurrentTIME  = EMPTY;
    if (   aCurrentTIME == Time[0] ) return 0;   // .NOP/JIT/RET --^ 
           aCurrentTIME  = Time[0];              // .MOV/LOCK
 // -------------------------------------------- // .CALC:
    int limit = Bars - counted_bars;
    ...
    /* update just the "HOT"-end has just got into OHLCVT[1]-cells */
 // -------------------------------------------- // .FIN
}

 

 

Or

 

datetime calculatedBarTime;
 
void OnCalculate()
{
    if (  calculatedBarTime != Time[0] ) 
    {
          onBar();
    }
}
 
void onBar()
{
     calculatedBarTime  = Time[0];
  // on bar logic....
}

 

Last solution received this comment: 

You may soon realise, that the New-MQL4 OnCalculate() handler does not work this way, it uses a block-arranged forward-stepping in undefined amount of mini-batches, so this calling onBar() will fail to process each and every Bar, as Custom Indicators obviously have to do. <Deleted>



I have attached tdi version i am using. Any suggestions and work would be greatly appreciated.

Reason: