As I understand the code, a candle that is not an inside bar gets a value of EMPTY_VALUE and the test HighBuffer[1] > 0 should not execute the if statement (alert). <--------- No, this is wrong.
if (HighBuff[TriggerCandle] > 0) { //========== }
In mql4, EMPTY_VALUE = 2147483647 ( = INT_MAX, that is, the maximal value, which can be represented by an int type variable). Obviously this value is greater than zero.
EMPTY_VALUE |
Empty value in an indicator buffer. Default custom indicator empty value |
2147483647 (0x7FFFFFFF) |
Source Link: https://docs.mql4.com/constants/namedconstants/otherconstants
Therefore, your condition will always be true (HighBuff[1] is always > 0, since, if it takes some other value, normally this value will be greater than 0, and if it takes the EMPTY_VALUE, it is also greater than 0) , that is why it always produces the alert.
You could change your condition to something like this:
if (HighBuff[TriggerCandle] < EMPTY_VALUE) { //========== }
Regards.
- docs.mql4.com
Thank you I have written it again and it seems to work.
Thank you I have written it again and it seems to work.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I am trying to include an alert into an inside bar indicator but I can't get it to work.
I do get an alert, (which is what I am focusing on right now). There are also no errors in the compiler.
However, what I want to achieve:
What I get:
What I assume is that since a new bar always starts as an inside bar this prompts the alert. What I don't get is that I am using HighBuffer[1] so it should focus only on the second candle not the current.
Also it could be that the Buffer is drawn to a candle while it is in the current state. However, since I am using HighBuffer[1] not HighBuffer[0] I don't see why this should matter.
It could be another problem I don't see, because I'm not so familiar with programming.
As I understand the code, a candle that is not an inside bar gets a value of EMPTY_VALUE and the test HighBuffer[1] > 0 should not execute the if statement (alert). Somehow it does.
//At the end of the onCalculate function
This is the code I was using.
The indicator I am using is from Tecciztecatl's inside bar indicator.
https://www.mql5.com/en/code/16533
I hope someone can help
Best,
Paul