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

Re: Help with coding an initial stop loss



PureBytes Links

Trading Reference Links


Bob Fulks wrote:
> 
> At 01:01 AM 11/2/2005, Larry wrote:
> 
> >Also, unless you are just back testing you will need to use Global
> >Variables in order to pass the BarLow and BarHigh values to the next day
> >unless you leave your computer on all the time.
> 
> Not true. The values are maintained bar to bar until you change
> them. If you simply say:

Absolutely not true - variables are only maintained as long as the
program is running. Shut down the program or turn off the computer and
all the program variables are gone.

If all he is doing is back testing - then the values will, of course, be
maintained through the test.  If he is trying to run his strategy on a
day to day basis in real time with real data AND shuts off his computer
or the program after the run - the values ARE gone. 

Many things that work in back testing such as passing along variables
from one day's data to the next day's run do NOT work in the real world
with real data.  Now he is aware of at least some of the problems with
taking a system that back tests and trying to apply that system to real
data.

If he is going to try to take his system into the real world then he
will need to pass the 'BarLow'/'BarHgh' value information from Monday's
run, to Tuesday's run, to Wednesday's run etc.  Which is easily done
with Global Variables. 

If he is happy with developing systems that run well on historic data
and content to see the results of what would have been if he only would
have been trading for real - would've, could've, should've, - then I
have very little interest in trying to help him.

 
> BarLow = Low;
> 
> Then you are updating the value each bar. But if you say:
> 
> if XXXXX then BarLow = Low;
> 
> then you are only updating BarLow when condition XXXX is TRUE.

> >You may also have a different problem with the "BarLow[1]".
> >BarLow/BarHigh are the current values of BarLow/BarHigh and should be
> >reset to a new value each time you enter a trade (long or short).
> >Sometimes TS does strange things with the back one value [1].  You may
> >not get what you think you should get.
> 
> Not true. TradeStation interprets "Variable[1]" as the value of the
> variable one bar back. This is handy for things like prices, which
> change every bar.

Absolutely not true - although using [1] may be handy for some things -
using [1] is death in this case.  He is trying to set the value of
'BarLow'/'BarHigh' to the value that they ARE on the trade entry bar. 
In his case using [1] is a kiss of death as he will not get the value
that he is expecting but, instead, will get the value of what
'BarLow'/'BarHgh' WERE one bar ago IF they had a value one bar ago. 
Which is not the value he is looking for - Hence a different problem.

And my statement "....should be reset to a new value each time you enter
a trade (long or short)." is a hint to check to make sure that you are
not resetting these values at any other time.  Which is, of course,

if condition xxx then begin
a=1;b=2;c=3;
end;

 
> It is not necessary to use that form for variables that do not get
> updated bar to bar unless your code specifically updates then bar
> to bar.
> 
> Bob Fulks

Larry