Powiadomienie SMS o transakcji EA

O jezykach programowania w platformach i nie tylko.
Awatar użytkownika
marek8
Gaduła
Gaduła
Posty: 288
Rejestracja: 26 lis 2011, 17:17

Powiadomienie SMS o transakcji EA

Nieprzeczytany post autor: marek8 »

Witam wszystkich ,
To EA powiadamia mailem o zmianach na rachunku tzn. otwarcie, zamknięcie pozycji i ustawienie zleceń oczekujących.

Przykładowy email z powiadomieniem wygląda tak:
Temat: Order changes Notification
 
New buy Order EURUSD.arm 0.01 Lot @1.3185

ja korzystam z Multi Box w orange , który po nadejściu maila wysyła smsa powiadamiającego o tym mailu.
niestety taki sms zawiera tylko temat emaila czyli " Order changes Notification"

Moja prośba dotyczy prostego / nie dla mnie :) / przerobienia EA ,żeby w temacie wiadomości robot wysyłał informację , która jest już w treści emaila, wtedy będzie widoczna w smsie powiadamiającym czyli np. "New buy Order EURUSD.arm 0.01 Lot @1.3185"

dziekuję


//+------------------------------------------------------------------+
//| Notify.mq4 |
//| Copyright 2012, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright 2012, MetaQuotes Software Corp."
#property link "http://www.forexfactory.com/mohan76"

extern bool MobileNotification = true;
extern bool EmailNotification = false;
extern bool AlertonPC = true;

extern bool nortify_orderclosed = true;
extern bool nortify_Pendingfilled = true;
extern bool nortify_new_pending = false;
extern bool nortify_new_order = false;
extern bool nortify_pending_deleted = false;



int totalord,totalpnd,totalopn;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----




//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+

int start()
{

string msg;


int tmp = OrdersTotal();

// Print(tmp , " - " ,totalpnd, "-" ,totalopn);

// if(totalord != tmp ){

// SendNotification("no of trade changed ");

if (tmp < totalord ){
// last closed order
int last_trade=HistoryTotal();
if(last_trade>0)
{
if(OrderSelect(last_trade-1,SELECT_BY_POS,MODE_HISTORY)==true) {
if ((OrderType()==OP_BUY) || (OrderType()==OP_SELL) ){

msg= StringConcatenate(TypeMnem(OrderType()) ," Order closed : "," ", OrderSymbol()," " ,OrderLots() , " Lot profit ",OrderProfit());
if(nortify_orderclosed){
if(MobileNotification){SendNotification(msg);}
if(EmailNotification){SendMail("Order changes Notification",msg);}
if(AlertonPC){Alert(msg);}
}

totalord = tmp;
return(0);



}


}
}

}


// send new order alert
int lastOpenTime = 0;
int tmp_pnd,temp_opn;
int ord_type;
for(int i = (OrdersTotal()-1); i >= 0; i --)
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
int curOpenTime = OrderOpenTime();
if(curOpenTime > lastOpenTime)
{
lastOpenTime = curOpenTime;
ord_type = OrderType();
msg = StringConcatenate("New ", TypeMnem(ord_type) ," Order " , OrderSymbol()," " ,OrderLots() , " Lot @", OrderOpenPrice());
}
// if(cmd!=OP_BUY && cmd!=OP_SELL)
if ((OrderType()==OP_BUY) || (OrderType()==OP_SELL) ){temp_opn=temp_opn + 1;}else{tmp_pnd =tmp_pnd +1 ;}
}
if (tmp > totalord ){
if ((ord_type==OP_BUY) || (ord_type==OP_SELL) ){

if(nortify_new_order){
if(MobileNotification){SendNotification(msg);}
if(EmailNotification){SendMail("Order changes Notification",msg);}
if(AlertonPC){Alert(msg);}
}
}


}









//-----------------------
if(tmp_pnd != totalpnd){
//pending filled or deleted
if(tmp_pnd < totalpnd){
if(totalopn < temp_opn){
if(nortify_Pendingfilled){
msg="Pending Filled";
if(MobileNotification){SendNotification(msg);}
if(EmailNotification){SendMail("Order changes Notification",msg);}
if(AlertonPC){Alert(msg);}
}
}
else{msg="Pending Deleted";}
if(nortify_pending_deleted){
if(MobileNotification){SendNotification(msg);}
if(EmailNotification){SendMail("Order changes Notification",msg);}
if(AlertonPC){Alert(msg);}
}
}

// new pending placed
if(tmp_pnd > totalpnd){
if(nortify_new_pending){
msg="New Pending order";
if(MobileNotification){SendNotification(msg);}
if(EmailNotification){SendMail("Order changes Notification",msg);}
if(AlertonPC){Alert(msg);}
}

}



}



//-------------------------

totalpnd=tmp_pnd;
totalopn=temp_opn;
totalord = tmp;
// } // end of total ord change

return(0);
}



//+------------------------------------------------------------------+

string TypeMnem(int type) {
switch (type) {
case OP_BUY: return("buy");
case OP_SELL: return("sell");
case OP_BUYLIMIT: return("buy limit");
case OP_SELLLIMIT: return("sell limit");
case OP_BUYSTOP: return("buy stop");
case OP_SELLSTOP: return("sell stop");
default: return("???");
}
}
Mk 9.23 - "....Wszystko możliwe jest dla tego kto wierzy".

QTrader
Gaduła
Gaduła
Posty: 223
Rejestracja: 27 lut 2013, 17:33

Re: Powiadomienie SMS o transakcji EA

Nieprzeczytany post autor: QTrader »

Zamień wszędzie w kodzie :

Kod: Zaznacz cały

if(EmailNotification){SendMail("Order changes Notification",msg);}
na

Kod: Zaznacz cały

if(EmailNotification){SendMail(msg,msg);}
Pozdrawiam

Awatar użytkownika
marek8
Gaduła
Gaduła
Posty: 288
Rejestracja: 26 lis 2011, 17:17

Re: Powiadomienie SMS o transakcji EA

Nieprzeczytany post autor: marek8 »

Teraz jest ok.
Dzięki za pomoc
pozdrawiam
Mk 9.23 - "....Wszystko możliwe jest dla tego kto wierzy".

Awatar użytkownika
marek8
Gaduła
Gaduła
Posty: 288
Rejestracja: 26 lis 2011, 17:17

Re: Powiadomienie SMS o transakcji EA

Nieprzeczytany post autor: marek8 »

witam wszystkich ponownie :)
czy może ktoś pomóc w tym kodzie również przenieść treść maila do tematu SMS jak w tym powyższym, z góry dzięki

//+------------------------------------------------------------------+
//| MA-Crossover_Alert.mq4 |
//| Copyright Š 2005, Jason Robinson (jnrtrading) |
//| http://www.jnrtading.co.uk |
//| Modified by Robert Hill to add LSMA and alert or send email |
//| Added Global LastAlert to try to have alert only on new cross |
//| but does not seem to work. So indicator does alert every bar |
//+------------------------------------------------------------------+

