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

QPG RENKO VERSION 2

  • lefeuvr3

    Je me suis inspire de la demarche RENKO mais de loin :)
    Merci d'ameliorer cet EA
    Code
    //+------------------------------------------------------------------+ //| QPG RENKO VERSION 2.mq4 | //| QPG | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "QPG" #property link "https://www.mql5.com" #property version "1.00" extern string mm="MONEY MANAGEMENT"; double lot; extern double LotFactor = 145; //lotsize factor extern bool trail = true; extern double TrailingStop = 67; extern int StopLoss=5000; //stop loss extern int TakeProfit=70; //take profit extern double pips = 0.00001; //leave as default for 5 digit brokers extern int Slippage=3; extern int MagicNumber=20180807; //magic sinput string RSI_Settings; input int period=12; // Averagin period for calculation input ENUM_APPLIED_PRICE appPrice=PRICE_HIGH; // Applied price input int OverSold=85; // Over bought level input int OverBought=15; // Over sold level extern string bo="BOOSTER"; extern int adxthreshold = 33; //adx threshold - must be greater than this to trade extern int adxperiod = 24; //adx period extern int rsiperiod = 4; //rsi period extern int rsiupper = 90; //rsi upper bound, wont buy above this value extern int rsilower = 70; //rsi lower bound, wont sell below this value extern int C0=0; extern int H1=1; extern int H2=2; extern int L1=1; extern int L2=2; extern int delta=27; //---- double TP=0,SL=0,TR; //+------------------------------------------------------------------+ //| Hidden StopLoss Calculations | //+------------------------------------------------------------------+ void StpLoss() { double MyPoint=Point; if(Digits==3 || Digits==5) MyPoint=Point*10; TP=TakeProfit*MyPoint; SL=StopLoss*MyPoint; double OrdP=0,OrdTP=0,OrdSL=0; for(int i=0; i<OrdersTotal(); i++) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) if(OrderMagicNumber()==MagicNumber && Symbol()==OrderSymbol()) { OrdP=OrderProfit()-MathAbs(OrderSwap())-MathAbs(OrderCommission()); OrdSL=(-1)*SL*OrderLots()*MarketInfo(OrderSymbol(),MODE_TICKVALUE)/Point; OrdTP=TP*OrderLots()*MarketInfo(OrderSymbol(),MODE_TICKVALUE)/Point; if(OrdP>OrdTP || OrdP<OrdSL) { if(OrderType()==OP_BUY) bool OrdClP=OrderClose(OrderTicket(),OrderLots(),Bid,Slippage,clrGreen); if(OrderType()==OP_SELL) bool OrdClL=OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,clrYellow); } } } } //+------------------------------------------------------------------+ //| Trailing Stop | //+------------------------------------------------------------------+ void trail() { for (int i = 0; i < OrdersTotal(); i++) { if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) if ( OrderSymbol()==Symbol() ) { if (OrderType() == OP_BUY) { if (Bid - OrderOpenPrice() > TrailingStop * MarketInfo(OrderSymbol(), MODE_POINT)) { if (OrderStopLoss() < Bid - TrailingStop * MarketInfo(OrderSymbol(), MODE_POINT)) { bool modify1=OrderModify(OrderTicket(), OrderOpenPrice(), Bid - TrailingStop * MarketInfo(OrderSymbol(), MODE_POINT), OrderTakeProfit(), Red); } } } else if (OrderType() == OP_SELL) { if (OrderOpenPrice() - Ask > TrailingStop * MarketInfo(OrderSymbol(), MODE_POINT)) { if ((OrderStopLoss() > Ask + TrailingStop * MarketInfo(OrderSymbol(), MODE_POINT)) || (OrderStopLoss() == 0)) { bool modify2=OrderModify(OrderTicket(), OrderOpenPrice(), Ask + TrailingStop * MarketInfo(OrderSymbol(), MODE_POINT), OrderTakeProfit(), Red); } } } } } } //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { if (trail) trail(); double MyPoint=Point; if(Digits==3 || Digits==5) MyPoint=Point*10; //---- if(IsNewCandle()) { trenddirection(); //find trend direction logic(); //apply indicator logic Lot_Volume(); //calc lotsize buyorsell(); //trade - buy or sell return(0); } return(0); } //+------------------------------------------------------------------+ //insuring its a new candle function //+------------------------------------------------------------------+ bool IsNewCandle() { static int BarsOnChart=0; if (Bars == BarsOnChart) return (false); BarsOnChart = Bars; return(true); } //+------------------------------------------------------------------+ //identifies the direction of the current trend //+------------------------------------------------------------------+ bool trenddirection() { //---- double rsi=iRSI(_Symbol,PERIOD_CURRENT,period,appPrice,1); bool orderOpended=false; if((rsi<OverBought && (Close[C0]>Open[C0])&&(Close[C0]>High[H1]) // Here is your open buy rule &&(Close[C0]-High[H1])>(delta/*_open_buy*/*Point))) if((rsi<OverBought && (Close[C0]>Open[C0])&&(Close[C0]>High[H2]) // Here is your open buy rule &&(Close[C0]-High[H2])>(delta/*_open_buy*/*Point))) { return(true); } if((rsi>OverSold && (Close[C0] <Open[C0])&& (Close[C0]<Low[L1]) // Here is your open Sell rule &&(Low[L1]-Close[C0])>(delta/*_open_sell*/*Point)) ) if((rsi>OverSold && (Close[C0] <Open[C0])&& (Close[C0]<Low[L2]) // Here is your open Sell rule &&(Low[L2]-Close[C0])>(delta/*_open_sell*/*Point))) { return(false); } return(0); } //+------------------------------------------------------------------+ //Applies Logic from Indicators ADX and RSI to determine if we can trade //+------------------------------------------------------------------+ int logic() { double adx,rsi; adx = iADX(Symbol(),0,adxperiod,PRICE_CLOSE,MODE_MAIN,0); rsi = iRSI(Symbol(),0,rsiperiod,PRICE_CLOSE,0); if(adx > adxthreshold) { if(rsi > rsilower && rsi < rsiupper) { return(1); } } return(0); } //+------------------------------------------------------------------+ //Opens Trades //+------------------------------------------------------------------+ int buyorsell() { bool trenddirectionx, logicx; int TicketNumber; trenddirectionx = trenddirection(); logicx = logic(); if(OrdersTotal() == 0) { if(trenddirectionx == 1 && logicx == 1 ) if (!IsTradeContextBusy() && IsTradeAllowed()) { //buy TicketNumber = OrderSend(Symbol(),OP_BUY,NR(Lot_Volume()),Ask,3,Ask-(StopLoss*pips),Ask+(TakeProfit*pips),NULL,MagicNumber,0,Green); if( TicketNumber > 0 ) { Print("Order placed # ", TicketNumber); } else { Print("Order Send failed, error # ", GetLastError() ); } } } if(OrdersTotal() == 0) { if(trenddirectionx == 0 && logicx == 1 ) //sell if (!IsTradeContextBusy() && IsTradeAllowed()) { TicketNumber = OrderSend(Symbol(),OP_SELL,NR(Lot_Volume()),Bid,3,Bid+(StopLoss*pips),Bid-(TakeProfit*pips),NULL,MagicNumber,0,Red); if( TicketNumber > 0 ) { Print("Order placed # ", TicketNumber); } else { Print("Order Send failed, error # ", GetLastError() ); } } } return(0); } //+------------------------------------------------------------------+ //Calculates Lot Size based on balance and factor //+------------------------------------------------------------------+ double NR(double thelot) { double maxlots=MarketInfo(Symbol(),MODE_MAXLOT), minilot=MarketInfo(Symbol(),MODE_MINLOT), lstep=MarketInfo(Symbol(),MODE_LOTSTEP); double lots=lstep*NormalizeDouble(thelot/lstep,0); lots=MathMax(MathMin(maxlots,lots),minilot); return (lots); } //+------------------------------------------------------------------+ double Lot_Volume() { lot=AccountBalance() * 0.01 /LotFactor ; return(lot); } //+------------------------------------------------------------------+
    lefeuvr3 a joint une image
    qpg-renko-version-2-11055
  • Agima

    Bonjour lefeuvr3 et merci pour cet EA.
    Je vais regarder et voir si je peux apporter des choses dessus.
    Je pense déjà modifier en premier lieu la gestion des lots pour que ça soit plus facile à gérer.
    As-tu trouvé des paramètres optimums déjà ou pas ?
  • lefeuvr3

    En fait les lots s'adaptent au capital du moment un peu comme cela
    Code
    double LotSize; //lotsize extern double LotFactor = 4.1; //lotsize factor
    /////////////////////////////////////////////////////////////////////////////
    Code
    //+------------------------------------------------------------------+ //Calculates Lot Size based on balance and factor //+------------------------------------------------------------------+ double Lot_Volume() { double lot; if (AccountBalance()>=50) lot=0.02; if (AccountBalance()>=75) lot=0.03; if (AccountBalance()>=100) lot=0.04; if (AccountBalance()>=125) lot=0.05; if (AccountBalance()>=150) lot=0.06; if (AccountBalance()>=175) lot=0.07; if (AccountBalance()>=200) lot=0.08; if (AccountBalance()>=225) lot=0.09; if (AccountBalance()>=250) lot=0.1; if (AccountBalance()>=275) lot=0.11; if (AccountBalance()>=300) lot=0.12; if (AccountBalance()>=325) lot=0.13; if (AccountBalance()>=350) lot=0.14; if (AccountBalance()>=375) lot=0.15; if (AccountBalance()>=400) lot=0.16; if (AccountBalance()>=425) lot=0.17; if (AccountBalance()>=450) lot=0.18; if (AccountBalance()>=475) lot=0.19; if (AccountBalance()>=500) lot=0.2; if (AccountBalance()>=525) lot=0.21; if (AccountBalance()>=550) lot=0.22; if (AccountBalance()>=575) lot=0.23; if (AccountBalance()>=600) lot=0.24; if (AccountBalance()>=625) lot=0.25; if (AccountBalance()>=650) lot=0.26; if (AccountBalance()>=675) lot=0.27; if (AccountBalance()>=700) lot=0.28; if (AccountBalance()>=725) lot=0.29; if (AccountBalance()>=750) lot=0.30; if (AccountBalance()>=800) lot=0.32; if (AccountBalance()>=825) lot=0.33; if (AccountBalance()>=850) lot=0.34; if (AccountBalance()>=875) lot=0.35; if (AccountBalance()>=900) lot=0.36; if (AccountBalance()>=925) lot=0.37; if (AccountBalance()>=950) lot=0.38; if (AccountBalance()>=975) lot=0.39; if (AccountBalance()>=1000) lot=0.4; if (AccountBalance()>=1025) lot=0.41; if (AccountBalance()>=1050) lot=0.42; if (AccountBalance()>=1075) lot=0.43; if (AccountBalance()>=1100) lot=0.44; if (AccountBalance()>=1125) lot=0.45; if (AccountBalance()>=1150) lot=0.46; if (AccountBalance()>=1175) lot=0.47; if (AccountBalance()>=1200) lot=0.48; if (AccountBalance()>=1225) lot=0.49; if (AccountBalance()>=1250) lot=0.5; if (AccountBalance()>=1275) lot=0.51; if (AccountBalance()>=1300) lot=0.52; if (AccountBalance()>=1325) lot=0.53; if (AccountBalance()>=1350) lot=0.54; if (AccountBalance()>=1350) lot=0.55; if (AccountBalance()>=1400) lot=0.56; if (AccountBalance()>=1450) lot=0.58; if (AccountBalance()>=1500) lot=0.6; if (AccountBalance()>=1550) lot=0.62; if (AccountBalance()>=1600) lot=0.64; if (AccountBalance()>=1650) lot=0.66; if (AccountBalance()>=1700) lot=0.68; if (AccountBalance()>=1750) lot=0.7; if (AccountBalance()>=1800) lot=0.72; if (AccountBalance()>=1850) lot=0.74; if (AccountBalance()>=1900) lot=0.76; if (AccountBalance()>=1950) lot=0.78; if (AccountBalance()>=2000) lot=0.8; if (AccountBalance()>=2025) lot=0.81; if (AccountBalance()>=2050) lot=0.82; if (AccountBalance()>=2075) lot=0.83; if (AccountBalance()>=2100) lot=0.84; if (AccountBalance()>=2150) lot=0.86; if (AccountBalance()>=2175) lot=0.87; if (AccountBalance()>=2200) lot=0.88; if (AccountBalance()>=2225) lot=0.89; if (AccountBalance()>=2250) lot=0.9; if (AccountBalance()>=2275) lot=0.91; if (AccountBalance()>=2300) lot=0.92; if (AccountBalance()>=2350) lot=0.94; if (AccountBalance()>=2400) lot=0.96; if (AccountBalance()>=2450) lot=0.98; if (AccountBalance()>=2500) lot=1.0; if (AccountBalance()>=2550) lot=1.02; if (AccountBalance()>=2600) lot=1.04; if (AccountBalance()>=2700) lot=1.08; if (AccountBalance()>=2800) lot=1.12; if (AccountBalance()>=2900) lot=0.16; if (AccountBalance()>=3000) lot=1.2; if (AccountBalance()>=3100) lot=1.24; if (AccountBalance()>=3200) lot=1.28; if (AccountBalance()>=3300) lot=1.32; if (AccountBalance()>=3400) lot=1.36; if (AccountBalance()>=3500) lot=1.4; if (AccountBalance()>=4000) lot=1.6; if (AccountBalance()>=4500) lot=1.8; if (AccountBalance()>=5000) lot=2.0; if (AccountBalance()>=5500) lot=2.2; if (AccountBalance()>=6000) lot=2.4; if (AccountBalance()>=6500) lot=2.6; if (AccountBalance()>=7000) lot=2.8; if (AccountBalance()>=7500) lot=3; if (AccountBalance()>=8000) lot=3.2; if (AccountBalance()>=8500) lot=3.4; if (AccountBalance()>=9000) lot=3.6; if (AccountBalance()>=9500) lot=3.8; if (AccountBalance()>=10000) lot=4.0; if (AccountBalance()>=10100) lot=4.04; if (AccountBalance()>=10200) lot=4.08; if (AccountBalance()>=10300) lot=4.12; if (AccountBalance()>=10400) lot=4.16; if (AccountBalance()>=10500) lot=4.2; if (AccountBalance()>=10600) lot=4.26; if (AccountBalance()>=10700) lot=4.3; if (AccountBalance()>=10800) lot=4.34; if (AccountBalance()>=10900) lot=4.38; if (AccountBalance()>=11000) lot=4.4; if (AccountBalance()>=12000) lot=4.8; if (AccountBalance()>=13000) lot=5.2; if (AccountBalance()>=14000) lot=5.6; if (AccountBalance()>=15000) lot=6.0; if (AccountBalance()>=20000) lot=8.0; if (AccountBalance()>=30000) lot=12; if (AccountBalance()>=40000) lot=16; if (AccountBalance()>=50000) lot=20; if (AccountBalance()>=60000) lot=24; if (AccountBalance()>=70000) lot=28; if (AccountBalance()>=80000) lot=32; if (AccountBalance()>=90000) lot=36; if (AccountBalance()>=100000) lot=40; if (AccountBalance()>=200000) lot=80; LotSize=lot/LotFactor; return(LotSize); }
  • lefeuvr3

    Depuis que je l'ai réalisé , je ne l'ai pas réévalue....il faudrait le backtester sur plusieurs années
    Bon week end
    Gerard