PureBytes Links
Trading Reference Links
|
I need some help from the TS4 wizards out there.
I have an indicator that looks at the Stochastic value, and displays
a green or red dot depending on conditions. Specifically,
GreenDot = Stoch > Stoch[1] and Stoch < 30;
RedDot = Stoch < Stoch[1] and Stoch > 70;
In other words, if the Stoch is less than 30 AND increasing, the
green dot should display. If it's greater than 70 AND decreasing,
the red dot should display.
If I apply this indicator, it works exactly as it should on historic
data. But if I apply it on realtime data, **WITH** "Update Every
Tick" on, all bets are off. It displays entirely different results
from the same indicator with "Update Every Tick" turned off. If you
turn its status off and on again, the UET indicator CHANGES so it
matches the non-UET indicator -- until it starts plotting new data.
I know intra-bar stuff is a little flaky in TS, but I thought I
understood how it worked. TS4 has no "memory" within a bar. If you
do something like increment a variable and print it, you'll see it
prints the SAME VALUE on every tick until the bar closes. My
understanding was that they do this to AVOID exactly the kind of
problem I'm having -- i.e. so UET indicators show the same results as
non-UET indicators.
So, in theory, when running on every tick, this indicator should be
comparing the current value of Stoch with the value from the last
bar. The green dot should flash on or off as appropriate. Then,
when the bar closes, the green dot should "lock" on the same state as
a non-UET indicator shows. Instead, it appears to be comparing it to
the value of Stoch from the previous TICK. I think.
In any case, somehow CanBuy and CanSell get set **within** the bar,
even when Stoch is larger than on the previous bar, and the dots are
inappropriately displayed.
I want to update this indicator on every tick, but only if I can get
it to work properly. Can somebody explain to me what's going on?
Thanks,
Gary
vars: Stoch(0), GreenDot(False), RedDot(False);
Stoch = SlowK(20);
GreenDot = Stoch > Stoch[1] and Stoch < 30;
RedDot = Stoch < Stoch[1] and Stoch > 70;
if GreenDot then plot1(70, "Green");
if RedDot then plot2(30, "Red");
plot3(Stoch, "Stoch");
|