/*
+------------------------------------------------------------------+
| Allows you to enter two ma periods and it will then show you at |
| Which point they crossed over. It is more usful on the shorter |
| periods that get obscured by the bars / candlesticks and when |
| the zoom level is out. Also allows you then to remove the mas |
| from the chart. (emas are initially set at 5 and 6) |
+------------------------------------------------------------------+
*/
#property copyright "Copyright Š 2005, Jason Robinson (jnrtrading)"
#property link "http://www.jnrtrading.co.uk"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 LawnGreen
#property indicator_color2 Red

extern bool SoundON=true;
extern bool EmailON=false;

extern int FastMA_Mode = 1; //0=sma, 1=ema, 2=smma, 3=lwma, 4=lsma
extern int FastMA_Period = 50;
extern int FastPriceMode = 0;//0=close, 1=open, 2=high, 3=low, 4=median(high+low)/2, 5=typical(high+low+close)/3, 6=weighted(high+low+close+close)/4
extern int SlowMA_Mode = 1; //0=sma, 1=ema, 2=smma, 3=lwma, 4=lsma
extern int SlowMA_Period = 100;
extern int SlowPriceMode = 0;//0=close, 1=open, 2=high, 3=low, 4=median(high+low)/2, 5=typical(high+low+close)/3, 6=weighted(high+low+close+close)/4
double CrossUp[];
double CrossDown[];
int flagval1 = 0;
int flagval2 = 0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0, DRAW_ARROW, EMPTY, 1);
SetIndexArrow(0, 233);
SetIndexBuffer(0, CrossUp);
SetIndexStyle(1, DRAW_ARROW, EMPTY, 1);
SetIndexArrow(1, 234);
SetIndexBuffer(1, CrossDown);
GlobalVariableSet("AlertTime"+Symbol()+Period(),CurTime());
GlobalVariableSet("SignalType"+Symbol()+Period(),OP_SELLSTOP);
// GlobalVariableSet("LastAlert"+Symbol()+Period(),0);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
GlobalVariableDel("AlertTime"+Symbol()+Period());
GlobalVariableDel("SignalType"+Symbol()+Period());
// GlobalVariableDel("LastAlert"+Symbol()+Period());

//----
return(0);
}

//+------------------------------------------------------------------+
//| LSMA with PriceMode |
//| PrMode 0=close, 1=open, 2=high, 3=low, 4=median(high+low)/2, |
//| 5=typical(high+low+close)/3, 6=weighted(high+low+close+close)/4 |
//+------------------------------------------------------------------+

double LSMA(int Rperiod, int prMode, int shift)
{
int i;
double sum, pr;
int length;
double lengthvar;
double tmp;
double wt;

length = Rperiod;

sum = 0;
for(i = length; i >= 1 ; i--)
{
lengthvar = length + 1;
lengthvar /= 3;
tmp = 0;
switch (prMode)
{
case 0: pr = Close[length-i+shift];break;
case 1: pr = Open[length-i+shift];break;
case 2: pr = High[length-i+shift];break;
case 3: pr = Low[length-i+shift];break;
case 4: pr = (High[length-i+shift] + Low[length-i+shift])/2;break;
case 5: pr = (High[length-i+shift] + Low[length-i+shift] + Close[length-i+shift])/3;break;
case 6: pr = (High[length-i+shift] + Low[length-i+shift] + Close[length-i+shift] + Close[length-i+shift])/4;break;
}
tmp = ( i - lengthvar)*pr;
sum+=tmp;
}
wt = sum*6/(length*(length+1));

return(wt);
}


//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start() {
int limit, i, counter;
double tmp=0;
double fastMAnow, slowMAnow, fastMAprevious, slowMAprevious;
double Range, AvgRange;
int counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;

limit=Bars-counted_bars;

for(i = 0; i <= limit; i++) {

counter=i;
Range=0;
AvgRange=0;
for (counter=i ;counter<=i+9;counter++)
{
AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]);
}
Range=AvgRange/10;

if (FastMA_Mode == 4)
{
fastMAnow = LSMA(FastMA_Period, FastPriceMode, i);
fastMAprevious = LSMA(FastMA_Period, FastPriceMode, i+1);

}
else
{
fastMAnow = iMA(NULL, 0, FastMA_Period, 0, FastMA_Mode, FastPriceMode, i);
fastMAprevious = iMA(NULL, 0, FastMA_Period, 0, FastMA_Mode, FastPriceMode, i+1);
}

if (SlowMA_Mode == 4)
{
slowMAnow = LSMA( SlowMA_Period, SlowPriceMode, i);
slowMAprevious = LSMA( SlowMA_Period, SlowPriceMode, i+1);
}
else
{
slowMAnow = iMA(NULL, 0, SlowMA_Period, 0, SlowMA_Mode, SlowPriceMode, i);
slowMAprevious = iMA(NULL, 0, SlowMA_Period, 0, SlowMA_Mode, SlowPriceMode, i+1);
}

if ((fastMAnow > slowMAnow) && (fastMAprevious < slowMAprevious))
{
if (i == 1 && flagval1==0){ flagval1=1; flagval2=0; }
CrossUp = Low - Range*0.75;
}
else if ((fastMAnow < slowMAnow) && (fastMAprevious > slowMAprevious))
{
if (i == 1 && flagval2==0) { flagval2=1; flagval1=0; }
CrossDown = High + Range*0.75;
}
}

if (flagval1==1 && CurTime() > GlobalVariableGet("AlertTime"+Symbol()+Period()) && GlobalVariableGet("SignalType"+Symbol()+Period())!=OP_BUY)
{
// if (GlobalVariableGet("LastAlert"+Symbol()+Period()) < 0.5)
// {
if (SoundON) Alert("BUY signal at Ask=",Ask,"\n Bid=",Bid,"\n Time=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\n Symbol=",Symbol()," Period=",Period());
if (EmailON) SendMail("BUY signal alert","BUY signal at Ask="+DoubleToStr(Ask,4)+", Bid="+DoubleToStr(Bid,4)+", Date="+TimeToStr(CurTime(),TIME_DATE)+" "+TimeHour(CurTime())+":"+TimeMinute(CurTime())+" Symbol="+Symbol()+" Period="+Period());
// }
tmp = CurTime() + (Period()-MathMod(Minute(),Period()))*60;
GlobalVariableSet("AlertTime"+Symbol()+Period(),tmp);
GlobalVariableSet("SignalType"+Symbol()+Period(),OP_SELL);
// GlobalVariableSet("LastAlert"+Symbol()+Period(),1);
}

