soit celui la(car il est filtré) je pense qu'il evitera les moments sans tendance
//+------------------------------------------------------------------+
//| Avg Daily Range.mq4 |
//| Copyright © 2005, tageiger aka
[email protected] |
//|
http://www.metatrader.org |
//+------------------------------------------------------------------+
#property copyright "Tous droits réservés, Nicolas Tuffier (2011)"
#property link "
http://www.furyweb.fr/forex/"
#import "stdlib.ex4"
string ErrorDescription(int error_code);
#import
#include <stderror.mqh>
#define NAME "EMA MTF CROSS"
#define VERSION "1.0"
//#property indicator_chart_window
extern double lotSize=0.2;
extern int StopLoss=300;
extern int FirstEven=150;
extern int BreakEven=300;
extern int TakeProfit=500;
extern string EMAValues="Settings for the 2 EMA";
//extern int MATF1 = 0;
extern int MAperiod1 = 2;
extern int MAperiod2 = 4;
//extern int MATF2 = 240;
extern int MAperiod3 = 8;
extern int MAperiod4 = 16;
extern bool Alerts = true;
extern string ADXValues="ADX & CCI Filter (0 for nothing)";
extern int CCiPeriod=50;
extern int CCITimeFrame=0;
extern int CCIbuyLevel=20;
extern int CCIsellLevel=-20;
extern string Next="--------------------------------------------------------------------";
extern int ADXFilterLimit=20;
extern int AdxPeriod=14;
extern int AdxTimeFrame=0;
extern string InfosValues="Label Settings";
extern bool ShowOtherInfos = true;
extern bool ShowSpreadAndDailyRange = true;
extern int DailyAtrPeriod=40;
extern int LabelXpos=10;
extern int LabelYpos=15;
extern string Capture="Screeshots (Stocked in ..\experts\files)";
extern bool TakeScreenShot = true;
extern int size_x = 1280;
extern int size_y = 720;
int ticket;
int a = 0;
int i;
int magicNumber = 152341;
double savedVolume;
double adx, TPPoints, SLPoints;
string symbolpair, time;
bool Buy,Sell;
double MA1, MA2, MA3, MA4;
string MAvalue, MAvalue2;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int init()
{
// TPPoints = TakeProfit * Point * MathPow(10, Digits % 2);
//SLPoints = StopLoss * Point * MathPow(10, Digits % 2);
return(0);}
bool newBarFormed() {
bool ret=Volume[0] < savedVolume;
savedVolume = Volume[0];
return(ret);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
if (OrdersTotal()>0)
OrdersList();
double cci ;
cci = iCCI(NULL,CCITimeFrame,CCiPeriod,PRICE_CLOSE,0);
adx = iADX(NULL,AdxTimeFrame,AdxPeriod,PRICE_CLOSE,MODE_MAIN,0);
MA1 = iMA(NULL,0,MAperiod1,0,MODE_EMA,PRICE_CLOSE,1);
MA2 = iMA(NULL,0,MAperiod2,0,MODE_EMA,PRICE_CLOSE,1);
MA3 = iMA(NULL,0,MAperiod3,0,MODE_EMA,PRICE_CLOSE,1);
MA4 = iMA(NULL,0,MAperiod4,0,MODE_EMA,PRICE_CLOSE,1);
//------------------------------------------
if( MA1 > MA2)
{
MAvalue = "UP]";
}
if( MA1 < MA2)
{
MAvalue = "Down]";
}
if( MA3 > MA4)
{
MAvalue2 = "UP]";
}
if( MA3 < MA4)
{
MAvalue2 = "Down]";
}
symbolpair = Symbol();
time = TimeToStr(TimeCurrent());
if (ShowOtherInfos == true)
{
ObjectCreate("BarTimer3" ,OBJ_LABEL,0,0,0);
ObjectSet("BarTimer3", OBJPROP_XDISTANCE, LabelXpos);
ObjectSet("BarTimer3", OBJPROP_YDISTANCE, LabelYpos);
ObjectSetText("BarTimer3", "[MA1 : "+MAvalue+" - [MA2 : "+MAvalue2+" - [ADX("+AdxTimeFrame+"
;) : "+DoubleToStr(adx, 0)+ "] - [CCI("+CCITimeFrame+"
;): "+DoubleToStr(cci,0)+"]", 11, "Arial", White);
}
if (ShowSpreadAndDailyRange == true)
{
ObjectCreate("BarTimer4" , OBJ_LABEL,0,0,0);
ObjectSet("BarTimer4", OBJPROP_XDISTANCE, LabelXpos);
if (ShowOtherInfos == true)
ObjectSet("BarTimer4", OBJPROP_YDISTANCE, LabelYpos+22);
else
ObjectSet("BarTimer4", OBJPROP_YDISTANCE, LabelYpos);
ObjectSetText("BarTimer4", "[Day ATR"+DailyAtrPeriod+" : "+DoubleToStr(iATR(NULL,1440,DailyAtrPeriod,0)*10000, 0)+ "] - [Day Range : "+DoubleToStr(iATR(NULL,1440,1,0)*10000, 0)+"] - [
Spread : "+DoubleToStr(MarketInfo("EURUSD",MODE_SPREAD)/10,1)+ " Pips]", 11, "Arial", Yellow);
}
else
ObjectDelete("BarTimer4"
;);
bool buySignal, sellSignal;
if (a == 0)
{
if(MA1 < MA2 && MA3 < MA4)
a=1;
if(MA1 > MA2 && MA3 > MA4)
a=2;
}
if (newBarFormed())
{
//------------ verif de positions
int scnt = 0, bcnt = 0, cnt = OrdersTotal();
for (i = 0; i < cnt; i++)
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
if (OrderMagicNumber() == magicNumber)
if (OrderType() == OP_BUY && OrderSymbol() == symbolpair)
bcnt++;
else
if (OrderType() == OP_SELL && OrderSymbol() == symbolpair)
scnt++;
// -------------- fin verif
Buy = MA1 > MA2 && MA3 > MA4 ;
Sell = MA1 < MA2 && MA3 < MA4;
}
if (adx>ADXFilterLimit)
{
//------------------------------------------
if((Buy) && a != 2)
{
if (cci >= CCIbuyLevel)
{
if (Alerts == true)
Alert(Symbol()," - EMA CROSS UP - BUY - ",Period()," @ ",Bid," ",time);
if (bcnt == 0)
{
//----------- passage d'ordre avec verif harcelement
ticket=OrderSend(Symbol(), OP_BUY, lotSize, Ask, 3, 0, 0, NAME + " " + VERSION, magicNumber);
while (ticket == -1) // tant que l’ordre n’est pas passé
{
Sleep(1000); // on attend une seconde
RefreshRates(); //on rafraichit les valeurs du cours de la paire
ticket = OrderSend(Symbol(), OP_BUY, lotSize, Ask, 3, 0, 0, NAME + " " + VERSION, magicNumber);
}
//------------ fin passage d'ordre
//OrderSend(Symbol(), OP_BUY, lotSize, Ask, 3, 0, 0, NAME + " " + VERSION, magicNumber);
if (TakeScreenShot == true)
if(!WindowScreenShot(StringConcatenate(NAME + "-" + Symbol(),"-",Period(),"-",TimeToStr(TimeCurrent(),TIME_DATE),"-",Hour(),"H",Minute(),".gif"
;),size_x,size_y))
Print(GetLastError());
}
a = 2;
}
}
if((Sell) && a != 1)
{
if (cci <= CCIsellLevel)
{
if (Alerts == true)
Alert(Symbol()," - EMA CROSS DOWN - SELL - ",Period()," @ ",Bid," ",time);
if (scnt == 0)
{
//----------- passage d'ordre avec verif harcelement
ticket=OrderSend(Symbol(), OP_SELL, lotSize, Bid, 3, 0, 0, NAME + " " + VERSION, magicNumber);
while (ticket == -1) // tant que l’ordre n’est pas passé
{
Sleep(1000); // on attend une seconde
RefreshRates(); //on rafraichit les valeurs du cours de la paire
ticket = OrderSend(Symbol(), OP_SELL, lotSize, Bid, 3, 0, 0, NAME + " " + VERSION, magicNumber);
}
//------------ fin passage d'ordre
// OrderSend(Symbol(), OP_SELL, lotSize, Bid, 3, 0, 0, NAME + " " + VERSION, magicNumber);
if (TakeScreenShot == true)
if(!WindowScreenShot(StringConcatenate(NAME + "-" + Symbol(),"-",Period(),"-",TimeToStr(TimeCurrent(),TIME_DATE),"-",Hour(),"H",Minute(),".gif"
;),size_x,size_y))
Print(GetLastError());
}
a = 1;
}
}
//------------------------------------------
}
return(0); }
//+------------------------------------------------------------------+
void OrdersList()
{
for (int cnt=0;cnt<OrdersTotal();cnt++)
{
OrderSelect(cnt, SELECT_BY_POS);
if (OrderSymbol()==Symbol() && OrderMagicNumber() == magicNumber)
{
if (OrderType()==OP_BUY)
{
if (OrderStopLoss()==0)
{
OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-StopLoss*Point,OrderOpenPrice()+TakeProfit*Point,0,LightGreen);
return(0);
}
//---- FirstEven
if (Bid-OrderOpenPrice()>Point*FirstEven&&OrderStopLoss()<OrderOpenPrice()&&Bid-OrderOpenPrice()<Point*BreakEven)
{
{OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-Point*StopLoss/2,OrderTakeProfit(),0,LightGreen);
return(0);}
}
//---- BreakEven
if (Bid-OrderOpenPrice()>Point*BreakEven&&OrderStopLoss()<OrderOpenPrice())
{
{OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0,LightGreen);
return(0);}
}
}
if (OrderType()==OP_SELL)
{
if (OrderStopLoss()==0)
{
OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+StopLoss*Point,OrderOpenPrice()-TakeProfit*Point,0,Yellow);
return(0);
}
//---- FirstEven
if (OrderOpenPrice()-Ask>Point*FirstEven&&OrderStopLoss()>OrderOpenPrice()&&OrderOpenPrice()-Ask<Point*BreakEven)
{
{OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+Point*StopLoss/2,OrderTakeProfit(),0,Yellow);
}
return(0);
}
//---- BreakEven
if (OrderOpenPrice()-Ask>Point*BreakEven&&OrderStopLoss()>OrderOpenPrice())
{
{OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0,Yellow);
}
return(0);
}
}
}
}
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit() {
//----
ObjectDelete("BarTimer3"
;);
ObjectDelete("BarTimer4"
;);
//----
return(0);
}
ce qui m'interesse et de remplacer les sl et tp par le croisement des mm ( l'efficacité est est superieur) avec les les SL et TP on peut aller aller à la faillite en reel tres rapidement
ci joint mon adresse:
[email protected]