Hull Moving averages on relative chart wrong data values

dear all, I faced un-logical data values of moving averages when I used my custom relative chart.
when I plotted hull moving averages on the high field price of my custom relative chart found it lower than hull moving averages on the close field price of my custom relative chart and it does not make sense to find hull moving on high under hull moving averages on close field price.


bench = ParamStr( "Bench", "EGX30" );
fc = Foreign( bench, "C" );
fo = Foreign( bench, "O" );
fh = Foreign( bench, "H" );
fl = Foreign( bench, "L" );




C=C/fc*10000000;
O=O/fo*10000000;
H=H/fh*10000000;
L=L/fl*10000000;






SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );

Plot( HMA( H, 40 ), "HMA-on-High Field Prie", ParamColor( "HMA-on-High-Color", colorCycle ), ParamStyle("HMA-on-High-Style") ); 

Plot( HMA( C, 40 ), "HMH-on-Close Field Prie", ParamColor( "HMA-on-Close-Color", colorCycle ), ParamStyle("HMA-on-Close-Style") ); 

Is there any explanation about that issue? @Tomasz

@ahm.montaser Looking at your screenshot it seems that the High is lower than the Close:

image

So it is not surprising that the HMA does the same. Check the data used accurately in the Quote editor.
Moreover, I suggest using an exploration to verify all the values that are part of the calculations of the arrays passed to the HMA function.

To make the exploration results easier to understand, I suggest assigning/overriding the calculated values to the internal OHLC arrays using some temporary variables instead.

1 Like

I'm already applying all validation processes and I found any moving averages on the height of my relative chart lower than the same moving averages on the close of my relative chart, and that means, moving averages read incorrect data values of field prices, so there are any other workarounds to get a relative chart as my code @Tomasz @beppe

@beppe already gave you some good suggestions, for example creating new variables for your modified prices instead of trying to reuse the built-in OHLC variables, and adding an Exploration so you can see your calculated values. He also pointed out that in your own screenshot there is an example where the calculated Close is higher than the calculated High. This can happen because you are taking the original OHLC and dividing each of them by a different value (foreign OHLC), so now you cannot assume that the calculated (relative) high is greater than Open, Low, and Close, nor can you assume that the calculated (relative) low is less than Open, High, and Close.

Finally, it might be helpful for you to review this post: How do I debug my formula?

1 Like

hello dear, I'm trying to do all that several times to debug that issue!

and faced the same issue, that is my new code any advice? @beppe @mradtke @Tomasz

bench = ParamStr( "Bench", "EGX30" );
fc = Foreign( bench, "C" );
fo = Foreign( bench, "O" );
fh = Foreign( bench, "H" );
fl = Foreign( bench, "L" );


clos = C;
opn = O;
hig = H;
lo = L;





CLoser=clos/fc*10000000;
opener =opn/fo*10000000;
higher=hig/fh*10000000;
lower =lo/fl*10000000;





/*
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", opener, higher, lower, CLoser, SelectedValue( ROC( CLoser, 1 ) ) ));
Plot( c, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
*/

Plot( HMA( higher, 40 ), "HMA-on-High Field Prie", ParamColor( "HMA-on-High-Color", colorCycle ), ParamStyle("HMA-on-High-Style") ); 

Plot( HMA( CLoser, 40 ), "HMH-on-Close Field Prie", ParamColor( "HMA-on-Close-Color", colorCycle ), ParamStyle("HMA-on-Close-Style") ); 

You did half of what was suggested, and I think you still do not understand that your High Ratio is not always greater than your Close Ratio, which is what causes the Hull MA behavior you described.

You should add an Exploration so that you can see the values of your ratios. Something like this:

Filter = true;
AddColumn(closer, "Close Ratio");
AddColumn(opener, "OpenRatio");
AddColumn(higher, "High Ratio");
AddColumn(lower, "Low Ratio");

And if you want to specifically see how often the High Ratio is less than the Close Ratio, then change this:

Filter = true;

to this:

Filter = higher < closer;
1 Like

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.