How to detect Heiken Ashi Body close above/below MA?

 

Hello,

I am newbie in MQL4. I would like to know how I could detected that Heiken Ashi Body close above/below MA?

 
if(close[1]>iMA[0])

{}
 
if(close[1]>iMA[0])

{}

I think this is Simple close[1] of last bar. How would I know that is Heiken Ashi Body is closing above/below MA 

 
kumaillakhani:

I think this is Simple close[1] of last bar. How would I know that is Heiken Ashi Body is closing above/below MA 

I have deleted your post in another topic that has been dormant for over 6 years. The topic starter is no longer active, so will not reply to you.

The reason for deleting it is so that there are not replies to the same question in different topics.

 
      double HA0=iCustom(_Symbol,0,"Heiken Ashi",2,x);
      double HA1=iCustom(_Symbol,0,"Heiken Ashi",3,x);

The above get the 2 values for buffers 2 and 3 for bar x, so if both are above the Ma, you will know that the body is above the MA.

 
Keith Watford:

The above get the 2 values for buffers 2 and 3 for bar x, so if both are above the Ma, you will know that the body is above the MA.

Thank you for the information you provided me. I have an understanding issue with iCustom function i.e: the 2nd last parameter is Mode what is mode I am not able to understand mode explained in documentation.

iCustom - Technical Indicators - MQL4 Reference
iCustom - Technical Indicators - MQL4 Reference
  • docs.mql4.com
[in]  Custom indicator compiled program name, relative to the root indicators directory (MQL4/Indicators/). If the indicator is located in subdirectory, for example, in MQL4/Indicators/ The passed parameters and their order must correspond with the declaration order and the type of extern variables of the custom indicator...
 

It's the (line)buffer you want to read it's value from.

 
Marco vd Heijden:

It's the (line)buffer you want to read it's value from.

double HA0=iCustom(_Symbol,0,"Heiken Ashi",2,x);

This will provide me HAOpen of current bar which is currently active?

 
kumaillakhani:

This will provide me HAOpen of current bar which is currently active?

Not necessarily. It is in the documentation..

shift

[in]  Index of the value taken from the indicator buffer (shift relative to the current bar the given amount of periods ago).

 
Keith Watford:

Not necessarily. It is in the documentation..

shift

[in]  Index of the value taken from the indicator buffer (shift relative to the current bar the given amount of periods ago).

Okay. But in the documentation:

mode

[in]  Line index. Can be from 0 to 7 and must correspond with the index, specified in call of the SetIndexBuffer() function.

According to documentation. I can use only 0 till 7 values 0 is for current candle and 7 is for 7th last candle and what if I want to access info older then 7th last candle?

for HAOpen I have to use 2?

for HALowI have to use 3?

and what if I want to HAHigh, HAClose?

SetIndexBuffer - Custom Indicators - MQL4 Reference
SetIndexBuffer - Custom Indicators - MQL4 Reference
  • docs.mql4.com
After binding, the dynamic array buffer[] will be indexed as in common arrays, even if the indexing of timeseries is pre-installed for the bound array. If you want to change the order of access to elements of the indicator array, use the ArraySetAsSeries() function...
 

[in]  Line index. Can be from 0 to 7 and must correspond with the index, specified in call of the SetIndexBuffer() function.

According to documentation. I can use only 0 till 7 values 0 is for current candle and 7 is for 7th last candle and what if I want to access info older then 7th last candle?

Line index can be much higher than 7 nowadays, documentation has not been updated.

Line index has nothing to do with candles. It is the buffer used in the indicator - Marco has already told you this.


for HAOpen I have to use 2?

for HALowI have to use 3?

and what if I want to HAHigh, HAClose?

Write a simple indicator, get the values and find out.

Put some effort in yourself. You will never learn anything if you don't study and try things.

SetIndexBuffer - Custom Indicators - MQL4 Reference
SetIndexBuffer - Custom Indicators - MQL4 Reference
  • docs.mql4.com
After binding, the dynamic array buffer[] will be indexed as in common arrays, even if the indexing of timeseries is pre-installed for the bound array. If you want to change the order of access to elements of the indicator array, use the ArraySetAsSeries() function...
Reason: