Cant take this any more!! (iMaOnArray) - Page 2
Page 2 of 612 FirstFirst 12
Results 11 to 14 of 14

Thread: Cant take this any more!! (iMaOnArray)

  1. #11
    Thankyou so

    I think the smartest solution now is to apply the EMA21 formula into the array I got with the data.
    I have been assessing but cant loe the EMA formula utilized on metatrader, I used the one supplied in the link below:

    http://stockcharts.com/school/doku.p...ntial_moving_a

    After using that formulation, the code I got is that one:

    Inserted Code double AUX1=0; double EMASMAANGLE=0; int j=0 ; for(j=0; jlt;21; j ) AUX1=EMASMAANGLE; EMASMAANGLE=iCustom(NULL, 0, SMAAngle, 0, j 21) AUX1; AUX1=EMASMAANGLE; EMASMAANGLE=AUX1/21; j=0; for(j=0; jlt;21; j ) AUX1=EMASMAANGLE; EMASMAANGLE = AUX1 ((iCustom(NULL, 0, SMAAngle, 0, 20 - j)-AUX1))/11; // EMA(current) = ((Price(current) - EMA(prev)) x Multiplier) EMA(prev) Alert(DoubleToStr(EMASMAANGLE,8));
    It doesnt give me the exact amount calculated supplied by the chart, but I guess its as close as I will get ^_^

    Thx again

  2. #12
    Quote Originally Posted by ;
    Hello everyone! I will go directly to the stage:

    Here is the code:


    dual AUX[22];
    dual EMASMAANGLE=0;
    int j=0;
    for(j=0; jlt;21; j )
    AUX[j] = iCustom( NULL, 0, SMAAngle, 0, j);

    EMASMAANGLE=iMAOnArray(AUX,21,21,0,MODE_EMA,j);

    Alert(EMASMAANGLE);


    Shouldnt that provide me an alert together with all the EMA(21) of the last 21 EMAAngle indior values?
    This returns 0 rather!!

    Thankyou!
    Hello Armagedoom,
    You can use Standard ema calculation:
    PHP Code: <code><span style=?color: #000000?> <span style=?color: #0000BB?></span><span style=?color: #FF8000?>//ConvertEmaPeriod(21)toSmoothFactor:
    </span><span style=?color: #0000BB?>doubleSF</span><span style=?color: #007700?>=</span><span style=?color: #0000BB?>2.0</span><span style=?color: #007700?>/(</span><span style=?color: #0000BB?>21</span><span style=?color: #007700?> </span><span style=?color: #0000BB?>1</span><span style=?color: #007700?>);
    </span><span style=?color: #FF8000?>//Defineinitialemavalue:
    </span><span style=?color: #0000BB?>doubleEmaSmaAngle</span><span style=?color: #007700?>=</span><span style=?color: #0000BB?>iCustom</span><span style=?color: #007700?>(</span><span style=?color: #0000BB?>NULL</span><span style=?color: #007700?>,</span><span style=?color: #0000BB?>0</span><span style=?color: #007700?>,</span><span style=?color: #DD0000?>?SMAAngle?</span><span style=?color: #007700?>,</span><span style=?color: #0000BB?>0</span><span style=?color: #007700?>,</span><span style=?color: #0000BB?>21</span><span style=?color: #007700?>);
    </span><span style=?color: #FF8000?>/Iteratethenextema,startfromtheoldestdata:
    </span><span style=?color: #007700?>for(</span><span style=?color: #0000BB?>j</span><span style=?color: #007700?>=</span><span style=?color: #0000BB?>20</span><span style=?color: #007700?>;</span><span style=?color: #0000BB?>j</span><span style=?color: #007700?>gt;=</span><span style=?color: #0000BB?>0</span><span style=?color: #007700?>;</span><span style=?color: #0000BB?>j</span><span style=?color: #007700?>--)
    </span><span style=?color: #0000BB?>EmaSmaAngle</span><span style=?color: #007700?>=</span><span style=?color: #0000BB?>EmaSmaAngle</span><span style=?color: #007700?> </span><span style=?color: #0000BB?>SF</span><span style=?color: #007700?>*(</span><span style=?color: #0000BB?>iCustom</span><span style=?color: #007700?>(</span><span style=?color: #0000BB?>NULL</span><span style=?color: #007700?>,</span><span style=?color: #0000BB?>0</span><span style=?color: #007700?>,</span><span style=?color: #DD0000?>?SMAAngle?</span><span style=?color: #007700?>,</span><span style=?color: #0000BB?>0</span><span style=?color: #007700?>,</span><span style=?color: #0000BB?>j</span><span style=?color: #007700?>)-</span><span style=?color: #0000BB?>EmaSmaAngle</span><span style=?color: #007700?>);
    </span><span style=?color: #0000BB?>Alert</span><span style=?color: #007700?>(</span><span style=?color: #0000BB?>EmaSmaAngle</span><span style=?color: #007700?>);
    </span><span style=?color: #0000BB?></span> </span> </code>

  3. #13
    There are lots of code samples utilizing iMAOnArray() in indiors. Just look at some and compare them with your own code.

  4. #14
    I'm having the exact same problem right now, seriouly frued.
    Quote Originally Posted by ;
    I remembered something else that this morning about iMAOnArray(). It can not be utilised in an EA. I remember fighting with this for hours - just when I looked for sample code and eventually like you I found that this discussion thread which confirmed my suspicions. What I ended up doing was using iMAOnArray() in an indior and regaining the values by means of iCustom().

    Sorry I did not remember this in my earlier reponses. Do not waste any more time, I doubt if it can be carried out.

    Http://forum.mql4.com/9228
    I'm using the iMAOnArray() in my indior, and it keeps returning 0 and has awakened my whole work.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
This website uses cookies
We use cookies to store session information to facilitate remembering your login information, to allow you to save website preferences, to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners.