Add alert + email + place tardes Zigzig indicator - page 7

 
rg1983:

You are totally right!

I have another request if possible : how can i get the ihighest and the ilowesr of a specific range example from 7pm to 1am asian session EST time 1 hour timeframe.

I tried with High[ihighest(ibarshift) it works when i fix count and start. But when hour change for example from 8am to 9am the count of bars changes so ihighest and ilowest value change accordingly.

Is there a way to store the first highest and ilowest values calculated and use them later on a condition or other functions? Thanks in advance

You have to get the bars numbers that you want to be tested and then you test only those bars

 
mladen:
You have to get the bars numbers that you want to be tested and then you test only those bars

Thanks ! I get it

in my condition I specify the hour() and then apply the High(Ihighest)

for example it is 8am , I count 7 and start testing at 7 bars

if it is 9am , I count 8 and start testing at 7 bars

if it is 10am , I count 9 and start testing at 7 bars

and so on ...

Or I can loop for example i = 0 to i=24

and then apply it in my fuction if hour() = i , in my fuction i count from i +1 and start testing at 7 ( fixed 7 bars to test high and low)

Brilliant !!what do you think ?

 
rg1983:

Thanks ! I get it

in my condition I specify the hour() and then apply the High(Ihighest)

for example it is 8am , I count 7 and start testing at 7 bars

if it is 9am , I count 8 and start testing at 7 bars

if it is 10am , I count 9 and start testing at 7 bars

and so on ...

Or I can loop for example i = 0 to i=24

and then apply it in my fuction if hour() = i , in my fuction i count from i +1 and start testing at 7 ( fixed 7 bars to test high and low)

Brilliant !!what do you think ?

The second solution is better

 

Hello !

Is it possible to add an alert with email to this indicator ?

Maybe this does aleready exist ?

Files:
i_xo_a_h.mq4  3 kb
 
smoulin500:
Hello !

Is it possible to add an alert with email to this indicator ?

Maybe this does aleready exist ?

smoulin500

Try out this one : i_xo_a_h_mtfalerts_nmc.mq4

 

Thanx a lot !!! You re wonderful Mladen !!! Thanx !! Thanx !!!

 
mladen:

henrykfx

That indicator is renamed SHI silver trend signal (this one : shi_silvertrendsig.mq4 ). And yes : it repaints (heavily) which makes it unsuitable for alerts

Thanks for your support

 

Hi mladen ,

Happy new year , all the best I hope you are doing well!

I tried to include the values generated by my below custom indicator in my expert advisors , it works but sometime it gives a wrong values

any advices!!.

I have included in my void ontick() the below codes :

Code I have included in my EA:

double Buffer1=iCustom(NULL,0,"myindicator",0,0);

double Buffer2=iCustom(NULL,0,"myindicator",1,0);

Print(Buffer1 , Buffer2);

The indicator Code:

#include

#include

//--- indicator settings

#property indicator_chart_window

#property indicator_buffers 2

#property indicator_type1 DRAW_ARROW

#property indicator_width1 2

#property indicator_color1 0x2BFF00

#property indicator_label1 "Buy"

#property indicator_type2 DRAW_ARROW

#property indicator_width2 2

#property indicator_color2 0x3700FF

#property indicator_label2 "Sell"

//--- indicator buffers

double Buffer1[];

double Buffer2[];

datetime time_alert; //used when sending alert

extern bool Send_Email = true;

extern bool Audible_Alerts = true;

double myPoint; //initialized in OnInit

void myAlert(string type, string message)

{

if(type == "print")

Print(message);

else if(type == "error")

{

Print(type+" | @ "+Symbol()+","+Period()+" | "+message);

}

else if(type == "order")

{

}

else if(type == "modify")

{

}

else if(type == "indicator")

{

if(Audible_Alerts) Alert(type+" | @ "+Symbol()+","+Period()+" | "+message);

if(Send_Email) SendMail("test", type+" | @ "+Symbol()+","+Period()+" | "+message);

}

}

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

//| Custom indicator initialization function |

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

int OnInit()

{

IndicatorBuffers(2);

SetIndexBuffer(0, Buffer1);

SetIndexEmptyValue(0, 0);

SetIndexArrow(0, 241);

SetIndexBuffer(1, Buffer2);

SetIndexEmptyValue(1, 0);

SetIndexArrow(1, 242);

//initialize myPoint

myPoint = Point();

if(Digits() == 5 || Digits() == 3)

{

myPoint *= 10;

}

return(INIT_SUCCEEDED);

}

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

//| Custom indicator iteration function |

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

int OnCalculate(const int rates_total,

const int prev_calculated,

const datetime& time[],

const double& open[],

const double& high[],

const double& low[],

const double& close[],

const long& tick_volume[],

const long& volume[],

const int& spread[])

{

int limit = rates_total - prev_calculated;

//--- counting from 0 to rates_total

ArraySetAsSeries(Buffer1, true);

ArraySetAsSeries(Buffer2, true);

//--- initial zero

if(prev_calculated < 1)

{

ArrayInitialize(Buffer1, 0);

ArrayInitialize(Buffer2, 0);

}

else

limit++;

//--- main loop

for(int i = limit-1; i >= 0; i--)

{

if (i >= MathMin(5000-1, rates_total-1-50)) continue; //omit some old rates to prevent "Array out of range" or slow calculation

//Indicator Buffer 1

if(iCCI(NULL, PERIOD_CURRENT, 20, PRICE_TYPICAL, i) > 100

&& iCCI(NULL, PERIOD_CURRENT, 20, PRICE_TYPICAL, i+1) < 100 //Commodity Channel Index crosses above fixed value

)

{

Buffer1 = Low; //Set indicator value at Candlestick Low

if(i == 0 && Time[0] != time_alert) { myAlert("indicator", "Buy"); time_alert = Time[0]; } //Instant alert, only once per bar

}

//Indicator Buffer 2

if(iCCI(NULL, PERIOD_CURRENT, 20, PRICE_TYPICAL, i) < -100

&& iCCI(NULL, PERIOD_CURRENT, 20, PRICE_TYPICAL, i+1) > -100 //Commodity Channel Index crosses below fixed value

)

{

Buffer2 = High; //Set indicator value at Candlestick High

if(i == 0 && Time[0] != time_alert) { myAlert("indicator", "Sell"); time_alert = Time[0]; } //Instant alert, only once per bar

}

}

return(rates_total);

}

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

 
rg1983:
Hi mladen ,

Happy new year , all the best I hope you are doing well!

I tried to include the values generated by my below custom indicator in my expert advisors , it works but sometime it gives a wrong values

any advices!!.

I have included in my void ontick() the below codes :

Code I have included in my EA:

double Buffer1=iCustom(NULL,0,"myindicator",0,0);

double Buffer2=iCustom(NULL,0,"myindicator",1,0);

Print(Buffer1 , Buffer2);

The indicator Code:

#include

#include

//--- indicator settings

#property indicator_chart_window

#property indicator_buffers 2

#property indicator_type1 DRAW_ARROW

#property indicator_width1 2

#property indicator_color1 0x2BFF00

#property indicator_label1 "Buy"

#property indicator_type2 DRAW_ARROW

#property indicator_width2 2

#property indicator_color2 0x3700FF

#property indicator_label2 "Sell"

//--- indicator buffers

double Buffer1[];

double Buffer2[];

datetime time_alert; //used when sending alert

extern bool Send_Email = true;

extern bool Audible_Alerts = true;

double myPoint; //initialized in OnInit

void myAlert(string type, string message)

{

if(type == "print")

Print(message);

else if(type == "error")

{

Print(type+" | @ "+Symbol()+","+Period()+" | "+message);

}

else if(type == "order")

{

}

else if(type == "modify")

{

}

else if(type == "indicator")

{

if(Audible_Alerts) Alert(type+" | @ "+Symbol()+","+Period()+" | "+message);

if(Send_Email) SendMail("test", type+" | @ "+Symbol()+","+Period()+" | "+message);

}

}

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

//| Custom indicator initialization function |

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

int OnInit()

{

IndicatorBuffers(2);

SetIndexBuffer(0, Buffer1);

SetIndexEmptyValue(0, 0);

SetIndexArrow(0, 241);

SetIndexBuffer(1, Buffer2);

SetIndexEmptyValue(1, 0);

SetIndexArrow(1, 242);

//initialize myPoint

myPoint = Point();

if(Digits() == 5 || Digits() == 3)

{

myPoint *= 10;

}

return(INIT_SUCCEEDED);

}

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

//| Custom indicator iteration function |

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

int OnCalculate(const int rates_total,

const int prev_calculated,

const datetime& time[],

const double& open[],

const double& high[],

const double& low[],

const double& close[],

const long& tick_volume[],

const long& volume[],

const int& spread[])

{

int limit = rates_total - prev_calculated;

//--- counting from 0 to rates_total

ArraySetAsSeries(Buffer1, true);

ArraySetAsSeries(Buffer2, true);

//--- initial zero

if(prev_calculated < 1)

{

ArrayInitialize(Buffer1, 0);

ArrayInitialize(Buffer2, 0);

}

else

limit++;

//--- main loop

for(int i = limit-1; i >= 0; i--)

{

if (i >= MathMin(5000-1, rates_total-1-50)) continue; //omit some old rates to prevent "Array out of range" or slow calculation

//Indicator Buffer 1

if(iCCI(NULL, PERIOD_CURRENT, 20, PRICE_TYPICAL, i) > 100

&& iCCI(NULL, PERIOD_CURRENT, 20, PRICE_TYPICAL, i+1) < 100 //Commodity Channel Index crosses above fixed value

)

{

Buffer1 = Low; //Set indicator value at Candlestick Low

if(i == 0 && Time[0] != time_alert) { myAlert("indicator", "Buy"); time_alert = Time[0]; } //Instant alert, only once per bar

}

//Indicator Buffer 2

if(iCCI(NULL, PERIOD_CURRENT, 20, PRICE_TYPICAL, i) < -100

&& iCCI(NULL, PERIOD_CURRENT, 20, PRICE_TYPICAL, i+1) > -100 //Commodity Channel Index crosses below fixed value

)

{

Buffer2 = High; //Set indicator value at Candlestick High

if(i == 0 && Time[0] != time_alert) { myAlert("indicator", "Sell"); time_alert = Time[0]; } //Instant alert, only once per bar

}

}

return(rates_total);

}

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

When you say "sometimes it gives wrong values" : what does that mean exactly?

 


rghanmi:

Hi My friends,

I hope you are doing well!

I'm looking to add an alert and email notification when arrows produced by the indicator. I tried with Alert("Indicator set"); with no succus

I want also to place automatic trades :

When Green arrows place a buy order and take profit at value of red arrows

When Red arrows place a sell order and take profit at value of green arrows

your help will be so much appreciated.

Many thanks


hi,

this indicator make my metatrader too slow.

can you help me?

thanks

Reason: