Relative Strength showing negative numbers when using EMA on RelStrength

Hi fellow members, I have been trying to figure a problem I continuously face with RELSTRENGTH.

For now, I am just trying to get the exploration right and was wondering if anyone can help me where am I going wrong.

below is my exploration formula

Copy

WatchlistNum = 1;
Filter=1;

List = CategoryGetSymbols(categoryWatchlist, WatchlistNum);
for(i=0; (sym = StrExtract(List, i)) != "";i++)
{
	if(sym != Name())
	{
		r = RelStrength("NIFTY",fixup=1);
		relema = EMA(r,21);

		z=BarCount - 1;
	
}}

AddColumn(r, "Rel Strength");
AddColumn(relema, "EMA Rel");

The results I get are somehow not correct.

see screenshot below

image

I don't have data for the particular security pre-2010 but post that I have data and used fixup=1 to use close price for any days missing after 2010 yet my EMA calculation shows an absurd number. I can still live with the first 21 bars showing the absurd number but post that why is a simple EMA calculation continuing to show me a massively negative number?

I would appreciate if anyone can help me sort this issue cause many of the names in my watchlist show this problem and the entire system goes for a toss as it is relative strength based.

thanks in advance.

Gautam

You have Pad&Align turned on.
So if Avantifeed does not have data before 2010 where Nifty does have data then e.g. Close of Avantifeed is Null.

Filter = 1;

r = RelStrength( "NIFTY", fixup = 1 );
r = IIf( ! IsNull( C ), r, Null );
relema = EMA( r, 21 );

AddColumn( C, "Price" );
AddColumn( r, "Rel Strength" );
AddColumn( relema, "EMA Rel" );
1 Like

Dear,
For me I don't see any error in the code, and I have just copied and pasted your code , ran it and nothing abnormal relative strength or EMA.

Please keep sure that relema is not defined any where in case the code you have submitted is only a part of your original code.

1 Like

hi fxshrat, i do have pad and align turned on. yes i do realize avantifeed doesnt have data pre 2010 but starting Sep 2010 when there is data, i do get the Rel strength but when i try the 21 day EMA on the RS, i get the huge negative number. Like i mentioned on my post maybe cause of Null data the first 21 data points can show me the absurd calculation, but what about post 21 days/weeks, then it should ideally show correct EMA calculation. However thats not the case. Anyways thanks for your time, i appreciate the help so far. I'll try the code you have suggested and revert. cheers

thanks mohamed.gad,

i will recheck my code again and esp check for 'Please keep sure that relema is not defined any where in case the code you have submitted is only a part of your original code.'

thanks again for your time and help so far.

cheers