I'm sorry, I wasn't on the right mind when giving you that advice.
Although it still can be done using array of ma (ma[]) but this one is easier.
Your code should be like this
#propertyindicator_separate_window#propertyindicator_buffers1#propertyindicator_color1Red//---- input parametersexternintMA1_Period=5;
externintMA2_Period=30;
//---- buffersdoubleExtMapBuffer1[];
//+------------------------------------------------------------------+//| Custom indicator initialization function |//+------------------------------------------------------------------+intinit(){//---- indicatorsSetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtMapBuffer1);
//----return(0);
}//+------------------------------------------------------------------+//| Custom indicator deinitialization function |//+------------------------------------------------------------------+intdeinit(){//----//----return(0);
}//+------------------------------------------------------------------+//| Custom indicator iteration function |//+------------------------------------------------------------------+intstart(){intcounted_bars=IndicatorCounted();
inti, maxlimit=Bars-counted_bars;
for(i=0; i<maxlimit; i++){doublema1=iMA(Symbol(),0,MA1_Period,0,0,PRICE_CLOSE,i); // SMA of MA1_Period on Price_closedoublema2=iMA(Symbol(),0,MA2_Period,0,0,PRICE_CLOSE,i); // SMA of MA2_Period on Price_closeExtMapBuffer1[i]=(ma1-ma2)/Point;
}//----//----return(0);
}//+------------------------------------------------------------------+
It's very simple, you can do it by yourself after this.
Hey guys, I really need to figure this out, and I need help, I have managed to add levels, but how to I set an alert or sendmail when the level has been crossed.
thanks
If you feel like hinting me instead of helping, just tell me what functions to use, I know it is supposed to look something like this
if ??????????? > 10 ()sendmail blah blah blah
but where do i put it does it need separate brackets and what am i calling on?
#propertyindicator_level110.0#propertyindicator_level2 -10.0#propertyindicator_separate_window#propertyindicator_buffers1#propertyindicator_color1Green#propertyindicator_levelcolorBlue//---- input parametersexternintMA1_Period=5;
externintMA2_Period=30;
//---- buffersdoubleExtMapBuffer1[];
//+------------------------------------------------------------------+//| Custom indicator initialization function |//+------------------------------------------------------------------+intinit(){//---- indicatorsSetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtMapBuffer1);
//----return(0);
}//+------------------------------------------------------------------+//| Custom indicator deinitialization function |//+------------------------------------------------------------------+intdeinit(){//----//----return(0);
}//+------------------------------------------------------------------+//| Custom indicator iteration function |//+------------------------------------------------------------------+intstart(){intcounted_bars=IndicatorCounted();
inti, maxlimit=Bars-counted_bars;
for(i=0; i<maxlimit; i++){doublema1=iMA(Symbol(),0,MA1_Period,0,1,PRICE_CLOSE,i); // SMA of MA1_Period on Price_closedoublema2=iMA(Symbol(),0,MA2_Period,0,1,PRICE_CLOSE,i); // SMA of MA2_Period on Price_closeExtMapBuffer1[i]=(ma1-ma2)/Point;
if(ExtMapBuffer1[i]>10 && ExtMapBuffer1[i+1]<=10){SendMail("Spread Changed", "Above 10");
}}//----//----return(0);
}//+------------------------------------------------------------------+
Considering that I need this indicator for both directions (long/short), I want
it to be triggered by a value of > 10 or <-10 because the -10 is the same
indicator for a downwards trend,
Does this make any sense?
My 2nd question is how to reverse it to send an alert when it is back below or
above this level,
I also noticed a strange comment in the Journal "Mail: not enough space for
'Spread Changed'" I hope this has nothing to do with the code,
It now appears that the message is being sent repeatedly maybe this is cloging
the mail queue, see this link https://www.mql5.com/en/forum/46481
so it will make more sense to only have the message sent one time when it crosses
the levels in either direction, and a message when it crosses back.
I have restarted the terminal and I can confirm that,
a) It was the MAIL problem mentioned in the above link about an over flooded queue
in the outbox.
b) I received 42 messages in 1 minute.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Although it still can be done using array of ma (ma[]) but this one is easier.
Your code should be like this
It's very simple, you can do it by yourself after this.
It works great, I appreciate your help.
Now I would like to add a sendmail( ) function or trigger an alert when this indicator goes above or below a given value.
I don't know where to place it, or how to write the condition for the value filter
Also how do I add a arrow or mark on the chart when it reaches the given value
Thanks
I have managed to add levels, but how to I set an alert or sendmail when the level has been crossed.
thanks
If you feel like hinting me instead of helping, just tell me what functions to use, I know it is supposed to look something like this
if ??????????? > 10 ()sendmail blah blah blah
but where do i put it does it need separate brackets and what am i calling on?
thanks for all
I've never code any sendmail feature before, so don't ask me about the rest.
Hope this helps.
This is what I now have,
Considering that I need this indicator for both directions (long/short), I want it to be triggered by a value of > 10 or <-10 because the -10 is the same indicator for a downwards trend,
Does this make any sense?
My 2nd question is how to reverse it to send an alert when it is back below or above this level,
I also noticed a strange comment in the Journal "Mail: not enough space for 'Spread Changed'" I hope this has nothing to do with the code,
It now appears that the message is being sent repeatedly maybe this is cloging the mail queue, see this link https://www.mql5.com/en/forum/46481
so it will make more sense to only have the message sent one time when it crosses the levels in either direction, and a message when it crosses back.
Thanks for your time.
a) It was the MAIL problem mentioned in the above link about an over flooded queue in the outbox.
b) I received 42 messages in 1 minute.
thanks