Please kindly help me with Adding Alert to Indicator

itunufolo

Trader
May 23, 2021
1
0
6
37
Please i tried for many days trying to add alert to this YangTrader for mt4 . But i was not able to make alerts trigger . it is a line indicator .. i followed all your steps on https://www.earnforex.com/blog/how-to-add-alerts-to-metatrader-indicators/

i wanted the alert to trigger : buy @ level above >55
Sell @ level below <45

i have attached both my attempts : Yang Alert attemps & YangTrader Original ( No alert added)

Please help me Add it ....... PLEASE
 

Attachments

Last edited:

Enivid

Administrator
Staff member
Nov 30, 2008
15,998
803
144
Odessa
www.earnforex.com
At no place in the tutorial there is a suggestion to compare TriggerCandle with 50.

Also, you have to get your requirements to the alerts straight. Here, in the post, you write that you want alerts when the indicator is > 55 or below < 45, but your code seems to be looking for a cross of some level (though incorrectly).
 

swigga

Newbie
Jun 18, 2021
4
0
1
27
I am in search of anyone that can code a verticle rectangle box indicator that can cover/block off candlesticks on the hard right edge of mt4 platform? any interaction will be appreciated.
 

hayseed

Master Trader
Jul 27, 2010
555
157
109
usa
it would help to know just how many candles you are talking about covering..... the script below goes in the scripts folder......
//-------

it uses the highest high and lowest low during the period back set by bar......

it will change the chart fore/back ground setting.....

it first deletes prior rectangle of same name.....

color is selectable......

it is draggable....

it is simple......h
//------
nzdusdts-d1-topstepfx-rect.png
 

Attachments

  • Like
Reactions: Enivid

Enivid

Administrator
Staff member
Nov 30, 2008
15,998
803
144
Odessa
www.earnforex.com
I think you should either get rid of this condition (and apply some time variable check to avoid multiple alerts from the same bar):
MQL5:
   if(prev_calculated!=rates_total)
Or you should change rates_total-1 to rates_total-2 here:
MQL5:
if(VendaBuffer[rates_total-1]!=EMPTY_VALUE)
and here:
MQL5:
if(CompraBuffer[rates_total-1]!=EMPTY_VALUE)
Because currently it works like this: a new bar arrives and the alert code is checked on it, but the bar is just 1 tick old - it has Open = High = Low = Close, so the indicator value likely remains equal EMPTY_VALUE. A bit later, when the indicator value gets updated, the initial prev_calculated!=rates_total fails because it is no longer a new bar, hence no alerts get issued.

If you apply the second change (rates_total-1 to rates_total-2) it will be checking only fully completed bars (so, the one just before the current bar) for alerts.
 

Panunes

Newbie
Mar 5, 2021
3
0
2
36
I think you should either get rid of this condition (and apply some time variable check to avoid multiple alerts from the same bar):
MQL5:
   if(prev_calculated!=rates_total)
Or you should change rates_total-1 to rates_total-2 here:
MQL5:
if(VendaBuffer[rates_total-1]!=EMPTY_VALUE)
and here:
MQL5:
if(CompraBuffer[rates_total-1]!=EMPTY_VALUE)
Because currently it works like this: a new bar arrives and the alert code is checked on it, but the bar is just 1 tick old - it has Open = High = Low = Close, so the indicator value likely remains equal EMPTY_VALUE. A bit later, when the indicator value gets updated, the initial prev_calculated!=rates_total fails because it is no longer a new bar, hence no alerts get issued.

If you apply the second change (rates_total-1 to rates_total-2) it will be checking only fully completed bars (so, the one just before the current bar) for alerts.
thank you, it worked
 

swigga

Newbie
Jun 18, 2021
4
0
1
27
I am in search of anyone that can code a verticle rectangle box indicator that can cover/block off candlesticks on the hard right edge of mt4 platform? any interac
it would help to know just how many candles you are talking about covering..... the script below goes in the scripts folder......
//-------

it uses the highest high and lowest low during the period back set by bar......

it will change the chart fore/back ground setting.....

it first deletes prior rectangle of same name.....

color is selectable......

it is draggable....

it is simple......h
//------
nzdusdts-d1-topstepfx-rect.png
Good day, thank you for the reply. With regards to the box, my intention is for the rectangular box to cover the whole right hight hand edge of mt4 platform, with a width of 40candles. the heght of the box would then be edge to edge from top to bottom regardles of the timeframe. If i was to change timeframes the box would still be on my right hand edge covering a width of 40candles top to bottom. The goal of the rectangular box is for when I'm looking at previous years price action, it covers 40candle width at right hand, so that I am then able to project future price movement candle by candle using F12. Currently my OCD makes it hard for me just to use my mt4 platform as is. The box gives my mind that future price still has to come. I acknowledge I wasnt clear in my discription on the first post.
 
Last edited:

hayseed

Master Trader
Jul 27, 2010
555
157
109
usa
Can the box settings be changed i.e height width?
yes, but probably not in the manner you are wanting.....

that is just a simple example of a way to cover/block off candlesticks on the hard right edge......

to adjust the width or height, click or double click on the rectangle to select it.... once selected, click and hold on any of the corners and drag out or up....

clicking and holding on the center squares allows you to move the square around.......

other than that, there is not much which can be done as the code is quite simple without adjustments......h
//-----

nzdusdts-d1-equiti-capital-uk-height.png
 

Enivid

Administrator
Staff member
Nov 30, 2008
15,998
803
144
Odessa
www.earnforex.com
Hi I followed the tutorial to add alerts but alert is not triggering alerts. I am not sure of what i did wrong.
When accessing bufferUp and bufferDown values, you don't need to use [rates_total - 1 - TriggerCandle] selector, use [TriggerCandle] instead. That's because they are set as series in the indicator's initialization function.
 

pkoolc1

Active Trader
Feb 26, 2012
12
0
32
When accessing bufferUp and bufferDown values, you don't need to use [rates_total - 1 - TriggerCandle] selector, use [TriggerCandle] instead. That's because they are set as series in the indicator's initialization function.
Thank very much, if i change the trigger candle to 1 it does not give an alert.
 

pkoolc1

Active Trader
Feb 26, 2012
12
0
32
The indicators buffers are shifted 2 bars to the left, so the latest meaningful value there can only be at index 2. Try setting TriggerCandle to 2.
Yes when it is set to 2 it does give alert, how can i set it so it can give alert from when the trigger is set to 1
 

swigga

Newbie
Jun 18, 2021
4
0
1
27
it would help to know just how many candles you are talking about covering..... the script below goes in the scripts folder......
//-------

it uses the highest high and lowest low during the period back set by bar......

it will change the chart fore/back ground setting.....

it first deletes prior rectangle of same name.....

color is selectable......

it is draggable....

it is simple......h
//------
nzdusdts-d1-topstepfx-rect.png
yes, but probably not in the manner you are wanting.....

that is just a simple example of a way to cover/block off candlesticks on the hard right edge......

to adjust the width or height, click or double click on the rectangle to select it.... once selected, click and hold on any of the corners and drag out or up....

clicking and holding on the center squares allows you to move the square around.......

other than that, there is not much which can be done as the code is quite simple without adjustments......h
//-----

nzdusdts-d1-equiti-capital-uk-height.png
okay, I understand, however, the indicator doesn't want to open on my mt4. when I add by ''Ctrl+N'' it doesn't do anything. when I manually try to insert it going through the thru top-down menu it does the same thing. Nothing. And thank you for your effort.