por salvarb » 29 Sep 2011, 10:40
Hola a tod@s!
Hace tiempo que voy buscando por toda la red un EA, que pueda enviar a mi email, cada vez que se ejecute/cierre una orden. Creo que esto es posible, ya que existen indicadores que disponen de la opción alerta por email.
Gracias y un saludo Salva Rojas
-
salvarb
-
- Mensajes: 2
- Registrado: 26 Ago 2010, 16:04
- Karma: 0
por salvarb » 12 Oct 2011, 11:29
Ya he encontrado el indicador en cuestión. Lo dejo aquí por si alguien está interesado. Básicamente lo que hace es enviar un mail, cada vez que se abre/cierra, modifica o se introduce una orden pendiente. A mi solo me interesa que informe cuando se abre/cierra un trade, lo que hago es aplicar un filtro para que solo me lleguen estos eventos. ¿Alguien que sabe de mql4, podría modificar este EA para que solo envié cuando se abre/cierra una operación? http://www.expertadvisordownloads.com/tag/i-signaloftrade-mq4/Un saludo Salva Rojas
-
salvarb
-
- Mensajes: 2
- Registrado: 26 Ago 2010, 16:04
- Karma: 0
por forexpgm » 13 Oct 2011, 16:12
No tengo el MT4 aquí pero creo que con esta pequeña modificación puedes desactivar o activar el envío de modificaciones. Cambiando el parametro SendModif, te debería enviar o no enviar las modificaciones... Este sería el código - Código: Seleccionar todo
//+----------------------------------------------------------------------------+ //| i-SignalOfTrade.mq4 | //| Êèì Èãîðü Â. aka KimIV | //| http://www.kimiv.ru | //| | //| 05.12.2007 Ñèãíàëèçàòîð âûïîëíåíèÿ òîðãîâûõ îïåðàöèé. | //| 13.05.2008 Ñèãíàëèçàöèÿ ñðàáàòûâàíèÿ îòëîæåííîãî îðäåðà. | //| 29.12.2008 Èñïðàâëåíà îøèáêà ñèãíàëèçàöèè óäàëåíèÿ îðäåðà. | //+----------------------------------------------------------------------------+ #property copyright "Êèì Èãîðü Â. aka KimIV" #property link "http://www.kimiv.ru" #property indicator_chart_window
//------- Âíåøíèå ïàðàìåòðû èíäèêàòîðà ----------------------------------------+ extern string _P_WhatOutput = "---------- ×òî âûâîäèòü"; extern bool OutAccountNumber = True; // Âûâîäèòü íîìåð ñ÷¸òà extern bool OutAccountServer = True; // Âûâîäèòü èìÿ àêòèâíîãî ñåðâåðà extern bool OutNameExpert = True; // Âûâîäèòü èìÿ ýêñïåðòà extern bool OutDateTime = True; // Âûâîäèòü äàòó è âðåìÿ extern bool UseTimeLocal = True; // Èñïîëüçîâàòü ëîêàëüíîå âðåìÿ extern bool OutTicket = False; // Âûâîäèòü òèêåò extern bool OutMagic = True; // Âûâîäèòü ìàãèê extern bool OutComment = True; // Âûâîäèòü êîììåíòàðèé extern bool SendModif = false; //Enviar Modificaciones. extern string _P_WhereOutput = "---------- Êóäà âûâîäèòü"; extern bool UseAlert = True; // Èñïîëüçîâàòü äèàëîãîâîå îêíî extern bool UseComment = True; // Âûâîäèòü êîììåíòàðèé extern bool UsePrint = False; // Çàïèñûâàòü â æóðíàë extern bool UseSendMail = False; // Èñïîëüçîâàòü ïåðåäà÷ó ñîîáùåíèé extern bool UseSound = True; // Èñïîëüçîâàòü çâóê extern string sotFileName = "expert.wav"; // Íàèìåíîâàíèå çâóêîâîãî ôàéëà
//------- Ãëîáàëüíûå ïåðåìåííûå èíäèêàòîðà ------------------------------------+ int sotOTI[]; // òèêåò OrderTicket() int sotOTY[]; // òèï OrderType() double sotOOP[]; // öåíà OrderOpenPrice() double sotOSL[]; // ñòîï OrderStopLoss() double sotOTP[]; // òåéê OrderTakeProfit() bool sotFirstRun=True; // Ôëàã ïåðâîãî ïðîãîíà
//+----------------------------------------------------------------------------+ //| | //| ÏÐÅÄÎÏÐÅÄÅ˨ÍÍÛÅ ÔÓÍÊÖÈÈ | //| | //+----------------------------------------------------------------------------+ //| Custom indicator initialization function | //+----------------------------------------------------------------------------+ void init() { sotFirstRun=True; // Ôëàã ïåðâîãî ïðîãîíà Comment(""); }
//+----------------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+----------------------------------------------------------------------------+ void deinit() { Comment(""); }
//+----------------------------------------------------------------------------+ //| Custom indicator iteration function | //+----------------------------------------------------------------------------+ void start() { double p; // Ðàçìåð ïóíêòà â âàëþòå êîòèðîâêè int d; // Êîëè÷åñòâî öèôð ïîñëå äåñÿòè÷íîé òî÷êè â öåíå int i; // Ñ÷¸ò÷èê îïåðàöèé int in; // Èíäåêñ ýëåìåíòà ìàññèâà îïåðàöèé int k=OrdersTotal(); // Êîëè÷åñòâî òåêóùèõ îïåðàöèé int ot; // Òèï îïåðàöèè OrderType() int oti[]; // Ìàññèâ íîâûõ òèêåòîâ string sh=""; // Ñòðîêà çàãîëîâêà ïî÷òîâîãî ñîîáùåíèÿ string st; // Ñòðîêà òåëà ïî÷òîâîãî ñîîáùåíèÿ
if (sotFirstRun) { MemCurrOP(); sotFirstRun=False; } if (OutAccountNumber) sh=DoubleToStr(AccountNumber(), 0)+" "; if (OutAccountServer) sh=sh+AccountServer(); if (StringLen(sh)>0) sh=sh+"\n"; if (OutDateTime) { if (UseTimeLocal) sh=sh+TimeToStr(TimeLocal(), TIME_DATE|TIME_MINUTES)+" "; else sh=sh+TimeToStr(TimeCurrent(), TIME_DATE|TIME_SECONDS)+" "; } if (OutNameExpert) sh=sh+WindowExpertName()+" "; if (StringLen(sh)>0) sh=sh+"\n"; // Îòêðûòèå/Óñòàíîâêà íîâûõ, ìîäèôèêàöèÿ ñóùåñòâóþùèõ ArrayResize(oti, k); for (i=0; i<k; i++) { if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { oti[i]=OrderTicket(); d=MarketInfo(OrderSymbol(), MODE_DIGITS); p=MarketInfo(OrderSymbol(), MODE_POINT); in=ArraySearchInt(sotOTI, oti[i]);
// îïåðàöèÿ ÍÅ íàéäåíà, çíà÷èò íîâàÿ if (in<0) { ot=OrderType(); if (ot==OP_BUY || ot==OP_SELL) st="Open "; if (ot==OP_BUYLIMIT || ot==OP_BUYSTOP || ot==OP_SELLLIMIT || ot==OP_SELLSTOP) st="Set "; if (OutTicket) st=st+DoubleToStr(OrderTicket(), 0)+" "; st=st+GetNameOP(ot)+" " +DoubleToStr(OrderLots(), 2)+" " +OrderSymbol() +" PR="+DoubleToStr(OrderOpenPrice(), d) +" SL="+DoubleToStr(OrderStopLoss(), d) +" TP="+DoubleToStr(OrderTakeProfit(), d) +"\n" +IIFs(OutMagic, "Magic="+DoubleToStr(OrderMagicNumber(), 0), "") +IIFs(OutMagic && OutComment, " ", "") +IIFs(OutComment, "Comment=\""+OrderComment()+"\"", "") +IIFs(OutMagic || OutComment, "\n", ""); if (ot==OP_BUY || ot==OP_SELL) { st=st+"Balance="+DoubleToStr(AccountBalance(), 2) +" FreeMargin="+DoubleToStr(AccountFreeMargin(), 2); } if (StringLen(sh)>0) st=sh+st; Signal(st);
// îïåðàöèÿ íàéäåíà, çíà÷èò ñóùåñòâîâàëà ðàíåå è âîçìîæíî èçìåíåíà } else { // ñðàáàòûâàíèå îòëîæåííîãî îðäåðà ot=OrderType(); if (ot!=sotOTY[in] && (ot==OP_BUY || ot==OP_SELL)) { st="Open "; if (OutTicket) st=st+DoubleToStr(OrderTicket(), 0)+" "; st=st+GetNameOP(ot)+" by "+GetNameOP(sotOTY[in])+" " +DoubleToStr(OrderLots(), 2)+" " +OrderSymbol() +" PR="+DoubleToStr(OrderOpenPrice(), d) +" SL="+DoubleToStr(OrderStopLoss(), d) +" TP="+DoubleToStr(OrderTakeProfit(), d) +"\n" +IIFs(OutMagic, "Magic="+DoubleToStr(OrderMagicNumber(), 0), "") +IIFs(OutMagic && OutComment, " ", "") +IIFs(OutComment, "Comment=\""+OrderComment()+"\"", "") +IIFs(OutMagic || OutComment, "\n", ""); if (ot==OP_BUY || ot==OP_SELL) { st=st+"Balance="+DoubleToStr(AccountBalance(), 2) +" FreeMargin="+DoubleToStr(AccountFreeMargin(), 2); } if (StringLen(sh)>0) st=sh+st; Signal(st); } // ìîäèôèêàöèÿ îðäåðà èëè ïîçèöèè if ((MathAbs(OrderOpenPrice()-sotOOP[in])>=p) || (MathAbs(OrderStopLoss()-sotOSL[in])>=p) || (MathAbs(OrderTakeProfit()-sotOTP[in])>=p)) { st="Modify "; if (OutTicket) st=st+DoubleToStr(OrderTicket(), 0)+" "; st=st+GetNameOP(OrderType())+" " +DoubleToStr(OrderLots(), 2)+" " +OrderSymbol(); // èçìåíèëàñü öåíà îòêðûòèÿ if (MathAbs(OrderOpenPrice()-sotOOP[in])>=p) { st=st+" PR="+DoubleToStr(sotOOP[in], d)+"->"+DoubleToStr(OrderOpenPrice(), d); } // èçìåíèëñÿ óðîâåíü ñòîïà if (MathAbs(OrderStopLoss()-sotOSL[in])>=p) { st=st+" SL="+DoubleToStr(sotOSL[in], d)+"->"+DoubleToStr(OrderStopLoss(), d); } // èçìåíèëñÿ óðîâåíü òåéêà if (MathAbs(OrderTakeProfit()-sotOTP[in])>=p) { st=st+" TP="+DoubleToStr(sotOTP[in], d)+"->"+DoubleToStr(OrderTakeProfit(), d); } st=st+IIFs(OutMagic || OutComment, "\n", "") +IIFs(OutMagic, "Magic="+DoubleToStr(OrderMagicNumber(), 0), "") +IIFs(OutMagic && OutComment, " ", "") +IIFs(OutComment, "Comment=\""+OrderComment()+"\"", "") +IIFs(OutMagic || OutComment, "\n", ""); if (StringLen(sh)>0) st=sh+st; if (SendModif) Signal(st); } } } }
// Çàêðûòèå ïîçèöèé / Óäàëåíèå îðäåðîâ k=ArraySize(sotOTI); for (i=0; i<k; i++) { if (ArraySearchInt(oti, sotOTI[i])<0) { ot=sotOTY[i]; if (ot==OP_BUY || ot==OP_SELL) st="Close "; if (ot==OP_BUYLIMIT || ot==OP_BUYSTOP || ot==OP_SELLLIMIT || ot==OP_SELLSTOP) st="Delete "; if (OutTicket) st=st+DoubleToStr(sotOTI[i], 0)+" "; if (OrderSelect(sotOTI[i], SELECT_BY_TICKET)) { d=MarketInfo(OrderSymbol(), MODE_DIGITS); st=st+GetNameOP(ot)+" " +DoubleToStr(OrderLots(), 2)+" " +OrderSymbol() +" PR="+DoubleToStr(OrderClosePrice(), d) ; if (ot==OP_BUY || ot==OP_SELL) { st=st+" Profit="+DoubleToStr(OrderProfit()+OrderSwap(), 2) +"\n" +IIFs(OutMagic, "Magic="+DoubleToStr(OrderMagicNumber(), 0), "") +IIFs(OutMagic && OutComment, " ", "") +IIFs(OutComment, "Comment=\""+OrderComment()+"\"", "") +IIFs(OutMagic || OutComment, "\n", "") +"Balance="+DoubleToStr(AccountBalance(), 2) +" FreeMargin="+DoubleToStr(AccountFreeMargin(), 2); } if (StringLen(sh)>0) st=sh+st; Signal(st); } } }
MemCurrOP(); }
//+----------------------------------------------------------------------------+ //| | //| ÏÎËÜÇÎÂÀÒÅËÜÑÊÈÅ ÔÓÍÊÖÈÈ | //| | //+----------------------------------------------------------------------------+ //| Âûïîëíÿåò ïîèñê ýëåìåíòà ìàññèâà ïî çíà÷åíèþ | //| è âîçâðàùàåò èíäåêñ íàéäåííîãî ýëåìåíòà èëè -1 | //| Ïàðàìåòðû: | //| m - ìàññèâ ýëåìåíòîâ | //| e - çíà÷åíèå ýëåìåíòà | //+----------------------------------------------------------------------------+ int ArraySearchInt(int& m[], int e) { for (int i=0; i<ArraySize(m); i++) { if (m[i]==e) return(i); } return(-1); }
//+----------------------------------------------------------------------------+ //| Âîçâðàùàåò íàèìåíîâàíèå òîðãîâîé îïåðàöèè | //| Ïàðàìåòðû: | //| op - èäåíòèôèêàòîð òîðãîâîé îïåðàöèè | //+----------------------------------------------------------------------------+ string GetNameOP(int op) { switch (op) { case OP_BUY : return("Buy"); case OP_SELL : return("Sell"); case OP_BUYLIMIT : return("BuyLimit"); case OP_SELLLIMIT: return("SellLimit"); case OP_BUYSTOP : return("BuyStop"); case OP_SELLSTOP : return("SellStop"); default : return("Unknown Operation"); } }
//+----------------------------------------------------------------------------+ //| Âîçâðàùàåò îäíî èç äâóõ çíà÷åíèé âçàâèñèìîñòè îò óñëîâèÿ. | //+----------------------------------------------------------------------------+ string IIFs(bool condition, string ifTrue, string ifFalse) { if (condition) return(ifTrue); else return(ifFalse); }
//+----------------------------------------------------------------------------+ //| Çàïîìèíàåò òåêóùèå îïåðàöèè â ìàññèâå. | //+----------------------------------------------------------------------------+ void MemCurrOP() { int i, k=OrdersTotal();
ArrayResize(sotOTI, k); ArrayResize(sotOTY, k); ArrayResize(sotOOP, k); ArrayResize(sotOSL, k); ArrayResize(sotOTP, k); for (i=0; i<k; i++) { if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { sotOTI[i]=OrderTicket(); sotOTY[i]=OrderType(); sotOOP[i]=OrderOpenPrice(); sotOSL[i]=OrderStopLoss(); sotOTP[i]=OrderTakeProfit(); } } }
//+----------------------------------------------------------------------------+ //| Ïîäà÷à ñèãíàëà. | //| Ïàðàìåòðû: | //| st - ñòðîêà ñîîáùåíèÿ | //+----------------------------------------------------------------------------+ void Signal(string st) { if (UseAlert) Alert(st); if (UseComment) Comment(st); if (UseSendMail) SendMail(WindowExpertName(), st); if (UsePrint) Print(st); if (UseSound) PlaySound(sotFileName); } //+----------------------------------------------------------------------------+
-
forexpgm
-
- Mensajes: 6
- Registrado: 13 Oct 2011, 15:40
- Karma: 0
|
|