Sending algorithmic string to buy signal in mt4

thread: Sending algorithmic string to buy signal in mt4

  1. #1
    Junior Member phexom's Avatar
    28

    Sending algorithmic string to buy signal in mt4

    I'm analyzing lots of buy signals in an EA and wish to send an algorithm for a string. If I copy and paste the string into the buy sign it works but if I keep it like a variable it does not work, or works differently. It should work the same. In this instance, if I copy and paste OpenTradeSignal 1 without the quotes that is (Close[1] gt; Close[X]) into the parenthesis at which BuySignal is, it works fine, however if I would like it to read from the code it does not. What am I doing wrong here?

    Inserted Code extern int OpenTradeSignal = 1; ////////// string BuySignal; string SellSignal; if (OpenTradeSignal == 1) BuySignal = (Close#91;1#93; gt; Close#91;X#93;-RRB-; SellSignal = (Close#91;1#93; lt; Close#91;X#93;-RRB-; if (OpenTradeSignal == two ) BuySignal = (Close#91;1#93; lt; Close#91;X#93;-RRB-; SellSignal = (Close#91;1#93; gt; Close#91;X#93;-RRB-; if (BuySignal) Comment(TimeToStr(TimeCurrent(),TIME_SECONDS), X gt; Y BUY SIGNAL, Ask); Print(TimeToStr(TimeCurrent(),TIME_SECONDS), X gt; Y BUY SIGNAL, Ask); if (countL1 lt; NP) fBuy1(); if (SellSignal) { Comment(TimeToStr(TimeCurrent(),TIME_SECONDS), X lt; Y SELL SIGNAL, Bid); // Printing (TimeToStr(TimeCurrent(),TIME_SECONDS), X lt; Y SELL SIGNAL, Bid); { if (countS1 lt; NP) fSell1();

  2. #2
    Junior Member phexom's Avatar
    28
    Got it. Thank you. Can this. Thank you again.

    Example (for other people to see if they come across this):

    Inserted Code if (OpenTradeSignalA == 1) if ((Open#91;Y#93; gt; Open#91;X#93;-RRB- BuySignalA = true; if ((Open#91;Y#93; lt; Open#91;X#93;-RRB- SellSignalA = true; if (OpenTradeSignalA == 2) if ((Close#91;Y#93; gt; Close#91;X#93;-RRB- BuySignalA = true; if ((Close#91;Y#93; lt; Close#91;X#93;-RRB- SellSignalA = true; etc. then

    if BuySignalA then Buy etc..

  3. #3
    Junior Member Lolopawz9's Avatar
    15
    I'd write it like under, if it were me:

    Inserted Code OpenTradeSignalA = TRUE; //--assign False or True value to your variable //--then use if Sayings if(OpenTradeSignalA) //--variable is either true or false /--three possible choices: greater, less or equal if(Open#91;y93; gt; Open#91;x93;-RRB- //--Higher BuySignalA = true; else if(Open#91;y#93; lt; Open#91;x93;-RRB- //--less SellSignalA = true; else //--equal //------------------------------no Sign - Maintain staring at chart else //--OpenTradeSignalA is false... if(Close#91;y#93; gt; Close#91;x93;-RRB- //--Higher BuySignalA = true; else if(Close#91;y93; lt; Close#91;x93;-RRB- //--less SellSignalA = true; else //--equal //---------------------------no Sign - Maintain staring at chart
    In your example, you have a Lot of left parantheses and you haven't explicitly dealt with prices being equal.

    My true or false may not be right in this case, as I wasn't sure if you're using 2 or 1 as authentic....

    Hope the above is helpful?

    OD

  4. #4
    Junior Member phexom's Avatar
    28
    Yeah you are right. Too many parens. I copied and pasted incorrectly.

    So far as the logic goes, the true EA code has if (OpenTradeSignalA == 1) as INT and it goes out of 1 through 20(for 20 distinct signs ). I have it that way so I could test which of those 20 signals were lately best.

  5. #5
    You still do not know to code in mql. That's the problem. Your code contains logic/syntax flaws.
    1. Your 1st/2nd if-statements (both) are terminated following the first announcement that follows.
    2. You are using strings (3th/4th outer if-statements) instead of a boolean (logical ) expression (the compiler will not evaluate the meaning of the string!) .

  •