artem artem il MACD. E deve essere confermato 4 volte e l'ordine dovrebbe aprirsi sulla quarta candela. Ho allegato un file per renderlo visivamente chiaro.
SanAlex, puoi zoomare per vedere chiaramente le barre MACD e come quella veloce incrocia quella lenta? Riesco a malapena a vederlo.
Prova
#define MagicNumber 122122externstring s1 = "Trading options";
externdouble Lot = 0.01; // размер лота 0 - авт.расчетexterndouble StopLoss = 40; // стоплоссexterndouble TakeProfit = 10; // тейкпрофитexterndouble TrailStop = 21; // уровень без убыткаexternint Trailing = 0; // трейлинг стоп 1 вкл. 0 выкл.externint Breakeven = 0; // перенос стоп лосса в без убытокexternstring s2 = "Day & Hour";
externint HrStart = 0; // время начала торговлиexternint HrEnd = 23; // время окончания торговлиexternint Monday = 1; // Понедельник 1 вкд. 0 выкл.externint Tuesday = 1; // Вторникexternint Wednesday = 1; // Средаexternint Thursday = 1; // Четвергexternint Friday = 1; // Пятница//+------------------------------------------------------------------+// параметры индикаторовdouble MovingPeriodLw = 5;
double MovingPeriodS1 = 75;
double MovingPeriodS2 = 85;
double StopLevel;
double TrailStep = 3; // шаг трейлинг стопаbool OrderBuy = true, OrderSell = true, Order = false, Init = true;
int timeprev = 0, Slip = 3.0, start, cnt;
//+------------------------------------------------------------------+//| Init function |//+------------------------------------------------------------------+voidOnInit()
{
if (Digits == 3 || Digits == 5) { // Пересчет для 5-ти знаков
TakeProfit *= 10;
TrailStop *= 10;
TrailStep *= 10;
StopLoss *=10;
Slip *=10;
}
return;
}
//+------------------------------------------------------------------+//| Start function |//+------------------------------------------------------------------+void start()
{
StopLevel = MarketInfo(Symbol(), MODE_STOPLEVEL);
if(CheckForOpen()!=start)
{start=CheckForOpen(); cnt=0;}
else
{cnt+=1;}// Определение направления пересечения мувингов// if (Init) InitMetod(); // Трейлинг стоп открытых позицийif (Trailing != 0 ) RealTrailOrder(TrailStop, TrailStep, StopLevel, MagicNumber);
// Ожидание нового бара на графикеif(timeprev == Time[0]) return;
timeprev = Time[0];
if(cnt==3)
{// Открытие ордера по методу Пуриаif(CheckForOpen()==0 && OrderBuy==true) // Если сигнал для покупок
{
if(OrderSend(Symbol(),OP_BUY,Lots(),Ask,Slip,Bid-StopLoss*Point,Ask+TakeProfit*Point,"",MagicNumber,0,Blue))
{OrderBuy=false; Print("BUY OK");}
}
if(CheckForOpen()==1 && OrderSell==true) // Если сигнал для продаж
{
if(OrderSend(Symbol(),OP_SELL,Lots(),Bid,Slip,Ask+StopLoss*Point,Bid-TakeProfit*Point,"",MagicNumber,0,Red))
{OrderSell=false; Print("SELL OK");}
}
}
}
//+------------------------------------------------------------------+//| Check for open order conditions |//+------------------------------------------------------------------+int CheckForOpen() // Открытие ордера по методу Пуриа
{
double malw,mas1,mas2,macd;
int res=-1, buy=0, sell=0;
// Считывание параметров индикаторов 3 свечи (4ой)
malw=iMA(NULL,0,MovingPeriodLw,0,MODE_EMA,PRICE_CLOSE,3);
mas1=iMA(NULL,0,MovingPeriodS1,0,MODE_LWMA,PRICE_LOW,3);
mas2=iMA(NULL,0,MovingPeriodS2,0,MODE_LWMA,PRICE_LOW,3);
macd=iMACD(NULL,0,15,26,1,PRICE_CLOSE,MODE_MAIN,3);
if(malw>mas1&&malw>mas2&&macd>0) {buy+=1; sell=0;}
if(malw<mas1&&malw<mas2&&macd<0) {buy=0; sell+=1;}
// Считывание параметров индикаторов 2 свечи (3ей)
malw=iMA(NULL,0,MovingPeriodLw,0,MODE_EMA,PRICE_CLOSE,2);
mas1=iMA(NULL,0,MovingPeriodS1,0,MODE_LWMA,PRICE_LOW,2);
mas2=iMA(NULL,0,MovingPeriodS2,0,MODE_LWMA,PRICE_LOW,2);
macd=iMACD(NULL,0,15,26,1,PRICE_CLOSE,MODE_MAIN,2);
if(malw>mas1&&malw>mas2&&macd>0) {buy+=1; sell=0;}
if(malw<mas1&&malw<mas2&&macd<0) {buy=0; sell+=1;}
// Считывание параметров индикаторов 1 свечи (2ой)
malw=iMA(NULL,0,MovingPeriodLw,0,MODE_EMA,PRICE_CLOSE,1);
mas1=iMA(NULL,0,MovingPeriodS1,0,MODE_LWMA,PRICE_LOW,1);
mas2=iMA(NULL,0,MovingPeriodS2,0,MODE_LWMA,PRICE_LOW,1);
macd=iMACD(NULL,0,15,26,1,PRICE_CLOSE,MODE_MAIN,1);
if(malw>mas1&&malw>mas2&&macd>0) {buy+=1; sell=0;}
if(malw<mas1&&malw<mas2&&macd<0) {buy=0; sell+=1;}
// Считывание параметров индикаторов 0 свечи (1ой)
malw=iMA(NULL,0,MovingPeriodLw,0,MODE_EMA,PRICE_CLOSE,0);
mas1=iMA(NULL,0,MovingPeriodS1,0,MODE_LWMA,PRICE_LOW,0);
mas2=iMA(NULL,0,MovingPeriodS2,0,MODE_LWMA,PRICE_LOW,0);
macd=iMACD(NULL,0,15,26,1,PRICE_CLOSE,MODE_MAIN,0);
if(malw>mas1&&malw>mas2&&macd>0) {buy+=1; sell=0;}
if(malw<mas1&&malw<mas2&&macd<0) {buy=0; sell+=1;}
if(buy <4) OrderBuy=true;
if(sell<4) OrderSell=true;
if(buy ==4) { res=0; OrderSell=true;}
if(sell==4) { res=1; OrderBuy =true;}
return(res);
}
SanAlex, puoi zoomare in modo che le barre MACD siano chiaramente visibili e che quella veloce incroci quella lenta? Riesco a malapena a vederlo.
ma quello che ho aggiunto lì - lo scopo dell'Expert Advisor è diverso. L'obiettivo è quello di ottenere il profitto totale di tutte le coppie aperte e di chiudere tutti gli Expert Advisors.
artem artem #: MakaeFX, ora per qualche motivo non si apre dalla quarta candela di conferma, ma in realtà dalla settima. Ho allegato uno screenshot del tester
SanAlex, quindi il punto è che quello che voglio implementare sarà ancora meglio + lo sto facendo da qualche giorno, e sono già fondamentalmente interessato a come dovrebbe essere il codice giusto. E sarà molto utile per il futuro, e l'Expert Advisor sarà davvero buono. Ma la tua versione è anche buona, non posso dire nulla contro di essa.
SanAlex, puoi zoomare per vedere chiaramente le barre MACD e come quella veloce incrocia quella lenta? Riesco a malapena a vederlo.
Prova
SanAlex, puoi zoomare in modo che le barre MACD siano chiaramente visibili e che quella veloce incroci quella lenta? Riesco a malapena a vederlo.
ma quello che ho aggiunto lì - lo scopo dell'Expert Advisor è diverso. L'obiettivo è quello di ottenere il profitto totale di tutte le coppie aperte e di chiudere tutti gli Expert Advisors.
MakaeFX, ora per qualche motivo non si apre dalla quarta candela di conferma, ma in realtà dalla settima. Ho allegato uno screenshot del tester
MakarFX, allegato EA
esattamente MetaEditor - versione 5.00 build 2382
Non è chiaro come hai compilato il file che hai postato...
Qui, provate ad aggiungere ciò di cui avete bisogno
MakarFX, va bene se faccio il test su tutti i tick - dal 01.08.21 al 03.09.21 - poi 46 ordini
e se faccio il test solo con i prezzi di apertura nello stesso periodo - 29 ordini ?
+ diversi ordini hanno esplicitamente mancato il loro prezzo di apertura se sono stati testati da tick. Ho allegato uno screenshot, mostra