Merci d'ameliorer mon dernier EA maison
Je conseille un backtest tous les 15 jours en cas d'utilisation dans un premier temps
//+------------------------------------------------------------------+
//
// QPG MM OPEN CLOSE MTF ADX RSI.mq4
//
//+------------------------------------------------------------------+
// DO NOT DELETE THIS HEADER
// DELETING THIS HEADER IS COPYRIGHT INFRIGMENT
//
// Copyright ©2011, ForexEAdvisor.com
// ForexEAdvisor Strategy Builder version 0.2
// http://www.ForexEAdvisor.com
//
// THIS EA CODE HAS BEEN GENERATED USING FOREXEADVISOR STRATEGY BUILDER 0.2
// on: 6/28/2018 12:55:55 PM
// Disclaimer: This EA is provided to you "AS-IS", and ForexEAdvisor disclaims any warranty
// or liability obligations to you of any kind.
// UNDER NO CIRCUMSTANCES WILL FOREXEADVISOR BE LIABLE TO YOU, OR ANY OTHER PERSON OR ENTITY,
// FOR ANY LOSS OF USE, REVENUE OR PROFIT, LOST OR DAMAGED DATA, OR OTHER COMMERCIAL OR
// ECONOMIC LOSS OR FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, STATUTORY, PUNITIVE,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES WHATSOEVER RELATED TO YOUR USE OF THIS EA OR
// FOREXEADVISOR STRATEGY BUILDER
// Because software is inherently complex and may not be completely free of errors, you are
// advised to verify this EA. Before using this EA, please read the ForexEAdvisor Strategy Builder
// license for a complete understanding of ForexEAdvisor' disclaimers.
// USE THIS EA AT YOUR OWN RISK.
//
// Before adding this expert advisor to a chart, make sure there are NO
// open positions.
// DO NOT DELETE THIS HEADER
// DELETING THIS HEADER IS COPYRIGHT INFRIGMENT
//+------------------------------------------------------------------+
extern int MagicNumber=20180807;
extern double Lots =0.01;
extern double StopLoss=96;
extern double TakeProfit=104;
extern int TrailingStop=80;
extern int Slippage=3;
extern string Per="periode MM";
extern int PEROM1=34;
extern int PERCM1=1;
extern int PEROM15=10;
extern int PERCM15=24;
extern int PEROH1=4;
extern int PERCH1=3;
extern string mod="Mode MM";
//MODE_SMA=0
//Simple Moving Average
//Equal weight is given to each price over the calculation period. Bias: Smooth (anti-noise)
//MODE_EMA=1 Exponential Moving Average
// More weight is given to recent prices in attempt to reduce lag. Bias: Speed (anti-lag)
//MODE_SMMA=2
// Smoothed Moving Average
// Similar to a SMA; however, rather than subtracting the oldest value, the previous smoothed average value is subtracted. Bias: Smooth (anti-noise)
//MODE_LWMA=3
//Linear Weighted Moving Average
//Designed to put more weight on recent data and less weight on past data. Bias: Speed (anti-lag)
extern int MODEMA=1;
extern int adxperiod =26;
extern int adxthreshold =22;
extern int shift0pen0 =1;
extern int shift0pen1=0;
extern int shiftClose0=0;
extern int shiftClose1=1;
double Timeframe=0;
//+------------------------------------------------------------------+
// 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;
// Here is your open buy rule
if(iMA(NULL,PERIOD_M1,PEROM1,0,MODEMA,PRICE_OPEN,shift0pen0)>iMA(NULL,PERIOD_M1,PERCM1,0,MODEMA,PRICE_CLOSE,shiftClose0)&&iMA(NULL,PERIOD_M1,PEROM1,1,MODEMA,PRICE_OPEN,shift0pen1)<iMA(NULL,PERIOD_M1,PERCM1,1,MODEMA,PRICE_CLOSE,shiftClose1)&&
iMA(NULL,PERIOD_M15,PEROM15,0,MODEMA,PRICE_OPEN,shift0pen0)>iMA(NULL,PERIOD_M15,PERCM15,0,MODEMA,PRICE_CLOSE,shiftClose0)&&iMA(NULL,PERIOD_M15,PEROM15,1,MODEMA,PRICE_OPEN,shift0pen1)<iMA(NULL,PERIOD_M15,PERCM15,1,MODEMA,PRICE_CLOSE,shiftClose1)&&
iMA(NULL,PERIOD_H1,PEROH1,0,MODEMA,PRICE_OPEN,shift0pen0)>iMA(NULL,PERIOD_H1,PERCH1,0,MODEMA,PRICE_CLOSE,shiftClose0)&&iMA(NULL,PERIOD_H1,PEROH1,1,MODEMA,PRICE_OPEN,shift0pen1)<iMA(NULL,PERIOD_H1,PERCH1,1,MODEMA,PRICE_CLOSE,shiftClose1) // Here is your open buy rule
&&(iADX(Symbol(),Timeframe,adxperiod,PRICE_CLOSE,MODE_MAIN,0)>adxthreshold )
)
{
result=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,0,0,"EA Generator www.ForexEAdvisor.com",MagicNumber,0,Blue);
if(result>0)
{
TheStopLoss=0;
TheTakeProfit=0;
if(TakeProfit>0) TheTakeProfit=Ask+TakeProfit*MyPoint;
if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint;
if(OrderSelect(result,SELECT_BY_TICKET)==true)
bool modif1= OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green);
}
return(0);
}
// Here is your open Sell rule
if(iMA(NULL,PERIOD_M1,PEROM1,0,MODEMA,PRICE_OPEN,shift0pen0)<iMA(NULL,PERIOD_M1,PERCM1,0,MODEMA,PRICE_CLOSE,shiftClose0)&&iMA(NULL,PERIOD_M1,PEROM1,1,MODEMA,PRICE_OPEN,shift0pen1)>iMA(NULL,PERIOD_M1,PERCM1,1,MODEMA,PRICE_CLOSE,shiftClose1)&& // Here is your open Sell rule
iMA(NULL,PERIOD_M15,PEROM15,0,MODEMA,PRICE_OPEN,shift0pen0)<iMA(NULL,PERIOD_M15,PERCM15,0,MODEMA,PRICE_CLOSE,shiftClose0)&&iMA(NULL,PERIOD_M15,PEROM15,1,MODEMA,PRICE_OPEN,shift0pen1)>iMA(NULL,PERIOD_M15,PERCM15,1,MODEMA,PRICE_CLOSE,shiftClose1)
&&iMA(NULL,PERIOD_H1,PEROH1,0,MODEMA,PRICE_OPEN,shift0pen0)<iMA(NULL,PERIOD_H1,PERCH1,0,MODEMA,PRICE_CLOSE,shiftClose0)&&iMA(NULL,PERIOD_H1,PEROH1,1,MODEMA,PRICE_OPEN,shift0pen1)>iMA(NULL,PERIOD_H1,PERCH1,1,MODEMA,PRICE_CLOSE,shiftClose1)
&&(iADX(Symbol(),Timeframe,adxperiod,PRICE_CLOSE,MODE_MAIN,0)>adxthreshold )
)
{
result=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,0,0,"EA Generator www.ForexEAdvisor.com",MagicNumber,0,Red);
if(result>0)
{
TheStopLoss=0;
TheTakeProfit=0;
if(TakeProfit>0) TheTakeProfit=Bid-TakeProfit*MyPoint;
if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint;
if (OrderSelect(result,SELECT_BY_TICKET)==true)
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)==true)
if(OrderType()<=OP_SELL &&
OrderSymbol()==Symbol() &&
OrderMagicNumber()==MagicNumber
)
{
if(OrderType()==OP_BUY)
{
if(iMA(NULL,PERIOD_M1,PEROM1,0,MODEMA,PRICE_OPEN,shift0pen0)<iMA(NULL,PERIOD_M1,PERCM1,0,MODEMA,PRICE_CLOSE,shiftClose0)&&iMA(NULL,PERIOD_M1,PEROM1,1,MODEMA,PRICE_OPEN,shift0pen1)>iMA(NULL,PERIOD_M1,PERCM1,1,MODEMA,PRICE_CLOSE,shiftClose1)&& //here is your close buy rule
iMA(NULL,PERIOD_M15,PEROM15,0,MODEMA,PRICE_OPEN,shift0pen0)<iMA(NULL,PERIOD_M15,PERCM15,0,MODEMA,PRICE_CLOSE,shiftClose0)&&iMA(NULL,PERIOD_M15,PEROM15,1,MODEMA,PRICE_OPEN,shift0pen1)>iMA(NULL,PERIOD_M15,PERCM15,1,MODEMA,PRICE_CLOSE,shiftClose1)
&&iMA(NULL,PERIOD_H1,PEROH1,0,MODEMA,PRICE_OPEN,shift0pen0)<iMA(NULL,PERIOD_H1,PERCH1,0,MODEMA,PRICE_CLOSE,shiftClose0)&&iMA(NULL,PERIOD_H1,PEROH1,1,MODEMA,PRICE_OPEN,shift0pen1)>iMA(NULL,PERIOD_H1,PERCH1,1,MODEMA,PRICE_CLOSE,shiftClose1) //here is your close buy rule
&&(iADX(Symbol(),Timeframe,adxperiod,PRICE_CLOSE,MODE_MAIN,0)>adxthreshold )
)
{
bool modif5= OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),Slippage,Red);
}
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(iMA(NULL,PERIOD_M1,PEROM1,0,MODEMA,PRICE_OPEN,shift0pen0)>iMA(NULL,PERIOD_M1,PERCM1,0,MODEMA,PRICE_CLOSE,shiftClose0)&&iMA(NULL,PERIOD_M1,PEROM1,1,MODEMA,PRICE_OPEN,shift0pen1)<iMA(NULL,PERIOD_M1,PERCM1,1,MODEMA,PRICE_CLOSE,shiftClose1)&& // here is your close sell rule
iMA(NULL,PERIOD_M15,PEROM15,0,MODEMA,PRICE_OPEN,shift0pen0)>iMA(NULL,PERIOD_M15,PERCM15,0,MODEMA,PRICE_CLOSE,shiftClose0)&&iMA(NULL,PERIOD_M15,PEROM15,1,MODEMA,PRICE_OPEN,shift0pen1)<iMA(NULL,PERIOD_M15,PERCM15,1,MODEMA,PRICE_CLOSE,shiftClose1)
&&iMA(NULL,PERIOD_H1,PEROH1,0,MODEMA,PRICE_OPEN,shift0pen0)>iMA(NULL,PERIOD_H1,PERCH1,0,MODEMA,PRICE_CLOSE,shiftClose0)&&iMA(NULL,PERIOD_H1,PEROH1,1,MODEMA,PRICE_OPEN,shift0pen1)<iMA(NULL,PERIOD_H1,PERCH1,1,MODEMA,PRICE_CLOSE,shiftClose1) // here is your close sell rule
&&(iADX(Symbol(),Timeframe,adxperiod,PRICE_CLOSE,MODE_MAIN,0)>adxthreshold )
)
{
bool modif6= OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),Slippage,Red);
}
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)==true)
if (OrderMagicNumber()==MagicNumber) result++;
}
return (result);
}
Je conseille un backtest tous les 15 jours en cas d'utilisation dans un premier temps
//+------------------------------------------------------------------+
//
// QPG MM OPEN CLOSE MTF ADX RSI.mq4
//
//+------------------------------------------------------------------+
// DO NOT DELETE THIS HEADER
// DELETING THIS HEADER IS COPYRIGHT INFRIGMENT
//
// Copyright ©2011, ForexEAdvisor.com
// ForexEAdvisor Strategy Builder version 0.2
// http://www.ForexEAdvisor.com
//
// THIS EA CODE HAS BEEN GENERATED USING FOREXEADVISOR STRATEGY BUILDER 0.2
// on: 6/28/2018 12:55:55 PM
// Disclaimer: This EA is provided to you "AS-IS", and ForexEAdvisor disclaims any warranty
// or liability obligations to you of any kind.
// UNDER NO CIRCUMSTANCES WILL FOREXEADVISOR BE LIABLE TO YOU, OR ANY OTHER PERSON OR ENTITY,
// FOR ANY LOSS OF USE, REVENUE OR PROFIT, LOST OR DAMAGED DATA, OR OTHER COMMERCIAL OR
// ECONOMIC LOSS OR FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, STATUTORY, PUNITIVE,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES WHATSOEVER RELATED TO YOUR USE OF THIS EA OR
// FOREXEADVISOR STRATEGY BUILDER
// Because software is inherently complex and may not be completely free of errors, you are
// advised to verify this EA. Before using this EA, please read the ForexEAdvisor Strategy Builder
// license for a complete understanding of ForexEAdvisor' disclaimers.
// USE THIS EA AT YOUR OWN RISK.
//
// Before adding this expert advisor to a chart, make sure there are NO
// open positions.
// DO NOT DELETE THIS HEADER
// DELETING THIS HEADER IS COPYRIGHT INFRIGMENT
//+------------------------------------------------------------------+
extern int MagicNumber=20180807;
extern double Lots =0.01;
extern double StopLoss=96;
extern double TakeProfit=104;
extern int TrailingStop=80;
extern int Slippage=3;
extern string Per="periode MM";
extern int PEROM1=34;
extern int PERCM1=1;
extern int PEROM15=10;
extern int PERCM15=24;
extern int PEROH1=4;
extern int PERCH1=3;
extern string mod="Mode MM";
//MODE_SMA=0
//Simple Moving Average
//Equal weight is given to each price over the calculation period. Bias: Smooth (anti-noise)
//MODE_EMA=1 Exponential Moving Average
// More weight is given to recent prices in attempt to reduce lag. Bias: Speed (anti-lag)
//MODE_SMMA=2
// Smoothed Moving Average
// Similar to a SMA; however, rather than subtracting the oldest value, the previous smoothed average value is subtracted. Bias: Smooth (anti-noise)
//MODE_LWMA=3
//Linear Weighted Moving Average
//Designed to put more weight on recent data and less weight on past data. Bias: Speed (anti-lag)
extern int MODEMA=1;
extern int adxperiod =26;
extern int adxthreshold =22;
extern int shift0pen0 =1;
extern int shift0pen1=0;
extern int shiftClose0=0;
extern int shiftClose1=1;
double Timeframe=0;
//+------------------------------------------------------------------+
// 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;
// Here is your open buy rule
if(iMA(NULL,PERIOD_M1,PEROM1,0,MODEMA,PRICE_OPEN,shift0pen0)>iMA(NULL,PERIOD_M1,PERCM1,0,MODEMA,PRICE_CLOSE,shiftClose0)&&iMA(NULL,PERIOD_M1,PEROM1,1,MODEMA,PRICE_OPEN,shift0pen1)<iMA(NULL,PERIOD_M1,PERCM1,1,MODEMA,PRICE_CLOSE,shiftClose1)&&
iMA(NULL,PERIOD_M15,PEROM15,0,MODEMA,PRICE_OPEN,shift0pen0)>iMA(NULL,PERIOD_M15,PERCM15,0,MODEMA,PRICE_CLOSE,shiftClose0)&&iMA(NULL,PERIOD_M15,PEROM15,1,MODEMA,PRICE_OPEN,shift0pen1)<iMA(NULL,PERIOD_M15,PERCM15,1,MODEMA,PRICE_CLOSE,shiftClose1)&&
iMA(NULL,PERIOD_H1,PEROH1,0,MODEMA,PRICE_OPEN,shift0pen0)>iMA(NULL,PERIOD_H1,PERCH1,0,MODEMA,PRICE_CLOSE,shiftClose0)&&iMA(NULL,PERIOD_H1,PEROH1,1,MODEMA,PRICE_OPEN,shift0pen1)<iMA(NULL,PERIOD_H1,PERCH1,1,MODEMA,PRICE_CLOSE,shiftClose1) // Here is your open buy rule
&&(iADX(Symbol(),Timeframe,adxperiod,PRICE_CLOSE,MODE_MAIN,0)>adxthreshold )
)
{
result=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,0,0,"EA Generator www.ForexEAdvisor.com",MagicNumber,0,Blue);
if(result>0)
{
TheStopLoss=0;
TheTakeProfit=0;
if(TakeProfit>0) TheTakeProfit=Ask+TakeProfit*MyPoint;
if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint;
if(OrderSelect(result,SELECT_BY_TICKET)==true)
bool modif1= OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green);
}
return(0);
}
// Here is your open Sell rule
if(iMA(NULL,PERIOD_M1,PEROM1,0,MODEMA,PRICE_OPEN,shift0pen0)<iMA(NULL,PERIOD_M1,PERCM1,0,MODEMA,PRICE_CLOSE,shiftClose0)&&iMA(NULL,PERIOD_M1,PEROM1,1,MODEMA,PRICE_OPEN,shift0pen1)>iMA(NULL,PERIOD_M1,PERCM1,1,MODEMA,PRICE_CLOSE,shiftClose1)&& // Here is your open Sell rule
iMA(NULL,PERIOD_M15,PEROM15,0,MODEMA,PRICE_OPEN,shift0pen0)<iMA(NULL,PERIOD_M15,PERCM15,0,MODEMA,PRICE_CLOSE,shiftClose0)&&iMA(NULL,PERIOD_M15,PEROM15,1,MODEMA,PRICE_OPEN,shift0pen1)>iMA(NULL,PERIOD_M15,PERCM15,1,MODEMA,PRICE_CLOSE,shiftClose1)
&&iMA(NULL,PERIOD_H1,PEROH1,0,MODEMA,PRICE_OPEN,shift0pen0)<iMA(NULL,PERIOD_H1,PERCH1,0,MODEMA,PRICE_CLOSE,shiftClose0)&&iMA(NULL,PERIOD_H1,PEROH1,1,MODEMA,PRICE_OPEN,shift0pen1)>iMA(NULL,PERIOD_H1,PERCH1,1,MODEMA,PRICE_CLOSE,shiftClose1)
&&(iADX(Symbol(),Timeframe,adxperiod,PRICE_CLOSE,MODE_MAIN,0)>adxthreshold )
)
{
result=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,0,0,"EA Generator www.ForexEAdvisor.com",MagicNumber,0,Red);
if(result>0)
{
TheStopLoss=0;
TheTakeProfit=0;
if(TakeProfit>0) TheTakeProfit=Bid-TakeProfit*MyPoint;
if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint;
if (OrderSelect(result,SELECT_BY_TICKET)==true)
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)==true)
if(OrderType()<=OP_SELL &&
OrderSymbol()==Symbol() &&
OrderMagicNumber()==MagicNumber
)
{
if(OrderType()==OP_BUY)
{
if(iMA(NULL,PERIOD_M1,PEROM1,0,MODEMA,PRICE_OPEN,shift0pen0)<iMA(NULL,PERIOD_M1,PERCM1,0,MODEMA,PRICE_CLOSE,shiftClose0)&&iMA(NULL,PERIOD_M1,PEROM1,1,MODEMA,PRICE_OPEN,shift0pen1)>iMA(NULL,PERIOD_M1,PERCM1,1,MODEMA,PRICE_CLOSE,shiftClose1)&& //here is your close buy rule
iMA(NULL,PERIOD_M15,PEROM15,0,MODEMA,PRICE_OPEN,shift0pen0)<iMA(NULL,PERIOD_M15,PERCM15,0,MODEMA,PRICE_CLOSE,shiftClose0)&&iMA(NULL,PERIOD_M15,PEROM15,1,MODEMA,PRICE_OPEN,shift0pen1)>iMA(NULL,PERIOD_M15,PERCM15,1,MODEMA,PRICE_CLOSE,shiftClose1)
&&iMA(NULL,PERIOD_H1,PEROH1,0,MODEMA,PRICE_OPEN,shift0pen0)<iMA(NULL,PERIOD_H1,PERCH1,0,MODEMA,PRICE_CLOSE,shiftClose0)&&iMA(NULL,PERIOD_H1,PEROH1,1,MODEMA,PRICE_OPEN,shift0pen1)>iMA(NULL,PERIOD_H1,PERCH1,1,MODEMA,PRICE_CLOSE,shiftClose1) //here is your close buy rule
&&(iADX(Symbol(),Timeframe,adxperiod,PRICE_CLOSE,MODE_MAIN,0)>adxthreshold )
)
{
bool modif5= OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),Slippage,Red);
}
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(iMA(NULL,PERIOD_M1,PEROM1,0,MODEMA,PRICE_OPEN,shift0pen0)>iMA(NULL,PERIOD_M1,PERCM1,0,MODEMA,PRICE_CLOSE,shiftClose0)&&iMA(NULL,PERIOD_M1,PEROM1,1,MODEMA,PRICE_OPEN,shift0pen1)<iMA(NULL,PERIOD_M1,PERCM1,1,MODEMA,PRICE_CLOSE,shiftClose1)&& // here is your close sell rule
iMA(NULL,PERIOD_M15,PEROM15,0,MODEMA,PRICE_OPEN,shift0pen0)>iMA(NULL,PERIOD_M15,PERCM15,0,MODEMA,PRICE_CLOSE,shiftClose0)&&iMA(NULL,PERIOD_M15,PEROM15,1,MODEMA,PRICE_OPEN,shift0pen1)<iMA(NULL,PERIOD_M15,PERCM15,1,MODEMA,PRICE_CLOSE,shiftClose1)
&&iMA(NULL,PERIOD_H1,PEROH1,0,MODEMA,PRICE_OPEN,shift0pen0)>iMA(NULL,PERIOD_H1,PERCH1,0,MODEMA,PRICE_CLOSE,shiftClose0)&&iMA(NULL,PERIOD_H1,PEROH1,1,MODEMA,PRICE_OPEN,shift0pen1)<iMA(NULL,PERIOD_H1,PERCH1,1,MODEMA,PRICE_CLOSE,shiftClose1) // here is your close sell rule
&&(iADX(Symbol(),Timeframe,adxperiod,PRICE_CLOSE,MODE_MAIN,0)>adxthreshold )
)
{
bool modif6= OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),Slippage,Red);
}
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)==true)
if (OrderMagicNumber()==MagicNumber) result++;
}
return (result);
}