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

Ajouter une fonction Martingale a ce robot.. HELP

  • arka3579

    Voici un robot un peu modifier par mes soins que j'aime bien dans sa base.
    j'aimerai lui ajouter une martingale si perte financière sur clôture.

    voici le code :

    Code
    //+------------------------------------------------------------------+ //| MACross.mq4 | //+------------------------------------------------------------------+ #property version "1.00" //--- input parameters extern bool Power_ON = true; input int Magic = 1; //Magic Number extern string __8 = "|||||||||| ICHIMOKU ||||||||||"; extern int Tenkan = 8; extern int Kijun = 23; extern int Senkou = 52; input double Lots_X = 29; //Lot Size input double minEquity = 10.0; //Min. Equity ($) extern string __15 = "||||||||||||||||||||||| TERMINAL Comments ||||||||||||||||||||||||||||||"; input string Buy_Com = __FILE__; input string Sell_Com = __FILE__; //Variabel Global double myPoint = 0.0; int mySlippage = 0; int BuyTicket = 0; int SellTicket = 0; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //validasi input, sebaiknya kita selalu melakukan validasi pada initialisasi data input if (Lots_X < 0.01 || minEquity < 10){ Alert("WARNING - Input data inisial tidak valid"); return (INIT_PARAMETERS_INCORRECT); } double min_volume=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MIN); if(Lots_X<min_volume) { string pesan =StringFormat("Volume lebih kecil dari batas yang dibolehkan yaitu %.2f",min_volume); Alert (pesan); return(INIT_PARAMETERS_INCORRECT); } myPoint = GetPipPoint(Symbol()); mySlippage = GetSlippage(Symbol(),3); return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { Print ("EA telah diberhentikan"); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { if (cekMinEquity()){ int signal = -1; bool isNewCandle = NewCandle(Period(), Symbol()); signal = getSignal(isNewCandle); transaction(isNewCandle, signal); }else{ //Stop trading, karena equity tidak cukup Print ("Vérifier Equity"); } } void transaction(bool isNewCandle, int signal){ if (isNewCandle==false) return; int tOrder = 0; int tOrderBuy = 0, tOrderSell = 0; string strMN = "", pair = ""; int tiketBuy = 0, tiketSell = 0; double lotBuy = 0.0, lotSell = 0.0; pair = Symbol(); tOrder = OrdersTotal(); for (int i=tOrder-1; i>=0; i--){ bool hrsSelect = OrderSelect(i, SELECT_BY_POS, MODE_TRADES); strMN = IntegerToString(OrderMagicNumber()); if (StringFind(strMN, IntegerToString(Magic), 0) == 0 && StringFind(OrderSymbol(), pair, 0) == 0 ){ if (OrderType() == OP_BUY){ tOrderBuy++; tiketBuy = OrderTicket(); lotBuy = OrderLots(); } if (OrderType() == OP_SELL){ tOrderSell++; tiketSell = OrderTicket(); lotSell = OrderLots(); } }//end if magic number && pair }//end for double lot = 0.0; double hargaOP = 0.0; double sl = 0.0, tp = 0.0; int tiket = 0; int orderType = -1; //Open pertama kali if (signal == OP_BUY && tOrderBuy == 0){ lot = getLotSize(); orderType = signal; hargaOP = Ask; tiket = OrderSend(Symbol(), orderType, lot, hargaOP, mySlippage, sl, tp, Buy_Com, Magic, 0, clrBlue); if (tiketSell > 0){ if (OrderClose(tiketSell, lotSell, Ask, mySlippage, clrRed)){ Print ("Close successful"); } } }else if (signal == OP_SELL && tOrderSell == 0){ lot = getLotSize(); orderType = signal; hargaOP = Bid; tiket = OrderSend(Symbol(), orderType, lot, hargaOP, mySlippage, sl, tp, Sell_Com, Magic, 0, clrRed); if (tiketBuy > 0){ if (OrderClose(tiketBuy, lotBuy, Bid, mySlippage, clrRed)){ Print ("Close successful"); } } } } int getSignal(bool isNewCandle){ int signal = -1; if (isNewCandle==true){ //Moving Averages double T_0=iIchimoku(NULL, 0, Tenkan, Kijun, Senkou, MODE_TENKANSEN, 0); double T_1=iIchimoku(NULL, 0, Tenkan, Kijun, Senkou, MODE_TENKANSEN, 1); double K_0=iIchimoku(NULL, 0, Tenkan, Kijun, Senkou, MODE_KIJUNSEN, 0); double K_1=iIchimoku(NULL, 0, Tenkan, Kijun, Senkou, MODE_KIJUNSEN, 1); if( T_1 < K_1 && T_0 >= K_0 ){ signal = OP_BUY; }else if( T_1 > K_1 && T_0 <= K_0 ) { signal = OP_SELL; } } return (signal); } double getLotSize(){ double lot = 0.0; lot = NormalizeDouble((AccountEquity() * 0.001 /Lots_X), 2); return (lot); } //fungsi tambahan untuk cek equity minimum bool cekMinEquity(){ bool valid = false; double equity = 0.0; equity = AccountEquity(); if (equity > minEquity){ valid = true; } return (valid); } // Fungsi GetPipPoint double GetPipPoint(string pair) { double point= 0.0; int digits = (int) MarketInfo(pair, MODE_DIGITS); if(digits == 2 || digits== 3) point= 0.01; else if(digits== 4 || digits== 5) point= 0.0001; return(point); } // Fungsi GetSlippage int GetSlippage(string pair, int SlippagePips) { int slippage = 0; int digit = (int) MarketInfo(pair,MODE_DIGITS); if(digit == 2 || digit == 4) slippage = SlippagePips; else if(digit == 3 || digit == 5) slippage = SlippagePips * 10; return(slippage ); } bool NewCandle(int tf, string pair = "" ){ bool isNewCS = false; static datetime prevTime = TimeCurrent(); if (pair == "") pair = Symbol(); if (prevTime < iTime(pair, tf, 0)){ isNewCS = true; prevTime = iTime(pair, tf, 0); } return isNewCS; }

    J y arrive pas )=
  • Mikiburger

    Bonjour Yohan,

    A utiliser sur EURUSD ? Quelle TF ?
    J'ai fait un rapide BT sur différent TF et ce n'est pas spécialement rentable.
  • arka3579 — en réponse à Mikiburger dans son message #125648

    Bjr Miki;
    Plusieurs choses intéressantes..

    Commençons par l'essentiel.. ma demande ; J'aimerai mettre une martingale suite a perte financière. eur/usd ou pas, c'est secondaire dans un 1er temps.

    Concernant les monnaies, matières, ou indices perso je suis branché US.
    En terme d'unité de temps mon ptit bb a moi c'est le M15 (Je lui fait confiance, je ne saurais dire pk)
    Concernant les résultats financier bénéfiques, je pense que c'est.. Un marché, une psychologie, donc.. UN REGLAGE pour chacun.
    Le passe partout j'y crois pas. (ce serai si beau)

    Ma question est bien d 'ordre technique et mettre une martingale sur ce robot.
    Cordialement.

    aRka. [ Le backtest c'est bien, ouvrir ses yeux.. C EST MIEUX ]
  • phvdweid

    Bonjour,
    Avez-vous trouvé quelqu'un pour mettre une martingale sur votre robot ? si non, je peux vous le faire.
    Salutations. Philippe
  • arka3579

    Bjr Philippe, je ne m'en suis pas occupé. Une proposition de code reste la bienvenue.
    aRka.
  • phvdweid — en réponse à arka3579 dans son message #125756

    Je peux vous livrer une très bonne martingale qui est celle d'ALEMBEX. Vous pouvez vous renseigner sur cette méthode, c'est celle qui ,sauf erreur de ma part, a permis à Belkhayate de devenir champion du monde de trading.
    Salutations. PhvdW
  • Mikiburger

    Bonjour Philippe,

    Le code m'intéresse aussi
  • Dreamer

    Les martingales peuvent être profitables un certain temps, parfois des mois, mais finissent toujours mal, tôt ou tard, et jusqu'à preuve du contraire.