Cant take this any more!! (iMaOnArray)
Page 1 of 612 12 LastLast
Results 1 to 10 of 14

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

  1. #1
    Hello everybody! I will go directly to the stage:

    This 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 give me an alert together with the EMA(21) of their last 21 EMAAngle indior values?
    This returns 0 instead!!

    Thankyou!

  2. #2
    You should contain more detail, when posting problems like this. I usually ignore postings that are incomplete similar to this.

    I am guessing that you see a popup alert with a 0 as the angle. It is an easy problem, if that is the case - you want to format the value EMASMANGLE. Use the purpose DoubleToString() to perform this. You will discover the details. If I am wrong, you have to provide more detail.

  3. #3
    If you're posting code it is better to use forums code tags. Makes it easier to read and you are more likely to get answers.

    Lux

  4. #4
    Im sorry I have spent many hours attempting to repair it, that I assumed that by submitting the code anybody would understand the problem was lol

    I changed that code for this one:

    Inserted Code dual AUX#91;21#93;; dual EMASMAANGLE=0; int j=0; for(j=0; jlt;21; j ) AUX#91;20-j#93; = iCustom(NULL, 0, SMAAngle, 0, j); EMASMAANGLE=iMAOnArray(AUX,21,21,0, MODE_EMA,0); Alert(DoubleToStr(EMASMAANGLE,8));
    One of the issues what the one you already taught me how to correct.

    With the popup alert being properly shown, I need the value it reveals to be the EMA(21) of the values stored in AUX factor.

    However, the value I get doesnt match the one in the chart, and they should be the same.

    I checked the values stored in AUX with alerts and they are stored properly, so the fail is in the
    Inserted Code iMAOnArray(AUX,21,21,0, MODE_EMA,0);
    By the way I assessed switching the order of AUX information and did neither work.

    Just one more thing:
    Thanks for the help!

  5. #5
    To correct a false impression that you and others have programmers can't only look at dozens of line of code and figure out what is wrong except when it is obvious. Even it is not posssible and so it becomes a process of elimination.

    Again I'm imagining. It appears you would like to compute values for the entire array not just the 21 values. I think the call should be iMAOnArray(AUX,0 ,21,0, MODE_EMA,j );

  6. #6
    Yeah exactly what I mean is that I'd spent so long on it I couldnt realize what you state

    As for exactly what I am attempting to get, I'll attempt to clarify it so that you dont need to figure hehe....


    I've an indior (SMAAngle) that has one numerical value with every bar (its not a constant line, just 1 value every bar)
    Afterward, over that indior, I put an EMA with period=21, and change 0, implemented of course to the worth of that indior.

    What I wish to get is just the latest value of that EMA.



    So using the programming:

    * The AUX range has the 21 (and only 21) newest values of this SMAAngle indior
    Decision I assessed the values from the range AUX and they store correctly the worth of SMAAngle indior

    Decision I took the
    Inserted Code EMASMAANGLE=iMAOnArray(AUX,21,21,0, MODE_EMA,0); out of this iteration, since I just want the latest value.

    Shouldnt EMASMAANGLE be returning the latest value of the EMA(21) of this SMAAngle indior?

  7. #7
    Then the code that you wrote should do the job, if you're just considering the value for the most recent pub. However I should point out the other values won't be right and that I had assumed that was the problem.

    I am not so familar with IMAOnArray() so what I do in this situation is loe a part of code that's working and compare it with my code and look for the problem through the process of removal. There are several indiors which come with MT4 such as MACD and ATR which use IMAOnArray(). I would suggest you become familar with them and you will loe problem.

  8. #8
    It is my hope that this can offer some help.

    PHP Code: <code><span style=?color: #000000?> <span style=?color: #0000BB?></span><span style=?color: #FF8000?>//--buffers
    </span><span style=?color: #0000BB?>doubleAUX</span><span style=?color: #007700?>#91;#93;;
    </span><span style=?color: #0000BB?>doubleEMASMAANGLE</span><span style=?color: #007700?>#91;#93;;
    </span><span style=?color: #FF8000?>//------------------------
    </span><span style=?color: #007700?>for(</span><span style=?color: #0000BB?>intj</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?>lt;</span><span style=?color: #0000BB?>21</span><span style=?color: #007700?>;</span><span style=?color: #0000BB?>j</span><span style=?color: #007700?> )

    </span><span style=?color: #0000BB?>AUX</span><span style=?color: #007700?>#91;</span><span style=?color: #0000BB?>j</span><span style=?color: #007700?>#93;=</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: #FF8000?>/*entercustomindiorparametershereifnecessary*/</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?>intcounted_bars</span><span style=?color: #007700?>=</span><span style=?color: #0000BB?>IndiorCounted</span><span style=?color: #007700?>();
    </span><span style=?color: #0000BB?>intlimit</span><span style=?color: #007700?>=</span><span style=?color: #0000BB?>Bars</span><span style=?color: #007700?>-</span><span style=?color: #0000BB?>counted_bars</span><span style=?color: #007700?>;
    for(</span><span style=?color: #0000BB?>inti</span><span style=?color: #007700?>=</span><span style=?color: #0000BB?>0</span><span style=?color: #007700?>;</span><span style=?color: #0000BB?>I</span><span style=?color: #007700?>lt;</span><span style=?color: #0000BB?>restrict</span><span style=?color: #007700?>;</span><span style=?color: #0000BB?>I</span><span style=?color: #007700?> )

    </span><span style=?color: #0000BB?>EMASMAANGLE</span><span style=?color: #007700?>#91;</span><span style=?color: #0000BB?>I</span><span style=?color: #007700?>#93;=</span><span style=?color: #0000BB?>iMAOnArray</span><span style=?color: #007700?>(</span><span style=?color: #0000BB?>AUX</span><span style=?color: #007700?>,</span><span style=?color: #0000BB?>Bars</span><span style=?color: #007700?>,</span><span style=?color: #0000BB?>21</span><span style=?color: #007700?>,</span><span style=?color: #0000BB?>0</span><span style=?color: #007700?>,</span><span style=?color: #0000BB?>MODE_EMA</span><span style=?color: #007700?>,</span><span style=?color: #0000BB?>I</span><span style=?color: #007700?>);
    </span><span style=?color: #0000BB?>Alert</span><span style=?color: #007700?>(</span><span style=?color: #0000BB?>DoubleToStr</span><span style=?color: #007700?>(</span><span style=?color: #0000BB?>EMASMAANGLE</span><span style=?color: #007700?>#91;</span><span style=?color: #0000BB?>I</span><span style=?color: #007700?>#93;,</span><span style=?color: #0000BB?>8</span><span style=?color: #007700?>));

    </span><span style=?color: #0000BB?></span> </span> </code>

  9. #9
    I will research about the indiors you indie CodeMeister.
    Unaiz, the code you shared will get a popup with 0 value.

    Thankyou for your help and time, If I get a solution I will post.

  10. #10
    I remembered something else that this morning about iMAOnArray(). It can not be utilised in an EA. I remember struggling with this for hours - just when I looked for sample code and eventually like you I discovered. What I ended up doing was using iMAOnArray() in an indior and regaining the values by means of iCustom().

    Sorry I didn't recall this in my previous reponses. Do not waste any longer, I doubt whether it could be carried out.

    http://forum.mql4.com/9228

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.