Rejoindre la communauté
banner_forum
Devenez membre de la plus grande
communauté francophone sur le Forex
Partagez, échangez et apprenez en gagnant des crédits sur votre compte de trading

Mon premier Robot Expert Advisor (Macd, CCI, BBands)

  • Lorka85

    oui ça s’appelle CloseAtOposite cette fonction dans mes EA.

    d'ailleurs je vais vous partager mes 4-5 autres EA perso ! vous avez étaient assez patient !
  • edgar

    ça c'est du rapide
    mais où trouver ce"CloseAtOposite" et comment l'activer?et que faire des lignes tp et sl?
    si on veut utiliser que 2 mm que faire des autres mm?"mettre un ZERO" à la place de la valeur ou autre chose?merci en tout cas
  • Lorka85

    oui tu peu mettre un tp tres elevé ca marchera. par contre je ne sais pas si tu parle du 1er robot du topic, ou cette fonction n'est pas présente.
  • edgar

    soit celui la(car il est filtré) je pense qu'il evitera les moments sans tendance
    //+------------------------------------------------------------------+
    //| Avg Daily Range.mq4 |
    //| Copyright © 2005, tageiger aka [email protected] |
    //| http://www.metatrader.org |
    //+------------------------------------------------------------------+
    #property copyright "Tous droits réservés, Nicolas Tuffier (2011)"
    #property link "http://www.furyweb.fr/forex/"
    #import "stdlib.ex4"
    string ErrorDescription(int error_code);
    #import
    #include <stderror.mqh>
    #define NAME "EMA MTF CROSS"
    #define VERSION "1.0"
    //#property indicator_chart_window


    extern double lotSize=0.2;
    extern int StopLoss=300;
    extern int FirstEven=150;
    extern int BreakEven=300;
    extern int TakeProfit=500;
    extern string EMAValues="Settings for the 2 EMA";
    //extern int MATF1 = 0;
    extern int MAperiod1 = 2;
    extern int MAperiod2 = 4;
    //extern int MATF2 = 240;
    extern int MAperiod3 = 8;
    extern int MAperiod4 = 16;
    extern bool Alerts = true;
    extern string ADXValues="ADX & CCI Filter (0 for nothing)";
    extern int CCiPeriod=50;
    extern int CCITimeFrame=0;
    extern int CCIbuyLevel=20;
    extern int CCIsellLevel=-20;
    extern string Next="--------------------------------------------------------------------";
    extern int ADXFilterLimit=20;
    extern int AdxPeriod=14;
    extern int AdxTimeFrame=0;
    extern string InfosValues="Label Settings";
    extern bool ShowOtherInfos = true;
    extern bool ShowSpreadAndDailyRange = true;
    extern int DailyAtrPeriod=40;
    extern int LabelXpos=10;
    extern int LabelYpos=15;
    extern string Capture="Screeshots (Stocked in ..\experts\files)";
    extern bool TakeScreenShot = true;
    extern int size_x = 1280;
    extern int size_y = 720;

    int ticket;
    int a = 0;
    int i;
    int magicNumber = 152341;
    double savedVolume;
    double adx, TPPoints, SLPoints;
    string symbolpair, time;
    bool Buy,Sell;
    double MA1, MA2, MA3, MA4;
    string MAvalue, MAvalue2;
    //+------------------------------------------------------------------+
    //| |
    //+------------------------------------------------------------------+
    int init()
    {

    // TPPoints = TakeProfit * Point * MathPow(10, Digits % 2);
    //SLPoints = StopLoss * Point * MathPow(10, Digits % 2);

    return(0);}


    bool newBarFormed() {
    bool ret=Volume[0] < savedVolume;
    savedVolume = Volume[0];
    return(ret);


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

    //+------------------------------------------------------------------+
    //| |
    //+------------------------------------------------------------------+
    int start()
    {
    if (OrdersTotal()>0)
    OrdersList();

    double cci ;
    cci = iCCI(NULL,CCITimeFrame,CCiPeriod,PRICE_CLOSE,0);


    adx = iADX(NULL,AdxTimeFrame,AdxPeriod,PRICE_CLOSE,MODE_MAIN,0);

    MA1 = iMA(NULL,0,MAperiod1,0,MODE_EMA,PRICE_CLOSE,1);
    MA2 = iMA(NULL,0,MAperiod2,0,MODE_EMA,PRICE_CLOSE,1);

    MA3 = iMA(NULL,0,MAperiod3,0,MODE_EMA,PRICE_CLOSE,1);
    MA4 = iMA(NULL,0,MAperiod4,0,MODE_EMA,PRICE_CLOSE,1);


    //------------------------------------------
    if( MA1 > MA2)
    {
    MAvalue = "UP]";
    }
    if( MA1 < MA2)
    {
    MAvalue = "Down]";
    }

    if( MA3 > MA4)
    {
    MAvalue2 = "UP]";
    }
    if( MA3 < MA4)
    {
    MAvalue2 = "Down]";
    }

    symbolpair = Symbol();
    time = TimeToStr(TimeCurrent());

    if (ShowOtherInfos == true)
    {
    ObjectCreate("BarTimer3" ,OBJ_LABEL,0,0,0);
    ObjectSet("BarTimer3", OBJPROP_XDISTANCE, LabelXpos);
    ObjectSet("BarTimer3", OBJPROP_YDISTANCE, LabelYpos);
    ObjectSetText("BarTimer3", "[MA1 : "+MAvalue+" - [MA2 : "+MAvalue2+" - [ADX("+AdxTimeFrame+";) : "+DoubleToStr(adx, 0)+ "] - [CCI("+CCITimeFrame+";): "+DoubleToStr(cci,0)+"]", 11, "Arial", White);
    }


    if (ShowSpreadAndDailyRange == true)
    {
    ObjectCreate("BarTimer4" , OBJ_LABEL,0,0,0);
    ObjectSet("BarTimer4", OBJPROP_XDISTANCE, LabelXpos);
    if (ShowOtherInfos == true)
    ObjectSet("BarTimer4", OBJPROP_YDISTANCE, LabelYpos+22);
    else
    ObjectSet("BarTimer4", OBJPROP_YDISTANCE, LabelYpos);
    ObjectSetText("BarTimer4", "[Day ATR"+DailyAtrPeriod+" : "+DoubleToStr(iATR(NULL,1440,DailyAtrPeriod,0)*10000, 0)+ "] - [Day Range : "+DoubleToStr(iATR(NULL,1440,1,0)*10000, 0)+"] - [Spread : "+DoubleToStr(MarketInfo("EURUSD",MODE_SPREAD)/10,1)+ " Pips]", 11, "Arial", Yellow);
    }
    else
    ObjectDelete("BarTimer4";);

    bool buySignal, sellSignal;


    if (a == 0)
    {

    if(MA1 < MA2 && MA3 < MA4)
    a=1;


    if(MA1 > MA2 && MA3 > MA4)
    a=2;

    }


    if (newBarFormed())
    {

    //------------ verif de positions
    int scnt = 0, bcnt = 0, cnt = OrdersTotal();
    for (i = 0; i < cnt; i++)
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
    if (OrderMagicNumber() == magicNumber)
    if (OrderType() == OP_BUY && OrderSymbol() == symbolpair)
    bcnt++;
    else
    if (OrderType() == OP_SELL && OrderSymbol() == symbolpair)
    scnt++;
    // -------------- fin verif

    Buy = MA1 > MA2 && MA3 > MA4 ;
    Sell = MA1 < MA2 && MA3 < MA4;


    }




    if (adx>ADXFilterLimit)
    {
    //------------------------------------------

    if((Buy) && a != 2)
    {

    if (cci >= CCIbuyLevel)
    {

    if (Alerts == true)
    Alert(Symbol()," - EMA CROSS UP - BUY - ",Period()," @ ",Bid," ",time);

    if (bcnt == 0)
    {

    //----------- passage d'ordre avec verif harcelement
    ticket=OrderSend(Symbol(), OP_BUY, lotSize, Ask, 3, 0, 0, NAME + " " + VERSION, magicNumber);

    while (ticket == -1) // tant que l’ordre n’est pas passé
    {
    Sleep(1000); // on attend une seconde
    RefreshRates(); //on rafraichit les valeurs du cours de la paire
    ticket = OrderSend(Symbol(), OP_BUY, lotSize, Ask, 3, 0, 0, NAME + " " + VERSION, magicNumber);
    }
    //------------ fin passage d'ordre

    //OrderSend(Symbol(), OP_BUY, lotSize, Ask, 3, 0, 0, NAME + " " + VERSION, magicNumber);

    if (TakeScreenShot == true)
    if(!WindowScreenShot(StringConcatenate(NAME + "-" + Symbol(),"-",Period(),"-",TimeToStr(TimeCurrent(),TIME_DATE),"-",Hour(),"H",Minute(),".gif";),size_x,size_y))
    Print(GetLastError());
    }
    a = 2;

    }
    }

    if((Sell) && a != 1)
    {

    if (cci <= CCIsellLevel)
    {


    if (Alerts == true)
    Alert(Symbol()," - EMA CROSS DOWN - SELL - ",Period()," @ ",Bid," ",time);

    if (scnt == 0)
    {

    //----------- passage d'ordre avec verif harcelement
    ticket=OrderSend(Symbol(), OP_SELL, lotSize, Bid, 3, 0, 0, NAME + " " + VERSION, magicNumber);

    while (ticket == -1) // tant que l’ordre n’est pas passé
    {
    Sleep(1000); // on attend une seconde
    RefreshRates(); //on rafraichit les valeurs du cours de la paire
    ticket = OrderSend(Symbol(), OP_SELL, lotSize, Bid, 3, 0, 0, NAME + " " + VERSION, magicNumber);
    }
    //------------ fin passage d'ordre


    // OrderSend(Symbol(), OP_SELL, lotSize, Bid, 3, 0, 0, NAME + " " + VERSION, magicNumber);
    if (TakeScreenShot == true)
    if(!WindowScreenShot(StringConcatenate(NAME + "-" + Symbol(),"-",Period(),"-",TimeToStr(TimeCurrent(),TIME_DATE),"-",Hour(),"H",Minute(),".gif";),size_x,size_y))
    Print(GetLastError());
    }
    a = 1;


    }
    }
    //------------------------------------------


    }

    return(0); }
    //+------------------------------------------------------------------+




    void OrdersList()
    {
    for (int cnt=0;cnt<OrdersTotal();cnt++)
    {
    OrderSelect(cnt, SELECT_BY_POS);
    if (OrderSymbol()==Symbol() && OrderMagicNumber() == magicNumber)
    {
    if (OrderType()==OP_BUY)
    {
    if (OrderStopLoss()==0)
    {
    OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-StopLoss*Point,OrderOpenPrice()+TakeProfit*Point,0,LightGreen);
    return(0);
    }
    //---- FirstEven
    if (Bid-OrderOpenPrice()>Point*FirstEven&&OrderStopLoss()<OrderOpenPrice()&&Bid-OrderOpenPrice()<Point*BreakEven)
    {

    {OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-Point*StopLoss/2,OrderTakeProfit(),0,LightGreen);
    return(0);}
    }

    //---- BreakEven
    if (Bid-OrderOpenPrice()>Point*BreakEven&&OrderStopLoss()<OrderOpenPrice())
    {

    {OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0,LightGreen);
    return(0);}
    }
    }
    if (OrderType()==OP_SELL)
    {
    if (OrderStopLoss()==0)
    {
    OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+StopLoss*Point,OrderOpenPrice()-TakeProfit*Point,0,Yellow);
    return(0);
    }

    //---- FirstEven
    if (OrderOpenPrice()-Ask>Point*FirstEven&&OrderStopLoss()>OrderOpenPrice()&&OrderOpenPrice()-Ask<Point*BreakEven)
    {

    {OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+Point*StopLoss/2,OrderTakeProfit(),0,Yellow);
    }
    return(0);
    }

    //---- BreakEven
    if (OrderOpenPrice()-Ask>Point*BreakEven&&OrderStopLoss()>OrderOpenPrice())
    {

    {OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0,Yellow);
    }
    return(0);
    }
    }
    }
    }

    }





    //+------------------------------------------------------------------+
    //| expert deinitialization function |
    //+------------------------------------------------------------------+
    int deinit() {
    //----

    ObjectDelete("BarTimer3";);
    ObjectDelete("BarTimer4";);


    //----
    return(0);
    }
    ce qui m'interesse et de remplacer les sl et tp par le croisement des mm ( l'efficacité est est superieur) avec les les SL et TP on peut aller aller à la faillite en reel tres rapidement
    ci joint mon adresse:[email protected]
  • edgar

    bonjour,après une reponse rapide hop le silence???
    comme je suis avec avafx(en reel) j'ai trouvé 1 en.act et non .mq4,je pense changer de platforme et revenir en metatrader
    bonne journée et surtout bonne chasse
  • fireball

    Super interessant ton EA , je travaille actuellement avec safe3
    Si ils sont encore disponiblez je veux bien les tester.
    [email protected].
    Merci d'avance
  • fabian.schoonjans

    Bonjour tout le monde,

    Serait-il encore possible de tester l'EA décrit ci dessous ??

    => mega upload n'étant plus dispo.. si qlq un a un autre lien, ou via mail [email protected]

    Merci d'avance!


    "
    xpert Advisor (Macd, CCI, BBands)
    Lorka85 Trader forex Lorka85
    816 messages
    Trader Forex
    #29267, 02/06/2011
    Merci de vos intérêts pour le sujet, a plusieurs, les avis seront plus complets
    voici mon EA nommé sobrement EMA cross STRATEGIE EA !

    http://www.megaupload.com/?d=OWR9KTNC

    Mettez les fichiers au bon endroit (les dossiers dans le zip parlent d'eux même)

    le principe de la stratégie :
    En timeFrame M30 On a :
    une EMA2 et une EMA4 !
    et une EMA 16 et une EMA32 (représentant a peu près les EMA2 et EMA4 sur un timeframe H4);

    Quand l'ema2 croise par le dessus l'ema4 ET si l'ema16 est déja au dessus de l'ema32 (donc tendance de fond haussiere) : l'ea prend position ! et vis versa.
    Pour ses positions :
    TP a 50 pips, SL a 30 pips, si 15 pips franchis en positif, le SL se rabat a seulement 15 pips, et si 26 pips franchie, le breakeven s'enclenche pour sécurisé les gains : sois vous tapez les 50 pips, sois vous ne perdez et gagner rien.

    Bien sur, vous pouvez modifier les périodes EMA, les TP, SL, pour tenter de trouver une optimisation possible.

    il y a 2 templates: un avec filtre adx et cci (l'adx doit etre a plus de 20, cci a + de 20 pour BUY), et un sans filtres (dans ce cas ça prend position a chaque fois que les 2 barres du templates correspondrons.) j'ai perso tester sans filtre pour mes résultats.
    sachez que l'ea prend un screenshot a chaque position pour preuve (peu être désactiver)
    voici une image de ce que vous devriez avoir niveau template (voir screenshot)

    Bon test :)

    "
Page 7