if (flagval2==1 && CurTime() > GlobalVariableGet("AlertTime"+Symbol()+Period()) && GlobalVariableGet("SignalType"+Symbol()+Period())!=OP_SELL) {
// if (GlobalVariableGet("LastAlert"+Symbol()+Period()) > -0.5)
// {
if (SoundON) Alert("SELL signal at Ask=",Ask,"\n Bid=",Bid,"\n Date=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\n Symbol=",Symbol()," Period=",Period());
if (EmailON) SendMail("SELL signal alert","SELL signal at Ask="+DoubleToStr(Ask,4)+", Bid="+DoubleToStr(Bid,4)+", Date="+TimeToStr(CurTime(),TIME_DATE)+" "+TimeHour(CurTime())+":"+TimeMinute(CurTime())+" Symbol="+Symbol()+" Period="+Period());
// }
tmp = CurTime() + (Period()-MathMod(Minute(),Period()))*60;
GlobalVariableSet("AlertTime"+Symbol()+Period(),tmp);
GlobalVariableSet("SignalType"+Symbol()+Period(),OP_BUY);
// GlobalVariableSet("LastAlert"+Symbol()+Period(),-1);
}

return(0);
}
Mk 9.23 - "....Wszystko możliwe jest dla tego kto wierzy".

Awatar użytkownika
marekpast
Stały bywalec
Stały bywalec
Posty: 40
Rejestracja: 03 sty 2011, 09:09

Re: Powiadomienie SMS o transakcji EA

Nieprzeczytany post autor: marekpast »

marek8 pisze:witam wszystkich ponownie :)

[...]
if (EmailON) SendMail("BUY signal alert","BUY signal at Ask="+DoubleToStr(Ask,4)+", Bid="+DoubleToStr(Bid,4)+", Date="+TimeToStr(CurTime(),TIME_DATE)+" "+TimeHour(CurTime())+":"+TimeMinute(CurTime())+" Symbol="+Symbol()+" Period="+Period());

[...]
if (EmailON) SendMail("SELL signal alert","SELL signal at Ask="+DoubleToStr(Ask,4)+", Bid="+DoubleToStr(Bid,4)+", Date="+TimeToStr(CurTime(),TIME_DATE)+" "+TimeHour(CurTime())+":"+TimeMinute(CurTime())+" Symbol="+Symbol()+" Period="+Period());
Całą treść przenieść do tematu?
Jeśli tak to zamiast powyższych linijek wpisać:

string message= "BUY signal at Ask="+DoubleToStr(Ask,4)+", Bid="+DoubleToStr(Bid,4)+", Date="+TimeToStr(CurTime(),TIME_DATE)+" "+TimeHour(CurTime())+":"+TimeMinute(CurTime())+" Symbol="+Symbol()+" Period="+Period();
if (EmailON) SendMail(message,"");

[...]

message= "SELL signal at Ask="+DoubleToStr(Ask,4)+", Bid="+DoubleToStr(Bid,4)+", Date="+TimeToStr(CurTime(),TIME_DATE)+" "+TimeHour(CurTime())+":"+TimeMinute(CurTime())+" Symbol="+Symbol()+" Period="+Period();
if (EmailON) SendMail(message,"");


Pozdrawiam Marek
______________________________
Pozdrawiam Marek

Awatar użytkownika
marek8
Gaduła
Gaduła
Posty: 288
Rejestracja: 26 lis 2011, 17:17

Re: Powiadomienie SMS o transakcji EA

Nieprzeczytany post autor: marek8 »

Działa tak jak chciałem , dziękuję za pomoc
Marek pozdrawia Marka :)
Mk 9.23 - "....Wszystko możliwe jest dla tego kto wierzy".

Awatar użytkownika
marek8
Gaduła
Gaduła
Posty: 288
Rejestracja: 26 lis 2011, 17:17

Re: Powiadomienie SMS o transakcji EA

Nieprzeczytany post autor: marek8 »

.... a czy można w powyższym kodzie ustawić limit powiadomień ?
tzn. jeżeli jest spełniony warunek przecięcia, to żeby było wygenerowane powiadomienie tylko za pierwszym razem - na następnej świecy jest spełniony znowu ten sam warunek i jest znowu to samo powiadomienie.
Przy mniejszych interwałach to jest denerwujące....

-- Dodano: pt 13-09-2013, 9:43 --

Ten kod generuje tylko jeden raz sygnał po EMA cross i nie powtarza ich.
tylko gdzie wstawić te llinie ,żeby wiadomość przenieść do tematu SMS ?

Całą treść przenieść do tematu?
Jeśli tak to zamiast powyższych linijek wpisać:

string message= "BUY signal at Ask="+DoubleToStr(Ask,4)+", Bid="+DoubleToStr(Bid,4)+", Date="+TimeToStr(CurTime(),TIME_DATE)+" "+TimeHour(CurTime())+":"+TimeMinute(CurTime())+" Symbol="+Symbol()+" Period="+Period();
if (EmailON) SendMail(message,"");

[...]

message= "SELL signal at Ask="+DoubleToStr(Ask,4)+", Bid="+DoubleToStr(Bid,4)+", Date="+TimeToStr(CurTime(),TIME_DATE)+" "+TimeHour(CurTime())+":"+TimeMinute(CurTime())+" Symbol="+Symbol()+" Period="+Period();
if (EmailON) SendMail(message,"");







//+------------------------------------------------------------------+
//| MA-Crossover_Alert.mq4 |
//| Copyright © 2005, Jason Robinson (jnrtrading) |
//| http://www.jnrtading.co.uk |
//| Modified by Robert Hill to add LSMA and alert or send email |
//| Added Global LastAlert to try to have alert only on new cross |
//| but does not seem to work. So indicator does alert every bar |
//+------------------------------------------------------------------+

/*
+------------------------------------------------------------------+
| Allows you to enter two ma periods and it will then show you at |
| Which point they crossed over. It is more usful on the shorter |
| periods that get obscured by the bars / candlesticks and when |
| the zoom level is out. Also allows you then to remove the mas |
| from the chart. (emas are initially set at 5 and 20) |
+------------------------------------------------------------------+
*/
#property copyright "Copyright © 2005, Jason Robinson (jnrtrading)"
#property link "http://www.jnrtrading.co.uk"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 LawnGreen
#property indicator_color2 Red

extern bool SoundON=true;
extern bool EmailON=false;

extern int FastMA_Mode = 1; //0=sma, 1=ema, 2=smma, 3=lwma, 4=lsma
extern int FastMA_Period = 5;
extern int FastPriceMode = 0;//0=close, 1=open, 2=high, 3=low, 4=median(high+low)/2, 5=typical(high+low+close)/3, 6=weighted(high+low+close+close)/4
extern int SlowMA_Mode = 1; //0=sma, 1=ema, 2=smma, 3=lwma, 4=lsma
extern int SlowMA_Period = 10;
extern int SlowPriceMode = 0;//0=close, 1=open, 2=high, 3=low, 4=median(high+low)/2, 5=typical(high+low+close)/3, 6=weighted(high+low+close+close)/4
double CrossUp[];
double CrossDown[];
int flagval1 = 0;
int flagval2 = 0;
bool downalertsent,upalertsent,downemailsent,upemailsent;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0, DRAW_ARROW, EMPTY, 1);
SetIndexArrow(0, 233);
SetIndexBuffer(0, CrossUp);
SetIndexEmptyValue(0,0.0);
SetIndexStyle(1, DRAW_ARROW, EMPTY, 1);
SetIndexArrow(1, 234);
SetIndexBuffer(1, CrossDown);
SetIndexEmptyValue(1,0.0);
GlobalVariableSet("AlertTime"+Symbol()+Period(),CurTime());
GlobalVariableSet("SignalType"+Symbol()+Period(),OP_SELLSTOP);
// GlobalVariableSet("LastAlert"+Symbol()+Period(),0);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
GlobalVariableDel("AlertTime"+Symbol()+Period());
GlobalVariableDel("SignalType"+Symbol()+Period());
// GlobalVariableDel("LastAlert"+Symbol()+Period());

//----
return(0);
}

//+------------------------------------------------------------------+
//| LSMA with PriceMode |
//| PrMode 0=close, 1=open, 2=high, 3=low, 4=median(high+low)/2, |
//| 5=typical(high+low+close)/3, 6=weighted(high+low+close+close)/4 |
//+------------------------------------------------------------------+

double LSMA(int Rperiod, int prMode, int shift)
{
int i;
double sum, pr;
int length;
double lengthvar;
double tmp;
double wt;

length = Rperiod;

sum = 0;
for(i = length; i >= 1 ; i--)
{
lengthvar = length + 1;
lengthvar /= 3;
tmp = 0;
switch (prMode)
{
case 0: pr = Close[length-i+shift];break;
case 1: pr = Open[length-i+shift];break;
case 2: pr = High[length-i+shift];break;
case 3: pr = Low[length-i+shift];break;
case 4: pr = (High[length-i+shift] + Low[length-i+shift])/2;break;
case 5: pr = (High[length-i+shift] + Low[length-i+shift] + Close[length-i+shift])/3;break;
case 6: pr = (High[length-i+shift] + Low[length-i+shift] + Close[length-i+shift] + Close[length-i+shift])/4;break;
}
tmp = ( i - lengthvar)*pr;
sum+=tmp;
}
wt = sum*6/(length*(length+1));

return(wt);
}


//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start() {
int limit, i, counter;
double tmp=0;
double fastMAnow, slowMAnow, fastMAprevious, slowMAprevious;
double Range, AvgRange;
int counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;

limit=Bars-counted_bars;

for(i = limit; i >= 0; i--) {

counter=i;
Range=0;
AvgRange=0;
for (counter=i ;counter<=i+9;counter++)
{
AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]);
}
Range=AvgRange/10;

if (FastMA_Mode == 4)
{
fastMAnow = LSMA(FastMA_Period, FastPriceMode, i+1);
fastMAprevious = LSMA(FastMA_Period, FastPriceMode, i+2);

}
else
{
fastMAnow = iMA(NULL, 0, FastMA_Period, 0, FastMA_Mode, FastPriceMode, i+1);
fastMAprevious = iMA(NULL, 0, FastMA_Period, 0, FastMA_Mode, FastPriceMode, i+2);
}

if (SlowMA_Mode == 4)
{
slowMAnow = LSMA( SlowMA_Period, SlowPriceMode, i+1);
slowMAprevious = LSMA( SlowMA_Period, SlowPriceMode, i+2);
}
else
{
slowMAnow = iMA(NULL, 0, SlowMA_Period, 0, SlowMA_Mode, SlowPriceMode, i+1);
slowMAprevious = iMA(NULL, 0, SlowMA_Period, 0, SlowMA_Mode, SlowPriceMode, i+2);
}

if ((fastMAnow > slowMAnow) && (fastMAprevious < slowMAprevious)&& CrossUp[i+1]==0)
{
if (i == 1 && flagval1==0){ flagval1=1; flagval2=0; }
CrossUp[i+1] = Low - Range*0.75;
}
else if ((fastMAnow < slowMAnow) && (fastMAprevious > slowMAprevious)&& CrossDown[i+1]==0)
{
if (i == 1 && flagval2==0) { flagval2=1; flagval1=0; }
CrossDown[i+1] = High + Range*0.75;
}
}
if(SoundON && CrossUp[1]!=0.0 && !upalertsent)
{
Alert("BUY signal at Ask=",Ask,"\n Bid=",Bid,"\n Time=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\n Symbol=",Symbol()," Period=",Period());
upalertsent=true;
}
if(SoundON && CrossDown[1]!=0.0 && !downalertsent)
{
Alert("SELL signal at Ask=",Ask,"\n Bid=",Bid,"\n Date=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\n Symbol=",Symbol()," Period=",Period());
downalertsent=true;
}
if(EmailON && CrossUp[1]!=0.0 && !upemailsent)
{
SendMail("BUY signal alert","BUY signal at Ask="+DoubleToStr(Ask,4)+", Bid="+DoubleToStr(Bid,4)+", Date="+TimeToStr(CurTime(),TIME_DATE)+" "+TimeHour(CurTime())+":"+TimeMinute(CurTime())+" Symbol="+Symbol()+" Period="+Period());
upemailsent=true;
}
if(EmailON && CrossDown[1]!=0.0 && !downemailsent)
{
SendMail("SELL signal alert","SELL signal at Ask="+DoubleToStr(Ask,4)+", Bid="+DoubleToStr(Bid,4)+", Date="+TimeToStr(CurTime(),TIME_DATE)+" "+TimeHour(CurTime())+":"+TimeMinute(CurTime())+" Symbol="+Symbol()+" Period="+Period());
downemailsent=true;
}
if(CrossUp[1] ==0.0 && CrossDown[1] == 0.0)
{
upalertsent=false;
downalertsent=false;
upemailsent=false;
downemailsent=false;
}
/* if (flagval1==1 && CurTime() > GlobalVariableGet("AlertTime"+Symbol()+Period()) && GlobalVariableGet("SignalType"+Symbol()+Period())!=OP_BUY)
{
// if (GlobalVariableGet("LastAlert"+Symbol()+Period()) < 0.5)
// {
if (SoundON) Alert("BUY signal at Ask=",Ask,"\n Bid=",Bid,"\n Time=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\n Symbol=",Symbol()," Period=",Period());
if (EmailON) SendMail("BUY signal alert","BUY signal at Ask="+DoubleToStr(Ask,4)+", Bid="+DoubleToStr(Bid,4)+", Date="+TimeToStr(CurTime(),TIME_DATE)+" "+TimeHour(CurTime())+":"+TimeMinute(CurTime())+" Symbol="+Symbol()+" Period="+Period());
// }
tmp = CurTime() + (Period()-MathMod(Minute(),Period()))*60;
GlobalVariableSet("AlertTime"+Symbol()+Period(),tmp);
GlobalVariableSet("SignalType"+Symbol()+Period(),OP_SELL);
// GlobalVariableSet("LastAlert"+Symbol()+Period(),1);
}

if (flagval2==1 && CurTime() > GlobalVariableGet("AlertTime"+Symbol()+Period()) && GlobalVariableGet("SignalType"+Symbol()+Period())!=OP_SELL) {
// if (GlobalVariableGet("LastAlert"+Symbol()+Period()) > -0.5)
// {
if (SoundON) Alert("SELL signal at Ask=",Ask,"\n Bid=",Bid,"\n Date=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\n Symbol=",Symbol()," Period=",Period());
if (EmailON) SendMail("SELL signal alert","SELL signal at Ask="+DoubleToStr(Ask,4)+", Bid="+DoubleToStr(Bid,4)+", Date="+TimeToStr(CurTime(),TIME_DATE)+" "+TimeHour(CurTime())+":"+TimeMinute(CurTime())+" Symbol="+Symbol()+" Period="+Period());
// }
tmp = CurTime() + (Period()-MathMod(Minute(),Period()))*60;
GlobalVariableSet("AlertTime"+Symbol()+Period(),tmp);
GlobalVariableSet("SignalType"+Symbol()+Period(),OP_BUY);
// GlobalVariableSet("LastAlert"+Symbol()+Period(),-1);
}
*/
return(0);
}

-- Dodano: pt 13-09-2013, 9:44 --

marek8 pisze:.... a czy można w powyższym kodzie ustawić limit powiadomień ?
tzn. jeżeli jest spełniony warunek przecięcia, to żeby było wygenerowane powiadomienie tylko za pierwszym razem - na następnej świecy jest spełniony znowu ten sam warunek i jest znowu to samo powiadomienie.
Przy mniejszych interwałach to jest denerwujące....

-- Dodano: pt 13-09-2013, 9:43 --

Ten kod generuje tylko jeden raz sygnał po EMA cross i nie powtarza ich.
tylko gdzie wstawić te linie , żeby wiadomość przenieść do tematu SMS ?



string message= "BUY signal at Ask="+DoubleToStr(Ask,4)+", Bid="+DoubleToStr(Bid,4)+", Date="+TimeToStr(CurTime(),TIME_DATE)+" "+TimeHour(CurTime())+":"+TimeMinute(CurTime())+" Symbol="+Symbol()+" Period="+Period();
if (EmailON) SendMail(message,"");

[...]

message= "SELL signal at Ask="+DoubleToStr(Ask,4)+", Bid="+DoubleToStr(Bid,4)+", Date="+TimeToStr(CurTime(),TIME_DATE)+" "+TimeHour(CurTime())+":"+TimeMinute(CurTime())+" Symbol="+Symbol()+" Period="+Period();
if (EmailON) SendMail(message,"");






Ten kod generuje tylko jeden raz email o crossie i nie powtarza ich co nowy bar ( o to chodzi)


//+------------------------------------------------------------------+
//| MA-Crossover_Alert.mq4 |
//| Copyright © 2005, Jason Robinson (jnrtrading) |
//| http://www.jnrtading.co.uk |
//| Modified by Robert Hill to add LSMA and alert or send email |
//| Added Global LastAlert to try to have alert only on new cross |
//| but does not seem to work. So indicator does alert every bar |
//+------------------------------------------------------------------+

/*
+------------------------------------------------------------------+
| Allows you to enter two ma periods and it will then show you at |
| Which point they crossed over. It is more usful on the shorter |
| periods that get obscured by the bars / candlesticks and when |
| the zoom level is out. Also allows you then to remove the mas |
| from the chart. (emas are initially set at 5 and 20) |
+------------------------------------------------------------------+
*/
#property copyright "Copyright © 2005, Jason Robinson (jnrtrading)"
#property link "http://www.jnrtrading.co.uk"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 LawnGreen
#property indicator_color2 Red

extern bool SoundON=true;
extern bool EmailON=false;

extern int FastMA_Mode = 1; //0=sma, 1=ema, 2=smma, 3=lwma, 4=lsma
extern int FastMA_Period = 5;
extern int FastPriceMode = 0;//0=close, 1=open, 2=high, 3=low, 4=median(high+low)/2, 5=typical(high+low+close)/3, 6=weighted(high+low+close+close)/4
extern int SlowMA_Mode = 1; //0=sma, 1=ema, 2=smma, 3=lwma, 4=lsma
extern int SlowMA_Period = 10;
extern int SlowPriceMode = 0;//0=close, 1=open, 2=high, 3=low, 4=median(high+low)/2, 5=typical(high+low+close)/3, 6=weighted(high+low+close+close)/4
double CrossUp[];
double CrossDown[];
int flagval1 = 0;
int flagval2 = 0;
bool downalertsent,upalertsent,downemailsent,upemailsent;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0, DRAW_ARROW, EMPTY, 1);
SetIndexArrow(0, 233);
SetIndexBuffer(0, CrossUp);
SetIndexEmptyValue(0,0.0);
SetIndexStyle(1, DRAW_ARROW, EMPTY, 1);
SetIndexArrow(1, 234);
SetIndexBuffer(1, CrossDown);
SetIndexEmptyValue(1,0.0);
GlobalVariableSet("AlertTime"+Symbol()+Period(),CurTime());
GlobalVariableSet("SignalType"+Symbol()+Period(),OP_SELLSTOP);
// GlobalVariableSet("LastAlert"+Symbol()+Period(),0);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
GlobalVariableDel("AlertTime"+Symbol()+Period());
GlobalVariableDel("SignalType"+Symbol()+Period());
// GlobalVariableDel("LastAlert"+Symbol()+Period());

//----
return(0);
}

//+------------------------------------------------------------------+
//| LSMA with PriceMode |
//| PrMode 0=close, 1=open, 2=high, 3=low, 4=median(high+low)/2, |
//| 5=typical(high+low+close)/3, 6=weighted(high+low+close+close)/4 |
//+------------------------------------------------------------------+

double LSMA(int Rperiod, int prMode, int shift)
{
int i;
double sum, pr;
int length;
double lengthvar;
double tmp;
double wt;

length = Rperiod;

sum = 0;
for(i = length; i >= 1 ; i--)
{
lengthvar = length + 1;
lengthvar /= 3;
tmp = 0;
switch (prMode)
{
case 0: pr = Close[length-i+shift];break;
case 1: pr = Open[length-i+shift];break;
case 2: pr = High[length-i+shift];break;
case 3: pr = Low[length-i+shift];break;
case 4: pr = (High[length-i+shift] + Low[length-i+shift])/2;break;
case 5: pr = (High[length-i+shift] + Low[length-i+shift] + Close[length-i+shift])/3;break;
case 6: pr = (High[length-i+shift] + Low[length-i+shift] + Close[length-i+shift] + Close[length-i+shift])/4;break;
}
tmp = ( i - lengthvar)*pr;
sum+=tmp;
}
wt = sum*6/(length*(length+1));

return(wt);
}


//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start() {
int limit, i, counter;
double tmp=0;
double fastMAnow, slowMAnow, fastMAprevious, slowMAprevious;
double Range, AvgRange;
int counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;

limit=Bars-counted_bars;

for(i = limit; i >= 0; i--) {

counter=i;
Range=0;
AvgRange=0;
for (counter=i ;counter<=i+9;counter++)
{
AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]);
}
Range=AvgRange/10;

if (FastMA_Mode == 4)
{
fastMAnow = LSMA(FastMA_Period, FastPriceMode, i+1);
fastMAprevious = LSMA(FastMA_Period, FastPriceMode, i+2);

}
else
{
fastMAnow = iMA(NULL, 0, FastMA_Period, 0, FastMA_Mode, FastPriceMode, i+1);
fastMAprevious = iMA(NULL, 0, FastMA_Period, 0, FastMA_Mode, FastPriceMode, i+2);
}

if (SlowMA_Mode == 4)
{
slowMAnow = LSMA( SlowMA_Period, SlowPriceMode, i+1);
slowMAprevious = LSMA( SlowMA_Period, SlowPriceMode, i+2);
}
else
{
slowMAnow = iMA(NULL, 0, SlowMA_Period, 0, SlowMA_Mode, SlowPriceMode, i+1);
slowMAprevious = iMA(NULL, 0, SlowMA_Period, 0, SlowMA_Mode, SlowPriceMode, i+2);
}

if ((fastMAnow > slowMAnow) && (fastMAprevious < slowMAprevious)&& CrossUp[i+1]==0)
{
if (i == 1 && flagval1==0){ flagval1=1; flagval2=0; }
CrossUp[i+1] = Low - Range*0.75;
}
else if ((fastMAnow < slowMAnow) && (fastMAprevious > slowMAprevious)&& CrossDown[i+1]==0)
{
if (i == 1 && flagval2==0) { flagval2=1; flagval1=0; }
CrossDown[i+1] = High + Range*0.75;
}
}
if(SoundON && CrossUp[1]!=0.0 && !upalertsent)
{
Alert("BUY signal at Ask=",Ask,"\n Bid=",Bid,"\n Time=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\n Symbol=",Symbol()," Period=",Period());
upalertsent=true;
}
if(SoundON && CrossDown[1]!=0.0 && !downalertsent)
{
Alert("SELL signal at Ask=",Ask,"\n Bid=",Bid,"\n Date=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\n Symbol=",Symbol()," Period=",Period());
downalertsent=true;
}
if(EmailON && CrossUp[1]!=0.0 && !upemailsent)
{
SendMail("BUY signal alert","BUY signal at Ask="+DoubleToStr(Ask,4)+", Bid="+DoubleToStr(Bid,4)+", Date="+TimeToStr(CurTime(),TIME_DATE)+" "+TimeHour(CurTime())+":"+TimeMinute(CurTime())+" Symbol="+Symbol()+" Period="+Period());
upemailsent=true;
}
if(EmailON && CrossDown[1]!=0.0 && !downemailsent)
{
SendMail("SELL signal alert","SELL signal at Ask="+DoubleToStr(Ask,4)+", Bid="+DoubleToStr(Bid,4)+", Date="+TimeToStr(CurTime(),TIME_DATE)+" "+TimeHour(CurTime())+":"+TimeMinute(CurTime())+" Symbol="+Symbol()+" Period="+Period());
downemailsent=true;
}
if(CrossUp[1] ==0.0 && CrossDown[1] == 0.0)
{
upalertsent=false;
downalertsent=false;
upemailsent=false;
downemailsent=false;
}
/* if (flagval1==1 && CurTime() > GlobalVariableGet("AlertTime"+Symbol()+Period()) && GlobalVariableGet("SignalType"+Symbol()+Period())!=OP_BUY)
{
// if (GlobalVariableGet("LastAlert"+Symbol()+Period()) < 0.5)
// {
if (SoundON) Alert("BUY signal at Ask=",Ask,"\n Bid=",Bid,"\n Time=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\n Symbol=",Symbol()," Period=",Period());
if (EmailON) SendMail("BUY signal alert","BUY signal at Ask="+DoubleToStr(Ask,4)+", Bid="+DoubleToStr(Bid,4)+", Date="+TimeToStr(CurTime(),TIME_DATE)+" "+TimeHour(CurTime())+":"+TimeMinute(CurTime())+" Symbol="+Symbol()+" Period="+Period());
// }
tmp = CurTime() + (Period()-MathMod(Minute(),Period()))*60;
GlobalVariableSet("AlertTime"+Symbol()+Period(),tmp);
GlobalVariableSet("SignalType"+Symbol()+Period(),OP_SELL);
// GlobalVariableSet("LastAlert"+Symbol()+Period(),1);
}

if (flagval2==1 && CurTime() > GlobalVariableGet("AlertTime"+Symbol()+Period()) && GlobalVariableGet("SignalType"+Symbol()+Period())!=OP_SELL) {
// if (GlobalVariableGet("LastAlert"+Symbol()+Period()) > -0.5)
// {
if (SoundON) Alert("SELL signal at Ask=",Ask,"\n Bid=",Bid,"\n Date=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\n Symbol=",Symbol()," Period=",Period());
if (EmailON) SendMail("SELL signal alert","SELL signal at Ask="+DoubleToStr(Ask,4)+", Bid="+DoubleToStr(Bid,4)+", Date="+TimeToStr(CurTime(),TIME_DATE)+" "+TimeHour(CurTime())+":"+TimeMinute(CurTime())+" Symbol="+Symbol()+" Period="+Period());
// }
tmp = CurTime() + (Period()-MathMod(Minute(),Period()))*60;
GlobalVariableSet("AlertTime"+Symbol()+Period(),tmp);
GlobalVariableSet("SignalType"+Symbol()+Period(),OP_BUY);
// GlobalVariableSet("LastAlert"+Symbol()+Period(),-1);
}
*/
return(0);
}
Mk 9.23 - "....Wszystko możliwe jest dla tego kto wierzy".

Awatar użytkownika
marekpast
Stały bywalec
Stały bywalec
Posty: 40
Rejestracja: 03 sty 2011, 09:09

Re: Powiadomienie SMS o transakcji EA

Nieprzeczytany post autor: marekpast »

Hmmm, cos Ci sie zdublowało, czy cóś tak jakoś... :D :mrgreen:

Ale wracając do tematu.

Cały kod częstosci wysyłania jest w tym miejscu

if (flagval1==1 && CurTime() > GlobalVariableGet("AlertTime"+Symbol()+Period()) && GlobalVariableGet("SignalType"+Symbol()+Period())!=OP_BUY)
{
// if (GlobalVariableGet("LastAlert"+Symbol()+Period()) < 0.5)
// {
if (SoundON) Alert("BUY signal at Ask=",Ask,"\n Bid=",Bid,"\n Time=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\n Symbol=",Symbol()," Period=",Period());
if (EmailON) SendMail("BUY signal alert","BUY signal at Ask="+DoubleToStr(Ask,4)+", Bid="+DoubleToStr(Bid,4)+", Date="+TimeToStr(CurTime(),TIME_DATE)+" "+TimeHour(CurTime())+":"+TimeMinute(CurTime())+" Symbol="+Symbol()+" Period="+Period());
// }
tmp = CurTime() + (Period()-MathMod(Minute(),Period()))*60;
GlobalVariableSet("AlertTime"+Symbol()+Period(),tmp);
GlobalVariableSet("SignalType"+Symbol()+Period(),OP_SELL);
// GlobalVariableSet("LastAlert"+Symbol()+Period(),1);
}

