[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 03:15 AM 11/8/2005, you wrote:
> 
> >I've found that some code works much better by not even allowing it to
> >look at the data before a certain amount of time has passed after the
> >open and closing out your trades before the session close can also
> >change things.  That and turning the code off and back on again at other
> >times can also change the results.
> 
> I think I understand what you are doing.

And I'm really trying to understand the way that you and it seems
everyone else in captivity are running TS.  Do you actually start your
strategy code with: if barnumber >=1 then ? 

> As Dennis says, most people simply let the calculation code run on every 
> bar (since it takes seconds when you turn on the machine) and turn on and 
> off the lines that initiate the trades at specific times of day.

What I was trying to say was - I've used code that produces better
results by turning off the calculations during certain times of the
day.  Must be stating it wrongly some how - maybe because my code and
calculations are all controlled by the same conditions - the initial
starting conditions which are mostly day and time of day.
 
> For example, this code fragment restricts entries to certain times, gets
> out near the end of the day, but leaves stops in place all day.
> 
> <All the calculation code that runs on all bars>
> 
> if (Time > 1000 and Time < 1200) or (Time > 1300 and Time < 1530) then
>    Buy next bar at XXX...
> 
> if MarketPosition = 1 and Time > 1545 then <Sell or ExitLong> ...
> 
> if MarketPosition = 1 then <Sell or ExitLong> next bar at xxx stop;

> Global variables are useful for communicating values between indicators or 
> between systems and indicators but are not required for most TradeStation users.
> They can be very tricky to use since TradeStation first runs one indicator from
> CurrentBar = 1 to the LastBarOnChart, then the next indicator from CurrentBar = 1 
> to the LastBarOnChart, etc., until all indicators and systems have been run. Then, 
> it runs all indicators and systems on each new real-time bar that arrives. The order
> in which these are runs is not specified so you have to take this into account
> when you decide which indicator is writing to and reading from the global variables
> when. This can get pretty complex.

Agreed, the use of global vars can get very hairy. However, they can be
well worth the effort needed.  There is nothing worse then being long in
the EUR and CHF at the same time - or short both.

Larry