Please help with this simple function!

 

Hi, and thanks ahead for your help!

Im trying to create a function for mq4 that will count the number of a MA crossing over a period of time or bars and save that number to a buffer for a later use..

can please someone help me on this?

Thanks again

 
AtApi:
Im trying to create a function for mq4
Then show your code, otherwise standard reply: No Slaves here, learn to code or pay someone.
 
WHRoeder:
Then show your code, otherwise standard reply: no slaves here, learn to code or pay someone.


Hey WHRoeder thanks for your answer, see i dont have a code yet...i can show you just what i got so far:

#property indicator_chart_window
#property indicator_buffers 2







// exported variables


// local variables
int ObjCount = 0;  // count of all objects created on the chart, allows creation of objects with unique names
int current = 0; // variable points to current bar

string TextObj8 = "";
double Buffer8[];
string TextObj6 = "";
double Buffer6[];


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
    if (false) ObjectsDeleteAll();      // clear the chart
    IndicatorShortName("Freq");
    IndicatorDigits(5);
    IndicatorBuffers(2);
    
    SetIndexBuffer(0, Buffer8);
    
    ObjCount += 1;
    TextObj8 = "IChart_" + ObjCount;
    ObjectCreate(TextObj8, OBJ_LABEL, 0, 0, 0);
    ObjectSet(TextObj8, OBJPROP_CORNER, 0);
    ObjectSet(TextObj8, OBJPROP_XDISTANCE, 10);
    ObjectSet(TextObj8, OBJPROP_YDISTANCE, 150);
    
    SetIndexBuffer(1, Buffer6);
    
    ObjCount += 1;
    TextObj6 = "IChart_" + ObjCount;
    ObjectCreate(TextObj6, OBJ_LABEL, 0, 0, 0);
    ObjectSet(TextObj6, OBJPROP_CORNER, 0);
    ObjectSet(TextObj6, OBJPROP_XDISTANCE, 10);
    ObjectSet(TextObj6, OBJPROP_YDISTANCE, 150);
    
    
    return(0);
}

//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
{
    if (false) ObjectsDeleteAll();
    
    
    return(0);
}

//+------------------------------------------------------------------+
//| Custom indicator start function                                  |
//+------------------------------------------------------------------+
int start()
{
    OnEveryTick9();
    
    return(0);
}

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

void OnEveryTick9()
{
    
    int i;
    int counted_bars = IndicatorCounted();
    if(counted_bars < 0) return(-1);
    if(counted_bars > 0) counted_bars--;
    i = Bars - counted_bars;
    // main calculation loop
    while (i >= 0)
    {
        current = i;
        MAcrossingUP();
        MAcrossingDOWN();
        
        i--;
    }
}

void MAcrossingUP()

{
    if ((iMA(NULL, NULL,4,0,MODE_EMA,PRICE_CLOSE,current+1) < iMA(NULL, NULL,5,0,MODE_EMA,PRICE_CLOSE,current+1) && (iMA(NULL, NULL,4,0,MODE_EMA,PRICE_CLOSE,current) > iMA(NULL, NULL,5,0,MODE_EMA,PRICE_CLOSE,current))
    {
        ChartText8();
        
    }
}

void ChartText8()
{
   ???
    
}


void MAcrossingDOWN()

{
    if ((iMA(NULL, NULL,4,0,MODE_EMA,PRICE_CLOSE,current+1) > iMA(NULL, NULL,5,0,MODE_EMA,PRICE_CLOSE,current+1) && (iMA(NULL, NULL,4,0,MODE_EMA,PRICE_CLOSE,current) < iMA(NULL, NULL,5,0,MODE_EMA,PRICE_CLOSE,current))
    {
        ChartText6();
        
    }
}

void ChartText6()
{
   ???
    
}
Reason: