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

Suggestion BANTU PERBAIKI ERROR CODING

Discussion in 'Requests and Suggestions' started by piwel766, 31 Jan 2018.

  1. piwel766

    piwel766 New Member

    Equity
    Credit
    Ref Point
    Hai para master

    Mencoba membuat ea hasil belajar video tutorialnya Soe Hoe.

    Sudah sampai tahap perintah Order tapi ada kendala a di perintah OrderSend terjadi error padahal sudah mengikuti sesuai petunjuk videonya.

    Ada yang bisa bantu membetulkan error coding .

    dan/atau sekalian lanjutkan sampai close order.


    rule EA nya seperti dalam file pdf


    trm kasih


    //+------------------------------------------------------------------+
    //| SimborrokFOREX.mq4 |
    //| Copyright 2017, MetaQuotes Software Corp. |
    //| https://www.mql5.com |
    //+------------------------------------------------------------------+
    [HASHTAG]#property[/HASHTAG] copyright "Copyright 2017, MetaQuotes Software Corp."
    [HASHTAG]#property[/HASHTAG] link "https://www.mql5.com"
    [HASHTAG]#property[/HASHTAG] version "1.00"
    [HASHTAG]#property[/HASHTAG] strict

    extern int NewOrder =3;
    extern double Lots =0.01;
    extern int Magic =4118;
    extern string Pair = "";
    extern string EACom ="SimborrokFOREX";

    extern string MABiru="__________________________________________________";
    extern int Period_=14,//Period
    Shift=0;
    input ENUM_MA_METHOD MAmethod=0;
    input ENUM_APPLIED_PRICE ApplyTo=0;
    extern string MAKuningLevel="__________________________________________________";
    extern int Level1=50,Level2=100,Level3=150,Level4=200,Level5=250;
    extern int Level1_=-500,Level2_=-100,Level3_=-150,Level4_=-200,Level5_=-250;

    extern string MAMerah="__________________________________________________";
    extern int Period_1=5,//Period
    Shift1=0;//Shift
    input ENUM_MA_METHOD MAmethod1=0;//MAmethod
    input ENUM_APPLIED_PRICE ApplyTo1=0;//ApplyTo
    extern string CCI="__________________________________________________";
    extern int CCIPeriod=14,level_0=0,level_up1=100,level_up2=150,level_up3=250,level_dn1=-100,level_dn2=-150,level_dn3=-250;

    extern string William="__________________________________________________";
    extern int period=14,level_tengah=-50,level_up_=-10,level_dn_=-90;


    int Slippage =0;
    string Sym;
    double price;


    //+---------------------------------------------------------------------+

    double ma=iMA(Sym,0,Period_,Shift,MAmethod,ApplyTo,0);
    double mamerah=iMA(Sym,0,Period_1,Shift1,MAmethod1,ApplyTo1,0);

    double ma1=iMA(Sym,0,Period_,Shift,MAmethod,ApplyTo,1);
    double mamerah1=iMA(Sym,0,Period_1,Shift1,MAmethod1,ApplyTo1,1);

    double ma_up1=ma+Level1*Point;
    double ma_up2=ma+Level2*Point;
    double ma_up3=ma+Level3*Point;
    double ma_up4=ma+Level4*Point;
    double ma_up5=ma+Level5*Point;
    double ma_up1x=ma1+Level1*Point;
    double ma_up2x=ma1+Level2*Point;
    double ma_up3x=ma1+Level3*Point;
    double ma_up4x=ma1+Level4*Point;
    double ma_up5x=ma1+Level5*Point;

    double ma_dn1=ma+Level1_*Point;
    double ma_dn2=ma+Level2_*Point;
    double ma_dn3=ma+Level3_*Point;
    double ma_dn4=ma+Level4_*Point;
    double ma_dn5=ma+Level5_*Point;
    double ma_dn1x=ma1+Level1_*Point;
    double ma_dn2x=ma1+Level2_*Point;
    double ma_dn3x=ma1+Level3_*Point;
    double ma_dn4x=ma1+Level4_*Point;
    double ma_dn5x=ma1+Level5_*Point;

    double cci=iCCI(Sym,0,CCIPeriod,0,0);
    double cci1=iCCI(Sym,0,CCIPeriod,0,1);
    double william=iWPR(Sym,0,period,0);
    double william1=iWPR(Sym,0,period,1);

    //+-------------------------------------------------------------+


    int NewOrder(string mySym, int OPType, double myLots)
    {
    int result;

    double myPoint = MarketInfo(mySym,MODE_POINT);
    if (OPType==0)
    {
    price = MarketInfo(mySym,MODE_ASK);
    }

    if (OPType==1)
    {
    price = MarketInfo(mySym,MODE_BID);

    }

    result=OrderSend (mySym,OPType,myLots,price,Slippage,0,0,EACom,Magic,0,Blue);

    }
    //+------------------------------------------------------------------+
    //| Expert initialization function |
    //+------------------------------------------------------------------+
    int OnInit()
    {
    //---
    if(Pair=="") Sym=Symbol(); else Sym=Pair;

    //---
    if(Bars<100)
    {
    Print("Jumlah Bars Masih Kurang");

    }

    return(0);
    }

    //+---------------------------------------------------------+

    int Cross()
    {
    int isCross=Cross();
    if(isCross!=0)
    {
    NewOrder(Sym,isCross-1,Lots);
    }

    if(isCross!=0)
    {
    int oTiket=NewOrder(Sym,isCross-1,Lots);
    if(oTiket>0&&OrderSelect(oTiket,SELECT_BY_TICKET,MODE_TRADES))
    Print("Oder Baru Berhasil");
    }

    static int last_trend;
    static int current_trend;

    if(((mamerah>ma_dn5 && mamerah1<ma_dn5x)||(mamerah>ma_dn4 && mamerah1<ma_dn4x)||(mamerah>ma_dn3 && mamerah1<ma_dn3x)||(mamerah>ma_dn2 && mamerah1<ma_dn2x)||(mamerah>ma_dn1 && mamerah1<ma_dn1x)||
    (mamerah>ma && mamerah1<ma1)||(mamerah>ma_up1 && mamerah1<ma_up1x)||(mamerah>ma_up2 && mamerah1<ma_up2x)||(mamerah>ma_up3 && mamerah1<ma_up3x)||(mamerah>ma_up4 && mamerah1<ma_up4x)||(mamerah>ma_up5 && mamerah1<ma_up5x)) &&
    ((cci>level_dn3 && cci1<level_dn3)||(cci>level_dn2 && cci1<level_dn2)||(cci>level_dn1 && cci1<level_dn1)||(cci>level_0 && cci1<level_0)||
    (cci>level_up1 && cci1<level_up1)||(cci>level_up2 && cci1<level_up2)||(cci>level_up3 && cci1<level_up3)) &&
    ((william>level_dn_ && william1<level_dn_)||(william>level_tengah && william1<level_tengah)||(william>level_up_ && william1<level_up_)))current_trend=1;


    if(((mamerah<ma_up5 && mamerah1>ma_up5x)||(mamerah<ma_up4 && mamerah1>ma_up4x)||(mamerah<ma_up3 && mamerah1>ma_up3x)||(mamerah<ma_up2 && mamerah1>ma_up2x)||(mamerah<ma_up1 && mamerah1>ma_up1x)||(mamerah<ma && mamerah1>ma1)||
    (mamerah<ma_dn1 && mamerah1>ma_dn1x)||(mamerah<ma_dn2 && mamerah1>ma_dn2x)||(mamerah<ma_dn3 && mamerah1>ma_dn3x)||(mamerah<ma_dn4 && mamerah1>ma_dn4x)||(mamerah<ma_dn5 && mamerah1>ma_dn5x)) &&
    ((cci<level_up3 && cci1>level_up3)||(cci<level_up2 && cci1>level_up2)||(cci<level_up1 && cci1>level_up1)||(cci<level_0 && cci1>level_0)||(cci<level_dn1 && cci1>level_dn1)||(cci<level_dn2 && cci1>level_dn2)||(cci<level_dn3 && cci1>level_dn3))&&
    ((william<level_up_ && william1>level_up_)||(william<level_tengah && william1>level_tengah)||(william<level_dn_ && william1>level_dn_)))current_trend=2;


    if(current_trend!=last_trend)
    {last_trend=current_trend;
    return(last_trend);
    }
    else
    {return(0);}


    }

    //+------------------------------------------------------------------+
    //| Expert deinitialization function |
    //+------------------------------------------------------------------+
    void OnDeinit(const int reason)
    {
    //---

    }
    //+------------------------------------------------------------------+
    //| Expert tick function |
    //+------------------------------------------------------------------+
    void OnTick()
    {
    //---

    }
    //+------------------------------------------------------------------+
     

    Attached Files:

    • Like Like x 1
  2. umar ismail

    umar ismail New Member

    Equity
    Credit
    Ref Point
    maaf bro
    itu masuknya perintah dari OnTick() atau OnTimer() atau start()
    tapi OnTick() nya kosong gak ada sambungan ke bagian lain
    jadinya gak ada proses
     
  3. muhkito

    muhkito New Member Credit Hunter

    Equity
    Credit
    Ref Point
    Di akhir function, NewOrder(...) sebelum }, perlu ditulis return (result);
     

Share This Page