Indicator building

 

Hi I have built two basic indicators today for my own use but I cannot finish them due to 4/5 red lines that I have tried many scenarios with no avail what do I need to put in the following boxes 

Copyright 

Link

Version 

Atrict

indicator chart window 

It may seem obivious to some I know but nothing i,ve tried will work

thanks in advance 

 
Copyright, link and version have no impact on how the indicator works.

#property strict is a compiler definition for MT4 for using the last compiler version instead of the old mql4 coding approach.
 

yep ive deleted all those lines before i read your reply my problem now is to get Mt4 to accept the two what do I need to tick to gain entry 

 
Your problem is not clear, can you explain better?
 
Fabio Cavalloni #: #property strict is a compiler definition for MT4 for using the last compiler version instead of the old mql4 coding approach.

Always use strict. Fixing the warnings will save you hours of debugging, but you must understand the differences.

 
Mark Richrard Grellet #: ive deleted all those lines before i read your reply my problem now is to get Mt4 to accept the two what do I need to tick to gain entry 

If you want help with your code, Show us your attempt (using the CODE button) and state the nature of your difficulty.
          No free help (2017)

we can't see your machine.
     How To Ask Questions The Smart Way. (2004)
          Be precise and informative about your problem

We can't see your broken code.

Always post all relevant code (using Code button) or attach the source file.

 

attached is code what I am trying to do is create a simple indicator using a standard 13 day MA and a Hull moving average I want it to send me a push message when crossover occurs I have tried again this morning but still cannot remove all errors 

//+------------------------------------------------------------------+

//|                                                     ZootSuit.mq4 |

//|                                                                  |

//|                                             https://www.mql5.com |

//+------------------------------------------------------------------+



#property indicator_separate_window

#property indicator_buffers 2

#property indicator_color1 Blue

#property indicator_color2 Red



// Define period as a global variable

input int Period = 13; // Or whatever value you intend to use



// Define buffers

double hullBuffer[];

double emaBuffer[];



//+------------------------------------------------------------------+

//| Custom indicator initialization function                         |

//+------------------------------------------------------------------+

int OnInit()

{

    // Indicator buffers mapping

    SetIndexBuffer(0, hullBuffer);

    SetIndexBuffer(1, emaBuffer);



    return(INIT_SUCCEEDED);

}



//+------------------------------------------------------------------+

//| Custom indicator iteration function                              |

//+------------------------------------------------------------------+

int OnCalculate(const int rates_total,

                const int prev_calculated,

                const datetime &time[],

                const double &open[],

                const double &high[],

                const double &low[],

                const double &close[],

                const long &tick_volume[],

                const long &volume[],

                const int &spread[])

{

    // Calculate the Hull moving average

    for (int i = prev_calculated; i < rates_total; i++)

    {

        hullBuffer[i] = HullMovingAverage(close, Period, i);

    }



    // Calculate the custom simple moving average

    for (int i = prev_calculated; i < rates_total; i++)

    {

        double sum = 0.0;

        for (int j = i - Period + 1; j <= i; ++j) {

            sum += close[j];

        }

        emaBuffer[i] = sum / Period;

    }



    // Check for crossover and send push notification

    if (rates_total >= 2 && hullBuffer[rates_total - 2] > emaBuffer[rates_total - 2] && hullBuffer[rates_total - 1] < emaBuffer[rates_total - 1])

    {

        SendNotification("HMA crossed below custom EMA");

    }



    // Return value of prev_calculated for next call

    return(rates_total);

}



//+------------------------------------------------------------------+

//| Hull Moving Average Calculation                                  |

//+------------------------------------------------------------------+

double HullMovingAverage(const double &price[],

                         const int period,

                         const int shift)

{

    double wma1 = iMA(Symbol(), 0, period / 2, 0, MODE_WMA, PRICE_CLOSE, shift);

    double wma2 = iMA(Symbol(), 0, period, 0, MODE_WMA, PRICE_CLOSE, shift);

    double hull = 2 * wma1 - wma2;

    return hull;

}


 
  1. #property indicator_buffers 2
    
    #property indicator_color1 Blue
    
    #property indicator_color2 Red

    You stated you have two buffers, and their color. You have not stated what the buffers should show.
              [Help] Custom RSI is Missing Some Portion of Indicator Lines - Indices - MQL4 programming forum (2018)

  2.     for (int i = prev_calculated; i < rates_total; i++)

    After the initial run (where prev_calculated is zero), prev_calculated equals rates_total, and your loop does nothing.
              How to do your lookbacks correctly #9#14 & #19 (2016)

  3.             sum += close[j];

    In MT4, buffers and MT4 predefined arrays are all ordered AsSeries. 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[], 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

    Your loop is non-series, but your buffers are not.