Notifications
Clear all

Indicator True Strength Index

ZaQ
 ZaQ
(@rhanz)
Active Member User

Can you please assist me. I am duplicating the True Strength Index and I am having problem with the signal line. 

The Signal Line is not showing. Below is the script.

Set Current_Price = Close
Set Previous_Price = REF(Close,1)

//Calculate Price Change and Absolute Price Change
Set Price_Change = Current_Price - Previous_Price
Set aPrice_Change = ABS(Current_Price - Previous_Price)

//Calculate 25 EMA of Price Change and 13 EMA of 25 EMA of Price Change
Set EMA_25 = EMA(Price_Change,25)
Set EMA_13 = EMA(EMA_25,13)

//Calculate 25 EMA of Absolute Price Change and 13 EMA of 25 EMA of Absolute Price Change
Set aEMA_25 = EMA(aPrice_Change,25)
Set aEMA_13 = EMA(aEMA_25,13)

//Calculate TSI & Signal Line
Set TSI = (EMA_13/aEMA_13) * 100
Set TSI_Signal = EMA(TSI,13)

//Plot TSI & Signal Line
Plot(TSI, line, blue, TSI1)
Plot(TSI_Signal, line, red, TSI1)

 

 

Thank you in advance!

ZaQ

 

Quote
Topic starter Posted : 04/05/2021 1:16 am
Mike
 Mike
(@vanguardai)
Co-Founder Admin

Hi, we noticed its working for higher periods for the signal line, we tested EMA(TS,25) and it works but not for lower periods. This bug has been noted and we'll have it fixed on the next release.

ReplyQuote
Posted : 04/05/2021 12:07 pm
snoperg
(@snoperg)
Admin Admin

Hi All,

 

Upon checking on this issue, the problem was caused by division of Zero in Set TSI = (EMA_13/aEMA_13) * 100. Initial value of aEMA_13 is zero.

The modified script below will work now:

Set Current_Price = Close
Set Previous_Price = REF(Close,1)

//Calculate Price Change and Absolute Price Change
Set Price_Change = Current_Price - Previous_Price
Set aPrice_Change = ABS(Current_Price - Previous_Price)

//Calculate 25 EMA of Price Change and 13 EMA of 25 EMA of Price Change
Set EMA_25 = EMA(Price_Change,25)
Set EMA_13 = EMA(EMA_25,13)

//Calculate 25 EMA of Absolute Price Change and 13 EMA of 25 EMA of Absolute Price Change
Set aEMA_25 = EMA(aPrice_Change,25)
Set aEMA_13 = EMA(aEMA_25,13)

//Calculate TSI & Signal Line
Set TSI =if(aEMA_13 <> 0, (EMA_13/aEMA_13) * 100,0)
Set TSI_Signal = EMA(TSI,13)

//Plot TSI & Signal Line
Plot(TSI, line, blue, TSI1)
Plot(TSI_Signal, line, red, TSI1)

ReplyQuote
Posted : 09/05/2021 2:37 pm
ZaQ
 ZaQ
(@rhanz)
Active Member User
Posted by: @snoperg

Hi All,

 

Upon checking on this issue, the problem was caused by division of Zero in Set TSI = (EMA_13/aEMA_13) * 100. Initial value of aEMA_13 is zero.

The modified script below will work now:

Set Current_Price = Close
Set Previous_Price = REF(Close,1)

//Calculate Price Change and Absolute Price Change
Set Price_Change = Current_Price - Previous_Price
Set aPrice_Change = ABS(Current_Price - Previous_Price)

//Calculate 25 EMA of Price Change and 13 EMA of 25 EMA of Price Change
Set EMA_25 = EMA(Price_Change,25)
Set EMA_13 = EMA(EMA_25,13)

//Calculate 25 EMA of Absolute Price Change and 13 EMA of 25 EMA of Absolute Price Change
Set aEMA_25 = EMA(aPrice_Change,25)
Set aEMA_13 = EMA(aEMA_25,13)

//Calculate TSI & Signal Line
Set TSI =if(aEMA_13 <> 0, (EMA_13/aEMA_13) * 100,0)
Set TSI_Signal = EMA(TSI,13)

//Plot TSI & Signal Line
Plot(TSI, line, blue, TSI1)
Plot(TSI_Signal, line, red, TSI1)

 

Thank you!

ReplyQuote
Topic starter Posted : 09/05/2021 9:39 pm
Share: