1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Welcome back! Thank you for being a part of this Traders Community. Let's discuss and share :)
    Selamat datang kembali! Trimakasih telah menjadi bagian dari Komunitas Trader ini. Mari berdiskusi dan berbagi :)
    Dismiss Notice

reduce EA Code

Discussion in 'Belajar MQL dari Nol' started by momo2077, 10 Feb 2019.

  1. momo2077

    momo2077 New Member

    Equity
    Credit
    Ref Point
    Hello everybody,



    I have an EA code with three "blocks" for the order "buy". Only the text changes ("buy now", "buynow", "buy.now"). I want to reduce the EA code, only make one out of three blocks. Can I put the blocks in a block?



    //-- buy now

    k = StringFind(text, " buy now " );
    if (k > 0)
    {
    Done = false;

    Trade_Type[NumOfTrades] = OP_BUY;
    pos = k + StringLen(" buy now ");
    pos2 = StringFind(text, " ", pos);
    len = pos2-pos;
    Trade_Price[NumOfTrades] = (double) StringSubstr(text, pos, len);
    NumOfTrades++;

    StringReplace(text, " buy now " , "");
    }

    k = StringFind(text, "buynow ");
    if (k > 0)
    {
    Done = false;

    Trade_Type[NumOfTrades] = OP_BUY;
    pos = k + StringLen( "buynow " );
    pos2 = StringFind(text, " ", pos);
    len = pos2-pos;
    Trade_Price[NumOfTrades] = (double) StringSubstr(text, pos, len);
    NumOfTrades++;

    StringReplace(text, " buynow " , "");
    }

    k = StringFind(text, " buy.now ");
    if (k > 0)
    {
    Done = false;

    Trade_Type[NumOfTrades] = OP_BUY;
    pos = k + StringLen(" buy.now ");
    pos2 = StringFind(text, " ", pos);
    len = pos2-pos;
    Trade_Price[NumOfTrades] = (double) StringSubstr(text, pos, len);
    NumOfTrades++;

    StringReplace(text, " buy.now " , "");
    }
     

Share This Page