if (flagval2==1 && CurTime() > GlobalVariableGet("AlertTime"+Symbol()+Period()) && GlobalVariableGet("SignalType"+Symbol()+Period())!=OP_SELL) {
// if (GlobalVariableGet("LastAlert"+Symbol()+Period()) > -0.5)
// {
if (SoundON) Alert("SELL signal at Ask=",Ask,"\n Bid=",Bid,"\n Date=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\n Symbol=",Symbol()," Period=",Period());
if (EmailON) SendMail("SELL signal alert","SELL signal at Ask="+DoubleToStr(Ask,4)+", Bid="+DoubleToStr(Bid,4)+", Date="+TimeToStr(CurTime(),TIME_DATE)+" "+TimeHour(CurTime())+":"+TimeMinute(CurTime())+" Symbol="+Symbol()+" Period="+Period());
// }
tmp = CurTime() + (Period()-MathMod(Minute(),Period()))*60;
GlobalVariableSet("AlertTime"+Symbol()+Period(),tmp);
GlobalVariableSet("SignalType"+Symbol()+Period(),OP_BUY);
// GlobalVariableSet("LastAlert"+Symbol()+Period(),-1);
}

ten kawałek kodu jest przetwarzany przy każdym ticku, powtarzam przy każdym ticku, nie jak piszesz przy świecy. Nie ma warunku na początku odwołania do funkcji typu 'is_new_bar '
ale aby wiadomość była wysłana muszą być spełnione trzy warunki, pierwszy zmienna flagvar musi przyjąć odpowiednia wartość, drugi - musi minąć czas wyliczany dla zmiennej tmp, trzeci to wygenerowany sygnał jest inny niż ten który wynika ze zmiennej flagvar.

Jeśli otrzymujesz więcej niż jedno powiadomienie w czasie jednego TF, to znaczy ze przedział gdzie następuje cross jest dość zmienny i mimo, że w trakcie danego TF zostal wygenerowany sygnał np. OP_BAY, musiały nastąpić nagłe zmiany notowań, które kasowały ten sygnał, np. chwilowy spadek notowania o 10p , który kasował flagę flagvar i sygnał OP_BAY, a co za tym idzie wyzerowaniu zmiennej tmp. Po ponownej zmianie warunków (wzrost notowań o 10p) ponownie jest generowany sygnał na ticku i ponownie spełnione są warunki i ponownie przetworzony jest powyższy kod , a co za tym idzie ponownie wysłana wiadomość. Tylko jedna - tak jak piszesz - na dany sygnał cross.

Zmienić to może tylko przeliczanie na już zamkniętej świecy, czyli na świecach i+1 i i+2 wtedy wygenerowany będzie tylko raz sygnał i tylko jedno powiadomienie, opóźnione o jeden TF.
Nie wiem czy Ci to będzie pasować.
______________________________
Pozdrawiam Marek

Awatar użytkownika
marek8
Gaduła
Gaduła
Posty: 288
Rejestracja: 26 lis 2011, 17:17

Re: Powiadomienie SMS o transakcji EA

Nieprzeczytany post autor: marek8 »

....A w tym kodzie poniżej jest to chyba rozwiązane chyba inaczej - ponieważ dodałem do niego tylko fragmenty jakie podałeś w poście wcześniej, które odpowiadają za podawanie treści smsa wszystkich danych z emaila i nie zauważyłem , żeby dawał więcej niż jeden alert na crossa.

//+------------------------------------------------------------------+
//| MA-Crossover_Alert.mq4 |
//| Copyright © 2005, Jason Robinson (jnrtrading) |
//| http://www.jnrtading.co.uk |
//| Modified by Robert Hill to add LSMA and alert or send email |
//| Added Global LastAlert to try to have alert only on new cross |
//| but does not seem to work. So indicator does alert every bar |
//+------------------------------------------------------------------+

/*
+------------------------------------------------------------------+
| Allows you to enter two ma periods and it will then show you at |
| Which point they crossed over. It is more usful on the shorter |
| periods that get obscured by the bars / candlesticks and when |
| the zoom level is out. Also allows you then to remove the mas |
| from the chart. (emas are initially set at 5 and 20) |
+------------------------------------------------------------------+
*/
#property copyright "Copyright © 2005, Jason Robinson (jnrtrading)"
#property link "http://www.jnrtrading.co.uk"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 LawnGreen
#property indicator_color2 Red

extern bool SoundON=true;
extern bool EmailON=true;

extern int FastMA_Mode = 1; //0=sma, 1=ema, 2=smma, 3=lwma, 4=lsma
extern int FastMA_Period = 5;
extern int FastPriceMode = 0;//0=close, 1=open, 2=high, 3=low, 4=median(high+low)/2, 5=typical(high+low+close)/3, 6=weighted(high+low+close+close)/4
extern int SlowMA_Mode = 1; //0=sma, 1=ema, 2=smma, 3=lwma, 4=lsma
extern int SlowMA_Period = 10;
extern int SlowPriceMode = 0;//0=close, 1=open, 2=high, 3=low, 4=median(high+low)/2, 5=typical(high+low+close)/3, 6=weighted(high+low+close+close)/4
double CrossUp[];
double CrossDown[];
int flagval1 = 0;
int flagval2 = 0;
bool downalertsent,upalertsent,downemailsent,upemailsent;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0, DRAW_ARROW, EMPTY, 1);
SetIndexArrow(0, 233);
SetIndexBuffer(0, CrossUp);
SetIndexEmptyValue(0,0.0);
SetIndexStyle(1, DRAW_ARROW, EMPTY, 1);
SetIndexArrow(1, 234);
SetIndexBuffer(1, CrossDown);
SetIndexEmptyValue(1,0.0);
GlobalVariableSet("AlertTime"+Symbol()+Period(),CurTime());
GlobalVariableSet("SignalType"+Symbol()+Period(),OP_SELLSTOP);
// GlobalVariableSet("LastAlert"+Symbol()+Period(),0);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
GlobalVariableDel("AlertTime"+Symbol()+Period());
GlobalVariableDel("SignalType"+Symbol()+Period());
// GlobalVariableDel("LastAlert"+Symbol()+Period());

//----
return(0);
}

//+------------------------------------------------------------------+
//| LSMA with PriceMode |
//| PrMode 0=close, 1=open, 2=high, 3=low, 4=median(high+low)/2, |
//| 5=typical(high+low+close)/3, 6=weighted(high+low+close+close)/4 |
//+------------------------------------------------------------------+

double LSMA(int Rperiod, int prMode, int shift)
{
int i;
double sum, pr;
int length;
double lengthvar;
double tmp;
double wt;

length = Rperiod;

sum = 0;
for(i = length; i >= 1 ; i--)
{
lengthvar = length + 1;
lengthvar /= 3;
tmp = 0;
switch (prMode)
{
case 0: pr = Close[length-i+shift];break;
case 1: pr = Open[length-i+shift];break;
case 2: pr = High[length-i+shift];break;
case 3: pr = Low[length-i+shift];break;
case 4: pr = (High[length-i+shift] + Low[length-i+shift])/2;break;
case 5: pr = (High[length-i+shift] + Low[length-i+shift] + Close[length-i+shift])/3;break;
case 6: pr = (High[length-i+shift] + Low[length-i+shift] + Close[length-i+shift] + Close[length-i+shift])/4;break;
}
tmp = ( i - lengthvar)*pr;
sum+=tmp;
}
wt = sum*6/(length*(length+1));

return(wt);
}


