need help on programming 2 SMAs on an indior

thread: need help on programming 2 SMAs on an indior

  1. #1

    need help on programming 2 SMAs on an indicator

    Hi,

    New to programming MT4 and'm struggling on the announcing my factors.

    What I want to do is get an external input for two simple moving averages, then compare them to one another, if I receive a long sign, I want an up arrow and when a brief sognal a down arrow (of course).

    When I go to compile, I get an error I have not defined the the MA's correctly. My syntax is messed up or it could be within my IF statement as an example for my fast moving average = F_MA and I have a announcement (F_MA(2) lt; F_MA(1)). . .what I am attempting to do there, is when the speedy ma of two bars past is significantly less than the last speedy ma pub ect...I could be totally off there also...

    I have been searching for different indiors I can check out and see what I am doing wrong and'm not seeing anything as simple as what I want to do. . .any thoughts or instructions would be appreciated.

  2. #2
    Change it from (1) to [1] and (2) to [2]

  3. #3
    Thank you, that took care of one thing, I wished to look before I asked my next thing...I guess I know enough to be dangerous

    I figure I'm not announcing it correctly because now I'm getting an unexpected mistake on the square brackets. Below is how I'm declaring the fast ma, and beneath this is part of the if statement, I just want to compare the latest closed pub with the pub before, which is all and that I thought I could use prevBar[1]and prevBar[2] but I cant find that in the guide...

    dual F_MA = iMA(Symbol(),0,( FAST_MA ),0,0,PRICE_CLOSE,0);

    if ((F_MA[2] lt; F_MA[1]) (S_MA[2] lt;= S_MA[1]) || (F_MA[2] lt;= F_MA[1]) (S_MA[2] lt; S_MA[1]))

  4. #4
    I went back and read a little more and I think I got it. . .only today I dont get no errors, however when I attempt to load up the indior after compiling, it will load, so on to the next thing haha!

    This is what I ended up doing, not for certain if this is the neatest way I could do it, just announced 2 fast MA's and that seemed to fix the error...



    double F_MAa = iMA(Symbol(),0,( FAST_MA ),0,0,PRICE_CLOSE,1);
    double F_MAb = iMA(Symbol(),0,( FAST_MA ),0,0,PRICE_CLOSE,2);

  •