Boston, MA USA
Posts: 2 since May 2014
Thanks Given: 0
Thanks Received: 0
|
Hey everybody, I have a little problem with my thinkorswim script.
I tweaked the Symbol Relation study from TOS and added a simple moving average to it.
However, SMA is not displayed right after the open - and the higher is the length of SMA - the longer it takes to appear on the chart.
I would really appreciate, if someone could help me with this and fix it....
Thanks..
_________
script:
declare lower;
input price = FundamentalType.CLOSE;
input relationWithSecurity = "VXX";
input length = 9;
input displace = 0;
def price1 = fundamental(price);
def price2 = fundamental(price, relationWithSecurity);
plot Relation = if price2 == 0 then Double.NaN else price2 / price1;
Relation.SetDefaultColor(GetColor(1));
plot SMA = Average(Relation[-displace], length);
SMA.SetDefaultColor(GetColor(5));
screenshot (can't post links - remove the spaces...)
ht t p : // tinypic. com /r / migl94 /8
On the left side I have SPY chart with SMA(60); on the right SMA(9)
I want SMA to be displayed right off the open - for some reason it does not appear.
Thanks.
P.S.
Each +1 in length of SMA shortens it. I wonder what's the reason for that.
For some reason 5-minute chart gets the longest MA...
|