//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start() {
int limit, i, counter;
double tmp=0;
double fastMAnow, slowMAnow, fastMAprevious, slowMAprevious;
double Range, AvgRange;
int counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;

limit=Bars-counted_bars;

for(i = limit; i >= 0; i--) {

counter=i;
Range=0;
AvgRange=0;
for (counter=i ;counter<=i+9;counter++)
{
AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]);
}
Range=AvgRange/10;

if (FastMA_Mode == 4)
{
fastMAnow = LSMA(FastMA_Period, FastPriceMode, i+1);
fastMAprevious = LSMA(FastMA_Period, FastPriceMode, i+2);

}
else
{
fastMAnow = iMA(NULL, 0, FastMA_Period, 0, FastMA_Mode, FastPriceMode, i+1);
fastMAprevious = iMA(NULL, 0, FastMA_Period, 0, FastMA_Mode, FastPriceMode, i+2);
}

if (SlowMA_Mode == 4)
{
slowMAnow = LSMA( SlowMA_Period, SlowPriceMode, i+1);
slowMAprevious = LSMA( SlowMA_Period, SlowPriceMode, i+2);
}
else
{
slowMAnow = iMA(NULL, 0, SlowMA_Period, 0, SlowMA_Mode, SlowPriceMode, i+1);
slowMAprevious = iMA(NULL, 0, SlowMA_Period, 0, SlowMA_Mode, SlowPriceMode, i+2);
}

if ((fastMAnow > slowMAnow) && (fastMAprevious < slowMAprevious)&& CrossUp[i+1]==0)
{
if (i == 1 && flagval1==0){ flagval1=1; flagval2=0; }
CrossUp[i+1] = Low - Range*0.75;
}
else if ((fastMAnow < slowMAnow) && (fastMAprevious > slowMAprevious)&& CrossDown[i+1]==0)
{
if (i == 1 && flagval2==0) { flagval2=1; flagval1=0; }
CrossDown[i+1] = High + Range*0.75;
}
}
if(SoundON && CrossUp[1]!=0.0 && !upalertsent)
{
Alert("EMA BUY signal at Ask=",Ask,"\n Bid=",Bid," Time=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\n Symbol=",Symbol()," Period=",Period());
string message= "EMA BUY signal at Ask="+DoubleToStr(Ask,4)+", Bid="+DoubleToStr(Bid,4)+", Date="+TimeToStr(CurTime(),TIME_DATE)+" "+TimeHour(CurTime())+":"+TimeMinute(CurTime())+" Symbol="+Symbol()+" Period="+Period();
upalertsent=true;
}
if(SoundON && CrossDown[1]!=0.0 && !downalertsent)
{
Alert("EMA SELL signal at Ask=",Ask,"\n Bid=",Bid," Date=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\n Symbol=",Symbol()," Period=",Period());
string message2= "EMA SELL signal at Ask="+DoubleToStr(Ask,4)+", Bid="+DoubleToStr(Bid,4)+", Date="+TimeToStr(CurTime(),TIME_DATE)+" "+TimeHour(CurTime())+":"+TimeMinute(CurTime())+" Symbol="+Symbol()+" Period="+Period();

downalertsent=true;
}
if(EmailON && CrossUp[1]!=0.0 && !upemailsent)

SendMail(message,"");

if(EmailON && CrossDown[1]!=0.0 && !downemailsent)
SendMail(message2,"");
if(CrossUp[1] ==0.0 && CrossDown[1] == 0.0)
{
upalertsent=false;
downalertsent=false;
upemailsent=false;
downemailsent=false;
}
/* if (flagval1==1 && CurTime() > GlobalVariableGet("AlertTime"+Symbol()+Period()) && GlobalVariableGet("SignalType"+Symbol()+Period())!=OP_BUY)
{
// if (GlobalVariableGet("LastAlert"+Symbol()+Period()) < 0.5)
// {
if (SoundON) Alert("BUY signal at Ask=",Ask,"\n Bid=",Bid,"\n Time=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\n Symbol=",Symbol()," Period=",Period());
if (EmailON) SendMail("BUY signal alert","BUY signal at Ask="+DoubleToStr(Ask,4)+", Bid="+DoubleToStr(Bid,4)+", Date="+TimeToStr(CurTime(),TIME_DATE)+" "+TimeHour(CurTime())+":"+TimeMinute(CurTime())+" Symbol="+Symbol()+" Period="+Period());
// }
tmp = CurTime() + (Period()-MathMod(Minute(),Period()))*60;
GlobalVariableSet("AlertTime"+Symbol()+Period(),tmp);
GlobalVariableSet("SignalType"+Symbol()+Period(),OP_SELL);
// GlobalVariableSet("LastAlert"+Symbol()+Period(),1);
}

if (flagval2==1 && CurTime() > GlobalVariableGet("AlertTime"+Symbol()+Period()) && GlobalVariableGet("SignalType"+Symbol()+Period())!=OP_SELL) {
// if (GlobalVariableGet("LastAlert"+Symbol()+Period()) > -0.5)
// {
if (SoundON) Alert("SELL signal at Ask=",Ask,"\n Bid=",Bid,"\n Date=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\n Symbol=",Symbol()," Period=",Period());
if (EmailON) SendMail("SELL signal alert","SELL signal at Ask="+DoubleToStr(Ask,4)+", Bid="+DoubleToStr(Bid,4)+", Date="+TimeToStr(CurTime(),TIME_DATE)+" "+TimeHour(CurTime())+":"+TimeMinute(CurTime())+" Symbol="+Symbol()+" Period="+Period());
// }
tmp = CurTime() + (Period()-MathMod(Minute(),Period()))*60;
GlobalVariableSet("AlertTime"+Symbol()+Period(),tmp);
GlobalVariableSet("SignalType"+Symbol()+Period(),OP_BUY);
// GlobalVariableSet("LastAlert"+Symbol()+Period(),-1);
}
*/
return(0);
}
Mk 9.23 - "....Wszystko możliwe jest dla tego kto wierzy".

Awatar użytkownika
belzebub
Gaduła
Gaduła
Posty: 272
Rejestracja: 20 sty 2013, 12:28

Re: Powiadomienie SMS o transakcji EA

Nieprzeczytany post autor: belzebub »

Witam,
Czy może ktoś podpowiedzieć co trzeba dodać do EA, aby w terśic sms'a była para walutowa?
abym wiedział co kupiłem/sprzedałem:)
jeżeli nie ma dużo zamieszania to jeszcze czy jest buy czy sell:)

chodzi o prostotę wykonania np.: BUY eurusd

Pozdrawiam
"Poddający się - nigdy nie wygrywa, a wygrywający - nigdy się nie poddaje"

ODPOWIEDZ