MA’s not Plotting Due To Length


Category:
0
0

Hello,

Currently, I am trying to just have moving averages plot all in one tidy study. However, Im running into an issue where the none of the plots work if a stock does not have the proper days for that avg (IPOs not having 50 trading days). I’ve tried to get around it a number of ways, but it seems as if the logic statements execute regardless of whether it is true or false and it doesnt graph my plot.

if barNumber() < 21 {

SMA21 = Average(price, 1);
short_SMA21 = double.nan;
} else {

SMA21 = Average(price,21);
short_SMA21 = SMA21;
}

This removes my other moving average plots if it returns true or false, which does not make sense to me. Apologies if this was already asked, I tried to search for it, but may have used the wrong filter words

 

Marked as spam
Posted by (Questions: 1, Answers: 1)
Asked on April 18, 2021 9:51 am
84 views
1
Private answer

Yes, this has been covered before in the forum. There is no way overcome this limitation in Thinkorswim and you will have to split the moving averages into separate chart studies so that when one of them fails due to insufficient historical data it will not cause all the others to fail along with it.

In the previous post we also attempted to use the bar number to try and control this behavior but it did not work and no workaround was identified.

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on April 18, 2021 3:58 pm
0
Appreciate it. Couldn't find the previous post so apologies for the double Question. Was hoping for a cool solution but as soon as the bar number wasn't working for me I figured it was a limitation. Have a great evening and thanks for your time n info
( at April 18, 2021 4:01 pm)