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

GAP EURUSD 1 MN VERSION 2

  • lefeuvr3

    Code
    //+------------------------------------------------------------------+ //| Gap 1 mn version2.mq4 | //| Copyright 2019, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2019, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" #property strict //+------------------------------------------------------------------+ extern int MagicNumber=10001; extern int LotFactor =80; extern double StopLoss=0; extern double TakeProfit=32; extern int TrailingStop=16; extern int Slippage=3; extern string mn="GAP-1-MN"; extern int min_gapsize = 0; extern double gain1 = 0.4; extern double gain2 = 0.5; //---- datetime order_time = 0; extern int Start_Time = 0; // Time to allow trading to start ( hours of 24 hr clock ) 0 for both disables extern int Finish_Time = 0; // Time to stop trading ( hours of 24 hr clock ) 0 for both disables //+------------------------------------------------------------------+ // expert start function //+------------------------------------------------------------------+ int start() { double MyPoint=Point; if(Digits==3 || Digits==5) MyPoint=Point*10; double TheStopLoss=0; double TheTakeProfit=0; if( TotalOrdersCount()==0 ) { int result=0; if(TimeHour(TimeCurrent())>=Start_Time && TimeHour(TimeCurrent())<=Finish_Time )return(0); // Defining the variables to decide. Print("order time", order_time); double current_openprice = iOpen(Symbol(),PERIOD_M1, 0); double previous_highprice = iHigh(Symbol(),PERIOD_M1, 1); double previous_lowprice = iLow(Symbol(),PERIOD_M1, 1); double point_gap = MarketInfo(Symbol(), MODE_POINT); int spread_gap = (int) MarketInfo(Symbol(), MODE_SPREAD); datetime current_time = iTime(Symbol(),PERIOD_M1, 0); // catching the gap on sell upper gap if(current_openprice > previous_highprice + (min_gapsize + spread_gap)*point_gap && current_time != order_time) //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ // Here is your open buy rule//Ici votre strategie d'achat // Here is your open buy rule if(current_openprice < previous_lowprice - (min_gapsize + spread_gap)*point_gap*gain2 && current_time != order_time) //if (!IsTradeContextBusy() && IsTradeAllowed()) { result = OrderSend(Symbol(), OP_BUY,(AccountEquity() * 0.01 /LotFactor), Ask, 0, 0, previous_lowprice - spread_gap*point_gap*gain1, "GAP-30-MN", MagicNumber, 0, Green); order_time = iTime(Symbol(),PERIOD_M1, 0); Print("I am inside (buy) :-)", order_time); if(result < 0) { Print("OrderSend failed with error #", GetLastError()); } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ { TheStopLoss=0; TheTakeProfit=0; if(TakeProfit>0) TheTakeProfit=Ask+TakeProfit*MyPoint; if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint; if( OrderSelect(result,SELECT_BY_TICKET)) bool modif1= OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green); } return(0); } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ // Here is your open Sell rule//Ici votre strategie de vente if(TimeHour(TimeCurrent())>=Start_Time && TimeHour(TimeCurrent())<=Finish_Time )return(0); // Defining the variables to decide. Print("order time", order_time); // catching the gap on sell upper gap if(current_openprice > previous_highprice + (min_gapsize + spread_gap)*point_gap*gain2 && current_time != order_time) //if (!IsTradeContextBusy() && IsTradeAllowed()) { result = OrderSend(Symbol(), OP_SELL, (AccountEquity() * 0.01 /LotFactor), Bid, 0, 0, previous_highprice + spread_gap*point_gap*gain1, "GAP-30-MN", MagicNumber, 0, Red); order_time = iTime(Symbol(),PERIOD_M1, 0); Print("I am inside (sell) :-)", order_time); //---- if(result < 0) { Print("OrderSend failed with error #", GetLastError()); } } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ { { TheStopLoss=0; TheTakeProfit=0; if(TakeProfit>0) TheTakeProfit=Bid-TakeProfit*MyPoint; if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint; if( OrderSelect(result,SELECT_BY_TICKET)) bool modif2= OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green); } return(0); } } for(int cnt=0;cnt<OrdersTotal();cnt++) { if( OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES)) if(OrderType()<=OP_SELL && OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber ) { if(OrderType()==OP_BUY) { if(TrailingStop>0) { if(Bid-OrderOpenPrice()>MyPoint*TrailingStop) { if(OrderStopLoss()<Bid-MyPoint*TrailingStop) { bool modif3= OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TrailingStop*MyPoint,OrderTakeProfit(),0,Green); return(0); } } } } else { if(TrailingStop>0) { if((OrderOpenPrice()-Ask)>(MyPoint*TrailingStop)) { if((OrderStopLoss()>(Ask+MyPoint*TrailingStop)) || (OrderStopLoss()==0)) { bool modif4= OrderModify(OrderTicket(),OrderOpenPrice(),Ask+MyPoint*TrailingStop,OrderTakeProfit(),0,Red); return(0); } } } } } } return(0); } int TotalOrdersCount() { int result=0; for(int i=0;i<OrdersTotal();i++) { if(OrderSelect(i,SELECT_BY_POS ,MODE_TRADES)) if (OrderMagicNumber()==MagicNumber) result++; } return (result); }
    lefeuvr3 a joint une image
    gap-eurusd-1-mn-version-2-12004
  • lefeuvr3

    Je me suis amusé à décliner cet EA sur d'autres unités de temps en modifiant le programme d'un«chouia»....et bien ,ce n'est pas mal non plus,sachant que l'on peut tous les utiliser en même temps car les programmes calculent la taille des lots automatique en fonctions des ordres déjà places .