Converting a Heikin Ashi related PineScript to MQL5

Converting a Heikin Ashi related PineScript to MQL5

Manage alerts

Loading saved threads...

Bucky · External communityPost link
External question — Stack Overflow Stack Exchange Author: Bucky Original post: https://stackoverflow.com/questions/66851137 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. The pinescript code is like the following ha = heikinashi(tickerid) ha_close = security(ha, res, close[1]) ma = ema(ha_close[1], 30) I'm trying to use the above code in MetaTrader5. So I tried the following, [ Using https://www.mql5.com/en/code/33 for getting Heikin Ashi values ] int handleHA = iCustom(_Symbol,PERIOD_CURRENT,"Heiken Ashi"); Then I got the CLOSE buffer value, Which is at the 4th position, double haArray[]; CopyBuffer(handleHA,3,1,5,haArray); And then I got the EMA of those CLOSE values, int handleEMA = iMA(_Symbol,PERIOD_CURRENT,30,0,MODE_EMA,haArray[1]); CopyBuffer(handleEMA,0,1,5,emaArray); But in Metatrader 5 I'm getting different results compared to the TradingView. I think I did the first and third step right. But I have doubts on how I wrote ha_close = security(ha, res, close[1]) in MQL5. Need help :(
Quote
Report
TNBrian · External communityPost link
External answer — Stack Overflow Stack Exchange Author: TNBrian Original post: https://stackoverflow.com/a/79480159 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. You are taking the MA of the regular price value, not of the Heikinashi values. you can't just call an iMA function to generate an MA like that. It would look at normal price values, not heikinashi values. Either look for a heikinashi smoothed indicator. or modify the indicator. Put EMA code in the EA that can take an array of values and make your own EMA without the iMA function. You will need to write or copy code that takes the heikinashi values as input, then smooths them with an ema code.
Quote
Report

Post Reply

Checking account access…
Converting a Heikin Ashi related PineScript to MQL5 | Forex.com.bd