[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Passing values to an indicator via text boxes



PureBytes Links

Trading Reference Links

Two programs cannot normally communicate with each other. so a
strategy cannot normally communicate with an indicator. To do this
you need a "global variable" that is accessible by both programs.

There are several global variable add-ons packages available for
TradeStation including GlobalPro and HashNums. A free one called
PushPop by Robert Linders is available on the www.traders2traders.com
web site.

When loading a chart, TradeStation first runs one program from
CurrentBar = 1 to the most recent bar, then runs the next program
from CurrentBar = 1 to the most recent bar. etc. So to pass a
variable between the two, you need to save a value of each variable
for every bar so that the next program can find it when it needs it.

You also need to load the program generating the values before you
run the program that uses it. Obviously, you can only pass data from
the first program to the second and not from the second to the first.
But since indicators can use functions that tell the conditions of
the strategy, indicators are rerun after a strategy is loaded even if
the indicator is loaded first.

In real time, the operation is different. In that case, when a new
bar is completed based upon time or number of ticks, the program
using that bar will be run through all the code for that new bar. If
the two programs are both using, say, 10 minute bars, then when a
10-minute bar is completed both programs will be run. The strategy
probably has to run first since indicators may call functions that
check the state of the strategy. You need to have the one generating
the global value run first so that the other program will get the
correct value for that 10-minute bar.

It is tricky but the documentation for the global variable packages
describes all this in great detail. You can track all this by using
print statements in each program to print events to the debug log as
they occur.

>This makes it impossible to pass correct values to the indicator for
>each bar in the past.

Not true. You can store all values for all past bars if you want the
method to work on historical data.

>I have spoken with both TradeStation support and EasyLangugage support,
>and was told that if the strategy includes a moving average calculation of
>any kind, then Tradestation evaluates all of the strategy bars BEFORE
>attempting to calculate any indicators. Since almost any strategy of
>significance will include a moving average, this would seem to close the
>door to sending data to an indicator on every bar of the chart.

Sounds like gibberish to me. I think TradeStation always executes a
strategy before executing indicators since indicators can use
functions (such as I_MarketPosition) that need data from the
strategy. So you can pass what ever you want from a strategy to an
indicator. If you want only want a single value for the most recent
real-time bar you only need one value of the variable. It you need
the values on all bars back in time, you need to store all bars back
in time.


Bob Fulks




>     Rather than duplicate large blocks of almost-identical code for a
>strategy and an indicator, I am trying to use a text boxes to pass two
>numbers from a strategy to a companion indicator to plot an upper and a
>lower breakout channel. The strategy writes the two text boxes with the
>current values for the channel, and the indicator is supposed to read and
>plot those two values for each bar. So far, so good.
>
>    However, when Tradestation loads a chart, it looks like it evaluates the
>EasyLanguage code for all of the historical strategy bars up to the current
>bar, then evaluates all of the indicator bars up to the present -- as
>opposed to evaluating the strategy and indicator code for each bar in
>sequence. This makes it impossible to pass correct values to the indicator
>for each bar in the past.
>
>     I have spoken with both TradeStation support and EasyLangugage support,
>and was told that if the strategy includes a moving average calculation of
>any kind, then Tradestation evaluates all of the strategy bars BEFORE
>attempting to calculate any indicators. Since almost any strategy of
>significance will include a moving average, this would seem to close the
>door to sending data to an indicator on every bar of the chart. Does anyone
>have suggestions or ideas on how to change the order in which indicator bars
>are evaluated?  Or do you have other shortcut ways to pass data from a
>strategy to an indicator so it can be plotted? Thanks.
>
>
>R. Engholm
>Portland, ME