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 LOTSCALP LOTS AUTOAJUSTES

  • lefeuvr3

    Code
    //+------------------------------------------------------------------+ //| QPG LOTSCALP LOTS AUTOAJUSTES | //+---------------------------------------------------------------------------+ double LotSize; //lotsize extern double LotFactor = 4.1; //lotsize factor // extern int StopLoss=1555; //stop loss extern int TakeProfit=94; //take profit extern int MagicNumber=20180807; //magic double pips = 0.00001; //leave as default for 5 digit brokers extern int adxthreshold = 27; //adx threshold - must be greater than this to trade extern int adxperiod = 14; //adx period // extern int rsiperiod = 14; //rsi period extern int rsiupper = 65; //rsi upper bound, wont buy above this value extern int rsilower = 35; //rsi lower bound, wont sell below this value // extern int t1=50; extern int t2=36; extern int delta_L=30; extern int delta_S=34; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { // // 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() { //---- if (((Open[t2]-Open[t1])>delta_L*Point)&& Volume[1]> Volume[0]) { return(true); } if (((Open[t1]-Open[t2])>delta_S*Point)&& Volume[1]> Volume[0]) { 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 == true && logicx == 1 ) { //buy TicketNumber = OrderSend(Symbol(),OP_BUY,LotSize,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 == false && logicx == 1 ) //sell { TicketNumber = OrderSend(Symbol(),OP_SELL,LotSize,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 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()>=550) lot=0.24; if (AccountBalance()>=600) lot=0.26; if (AccountBalance()>=650) lot=0.28; if (AccountBalance()>=700) lot=0.3; if (AccountBalance()>=750) lot=0.32; if (AccountBalance()>=800) lot=0.34; if (AccountBalance()>=850) lot=0.36; if (AccountBalance()>=900) lot=0.38; if (AccountBalance()>=1000) lot=0.4; if (AccountBalance()>=1500) lot=0.6; if (AccountBalance()>=2000) lot=0.8; if (AccountBalance()>=2500) lot=1.0; if (AccountBalance()>=3000) lot=1.2; 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()>=7000) lot=2.8; if (AccountBalance()>=8000) lot=3.2; if (AccountBalance()>=9000) lot=3.6; if (AccountBalance()>=10000) lot=4.0; 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 a joint une image
    qpg-lotscalp-lots-autoajustes-10931
  • lefeuvr3

    Je viens de le retester apres avoir apporté quelques petites modifications dans le programme….sympa ...non ?
    lefeuvr3 a joint une image
    qpg-lotscalp-lots-autoajustes-10939
  • lefeuvr3

    voici le programme ….merci de le corriger et de l'ameliorer encore

    Code
    //+------------------------------------------------------------------+ //| QPG LOTSCALP LOTS AUTOAJUSTES | //+---------------------------------------------------------------------------+ double LotSize; //lotsize extern double LotFactor = 4.1; //lotsize factor extern bool trail = true; extern double TrailingStop = 80; extern int StopLoss=1680; //stop loss extern int TakeProfit=90; //take profit extern int MagicNumber=20180807; //magic extern int Slippage=3; double pips = 0.00001; //leave as default for 5 digit brokers extern int adxthreshold = 27; //adx threshold - must be greater than this to trade extern int adxperiod = 14; //adx period // extern int rsiperiod = 14; //rsi period extern int rsiupper = 65; //rsi upper bound, wont buy above this value extern int rsilower = 35; //rsi lower bound, wont sell below this value // extern int t1=0; extern int t2=4; extern int delta=25; 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() { //---- if (((Open[t2]-Open[t1])>delta*Point)&& Volume[1]> Volume[0]) { return(true); } if (((Open[t1]-Open[t2])>delta*Point)&& Volume[1]> Volume[0]) { 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 == true && logicx == 1 ) { //buy TicketNumber = OrderSend(Symbol(),OP_BUY,LotSize,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 == false && logicx == 1 ) //sell { TicketNumber = OrderSend(Symbol(),OP_SELL,LotSize,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 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()>=550) lot=0.24; if (AccountBalance()>=600) lot=0.26; if (AccountBalance()>=650) lot=0.28; if (AccountBalance()>=700) lot=0.3; if (AccountBalance()>=750) lot=0.32; if (AccountBalance()>=800) lot=0.34; if (AccountBalance()>=850) lot=0.36; if (AccountBalance()>=900) lot=0.38; if (AccountBalance()>=1000) lot=0.4; if (AccountBalance()>=1500) lot=0.6; if (AccountBalance()>=2000) lot=0.8; if (AccountBalance()>=2500) lot=1.0; if (AccountBalance()>=3000) lot=1.2; 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()>=7000) lot=2.8; if (AccountBalance()>=8000) lot=3.2; if (AccountBalance()>=9000) lot=3.6; if (AccountBalance()>=10000) lot=4.0; 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); }
  • Lebenet

    Bonjour,
    J'ai réécris cet algo en LUA pour le faire tourner sur mon optimiseur.
    En gros, les résultats sont les mêmes et la plage de paramètres qui donne l'algo rentable est très large.

    Par contre, j'ai noté un souci.
    Cet algo créé énormément d'ordres et on se retrouve très vite en appel de marge si le capital de départ est trop faible.
    En effet, depuis la passage de la réglementation au 1 août à un effet de levier 1/30 au maximum (au lieu de 1/300 ou 1/400), cela limite énormément le nombre d'ordres en parallèle et la marge requise (de l'ordre de 33€ par ordre de 1 micro-lot).

    Avez-vous observé la même chose ?
  • lefeuvr3

    Je vais me repencher dessus pour voir cela de plus près ...
  • lefeuvr3

    Je viens de refaire une nouvelle version qui permet de plus facilement ajuster la taille des lots grace au "Lot Factor"
    Je ne modifie pas les autres paramètres pour voir comment il va se comporter à l'avenir.

    Code
    //+------------------------------------------------------------------+ //| QPG LOTSCALP LOTS AUTOAJUSTES // VERSION 2.mq4 // EURUSD 1MN QPG // https://www.mql5.com //+------------------------------------------------------------------+ #property copyright "QPG" #property link "https://www.mql5.com" #property version "1.00" //#property strict //+------------------------------------------------------------------+ double LotSize; //lotsize extern string mn="LOT FACTOR LOT SIZE"; extern double LotFactor = 140; //lotsize factor double lot; extern bool trail = true; extern double TrailingStop =80; extern int StopLoss=1680; //stop loss extern int TakeProfit=90; //take profit extern int MagicNumber=20180807; //magic extern int Slippage=3; double pips = 0.00001; //leave as default for 5 digit brokers extern int adxthreshold = 27; //adx threshold - must be greater than this to trade extern int adxperiod = 14; //adx period // extern int rsiperiod = 14; //rsi period extern int rsiupper = 65; //rsi upper bound, wont buy above this value extern int rsilower = 35; //rsi lower bound, wont sell below this value // extern int t1=3; extern int t2=1; extern int delta=30; 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() { //---- if (((Open[t2]-Open[t1])>delta*Point)&& Volume[1]> Volume[0]) { return(true); } if (((Open[t1]-Open[t2])>delta*Point)&& Volume[1]> Volume[0]) { 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 == true && logicx == 1 ) { //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 == false && logicx == 1 ) //sell { 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); } //+------------------------------------------------------------------+
    Modifié le 2018-09-07 08:05:34 par lefeuvr3
  • lefeuvr3

    voici le resultat avec les paramètres de ce dernier programme ,ajusté pour que le DD reste en dessous de 30
    lefeuvr3 a joint une image
    qpg-lotscalp-lots-autoajustes-10962
  • lefeuvr3

    La stratégie de cet EA me donne l'idée d'en faire un dans le même esprit mais si possible ...modestement ...plus performant avec plus de garde-fous.
    Je vais m'y atteler de ce pas .
  • lefeuvr3

    version 3 pour EURUSD UT 1 HEURE
    Code
    //+------------------------------------------------------------------+ //| LotScalp.mq4 v3 EurUsd 1 H | //+------------------------------------------------------------------+ extern int TakeProfit_L = 160; // Take Profit in points extern int StopLoss_L = 1400; // Stop Loss in points extern int TakeProfit_S = 200; // Take Profit in points extern int StopLoss_S = 930; // Stop Loss in points extern double coeff=53; //-------------------------------------------------+essai extern int volume1=1; extern int volume0=0; //--------------------------------------------------+essai double TP = MarketInfo(Symbol(),MODE_STOPLEVEL)*Point; //"EURUSD" or other currency pairs on chart = Symbol() double SL_L = (TP*StopLoss_L)*Point; double SL_S = (TP*StopLoss_S)*Point; //---------------------------------------------------+essai extern bool trail = True; extern double TrailingStop = 170; extern int TradeTime =7; // Time to enter the market extern int t1buy=16; extern int t2buy=14; extern int t1sell=4; extern int t2sell=13; extern int delta_L=1; extern int delta_S=7; extern double lot = 0.01; // Lot size extern int Orders=1; // maximal number of positions opened at a time } extern int MaxOpenTime=101; extern double BigLotSize = 1; // By how much lot size is multiplicated in Big lot... No more 3 extern bool AutoLot=true; extern bool cantrade = true; extern int adxperiod= 17; extern int adxthreshold=24; extern int rsiperiod=14; extern int rsilower =30; extern int rsiupper =70; int ticket,total,cnt; double closeprice; double tmp; int LotSize() // The function opens a short position with lot size=volume coeff diviseur 273.16 environs { lot= AccountBalance() * 0.01 / coeff; return(0); } int globPos() // the function calculates big lot size { int v1=GlobalVariableGet("globalPosic"); GlobalVariableSet("globalPosic",v1+1); return(0); } int OpenLong(double volume=0.1) // the function opens a long position with lot size=volume { int slippage=10; string comment="20/200 expert v2 (Long)"; color arrow_color=Red; int magic=0; if (GlobalVariableGet("globalBalans")>AccountBalance()) volume=lot*BigLotSize; // if (GlobalVariableGet("globalBalans")>AccountBalance()) if (AutoLot) LotSize(); ticket=OrderSend(Symbol(),OP_BUY,volume,Ask,slippage,Ask-StopLoss_L*Point, Ask+TakeProfit_L*Point,comment,magic,0,arrow_color); GlobalVariableSet("globalBalans",AccountBalance()); globPos(); // if (GlobalVariableGet("globalPosic")>25) // { GlobalVariableSet("globalPosic",0); if (AutoLot) LotSize(); // } if(ticket>0) { if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) { return(0); } else { Print("OpenLong(),OrderSelect() - returned an error : ",GetLastError()); return(-1); } } else { Print("Error opening Buy order : ",GetLastError()); return(-1); } } int OpenShort(double volume=0.1) // The function opens a short position with lot size=volume { int slippage=10; string comment="Gabriel Eze Junior >>>SHORT"; color arrow_color=Red; int magic=0; if (GlobalVariableGet("globalBalans")>AccountBalance()) volume=lot*BigLotSize; ticket=OrderSend(Symbol(),OP_SELL,volume,Bid,slippage,Bid+StopLoss_S*Point, Bid-TakeProfit_S*Point,comment,magic,0,arrow_color); GlobalVariableSet("globalBalans",AccountBalance()); globPos(); // if (GlobalVariableGet("globalPosic")>25) // { GlobalVariableSet("globalPosic",0); if (AutoLot) LotSize(); // } if(ticket>0) { if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) { return(0); } else { Print("OpenShort(),OrderSelect() - returned an error : ",GetLastError()); return(-1); } } else { Print("Error opening Sell order : ",GetLastError()); return(-1); } } void trail() { for (int i = 0; i < OrdersTotal(); i++) { if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)==true) 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); } } } } } } int init() { // control of a variable before using if (AutoLot) LotSize(); if(!GlobalVariableCheck("globalBalans")) GlobalVariableSet("globalBalans",AccountBalance()); if(!GlobalVariableCheck("globalPosic")) GlobalVariableSet("globalPosic",0); return(0); } int deinit() { return(0); } int start() { double booster = Volume[volume1]> Volume[volume0] &&iADX(Symbol(),0,adxperiod,PRICE_CLOSE,MODE_MAIN,0)> adxthreshold &&iRSI(Symbol(),0,rsiperiod,PRICE_CLOSE,0)>rsilower && iRSI(Symbol(),0,rsiperiod,PRICE_CLOSE,0)<rsiupper ; if (trail) trail(); if((TimeHour(TimeCurrent())>TradeTime)) cantrade=true; // check if there are open orders ... total=OrdersTotal(); if(total<Orders) { // ... if no open orders, go further // check if it's time for trade if((TimeHour(TimeCurrent())==TradeTime)&&(cantrade)) { // ... if it is if (((Open[t1sell]-Open[t2sell])>delta_S*Point) &&(booster)) //if it is { //condition is fulfilled, enter a short position: // check if there is free money for opening a short position if(AccountFreeMarginCheck(Symbol(),OP_SELL,lot)<=0 || GetLastError()==134) { Print("Not enough money"); return(0); } OpenShort(lot); cantrade=false; //prohibit repeated trade until the next bar return(0); } if (((Open[t2buy]-Open[t1buy])>delta_L*Point) &&(booster)) //if the price increased by delta { // condition is fulfilled, enter a long position // check if there is free money if(AccountFreeMarginCheck(Symbol(),OP_BUY,lot)<=0 || GetLastError()==134) { Print("Not enough money"); return(0); } OpenLong(lot); cantrade=false; return(0); } } } // block of a trade validity time checking, if MaxOpenTime=0, do not check. if(MaxOpenTime>0) { for(cnt=0;cnt<total;cnt++) { if (OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES)) { tmp = (TimeCurrent()-OrderOpenTime())/3600.0; if (((NormalizeDouble(tmp,8)-MaxOpenTime)>=0)) { RefreshRates(); if (OrderType()==OP_BUY) closeprice=Bid; else closeprice=Ask; if (OrderClose(OrderTicket(),OrderLots(),closeprice,10,Green)) { Print("Forced closing of the trade - ¹",OrderTicket()); OrderPrint(); } else Print("OrderClose() in block of a trade validity time checking returned an error - ",GetLastError()); } } else Print("OrderSelect() in block of a trade validity time checking returned an error - ",GetLastError()); } } return(0); }
    lefeuvr3 a joint une image
    qpg-lotscalp-lots-autoajustes-11019
  • lefeuvr3

    Nouveau backtest amelioration de la performance et de la securisation
    lefeuvr3 a joint une image
    qpg-lotscalp-lots-autoajustes-11042