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