Indicator MT4 that works not so well

 

Hi i have developed an indicator that should recognize the IDNR4 pattern and suggest to enter Long or Short based on the pattern.

Looking at the indicator it seems correct but:

1. Display Long and Short arrow

2. If it is included into an EA getting the Bars-1 (so the previous closed bar) it doesn't provide any signals on buffer 2 and 3.

Could you please help me ?

Attached the code

Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Symbol Properties
Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Symbol Properties
  • www.mql5.com
To obtain the current market information there are several functions: SymbolInfoInteger() , SymbolInfoDouble() and SymbolInfoString() . The first...
Files:
 
  1. Why did you post your MT4 question in the MT5 Indicators section instead of the MQL4 section, (bottom of the Root page)?
              General rules and best pratices of the Forum. - General - MQL5 programming forum? (2017)
    Next time, post in the correct place. I have moved this thread.

  2. Your loop is non-series
       int end = rates_total - 1;  // arrivo fino a rates_total - 1 incluso
       for(int i = 1; i <= end; i++){
    
    There is a difference between the arrays passed to OnCalculate (e.g. low[]) and the MT4 predefined variables (e.g. Low[].) The passed arrays have no default direction, just like MT5.

    To determine the indexing direction of time[], open[], high[], low[], close[], tick_volume[], volume[] and spread[] arrays, call ArrayGetAsSeries(). In order not to depend on default values, you should unconditionally call the ArraySetAsSeries() function for those arrays, which are expected to work with.
              Event Handling Functions - Functions - Language Basics - MQL4 Reference

          double range0 = high[i - 1] - low[i - 1];
    Buffers default to as-series.
          BufferArrowLong[i] = EMPTY_VALUE;
          BufferArrowShort[i] = EMPTY_VALUE;
 
William Roeder #:
  1. Why did you post your MT4 question in the MT5 Indicators section instead of the MQL4 section, (bottom of the Root page)?
              General rules and best pratices of the Forum. - General - MQL5 programming forum? (2017)
    Next time, post in the correct place. I have moved this thread.

  2. Your loop is non-series
    There is a difference between the arrays passed to OnCalculate (e.g. low[]) and the MT4 predefined variables (e.g. Low[].) The passed arrays have no default direction, just like MT5.
    Buffers default to as-series.

thank you for you r answer but i haven't understood how i can correct the code. Could you please help me writing the piece of code that i'm not able to do ?

 
What part of “should unconditionally call the ArraySetAsSeries() function for those arrays” (and buffers) is unclear?
 
William Roeder #:
What part of “should unconditionally call the ArraySetAsSeries() function for those arrays” (and buffers) is unclear?

The usage of these buffers. i have seen some indicators where they are not used and i don't understand why my code can't work without them. Probably i missed som einfo on how the indicators work with the graph and the EA that call them.