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

Re: Need help - Alternate explan. of code problem



PureBytes Links

Trading Reference Links

> > I'm trying to find a way to code a system such that if conditions 
> > for a buy occur on a particular bar, then if on the next bar 
> > the high of the previous bar is taken out the system goes long 
> > immediately without waiting for close.

For that you need to use stops, as ndtrader suggested.  However, I 
don't think his code is doing exactly what you wanted.  Your 
description is unclear so I'm not sure.

> Try these statements:
> > If Condition1 and H next bar >= H[1] + X points then buy immediately;
> If Condition1[1] Then Buy on Stop H[1]+X;

That code says "if Condition1 is true on bar Z-1, then buy on bar Z+1 
at the High of bar Z-1 plus X."

I think what you asked for was "if Condition1 is true on bar Z, then 
buy on bar Z+1 at the High of bar Z plus X."

If so, the code for that is:

if Condition1 then buy at High+X stop;

Condition1 and High both reference the current bar.  The buy stop 
order is active on the next bar.  (And ONLY on the next bar.  Orders 
in TS do not automatically stay in effect until hit or cancelled.)

If you actually wanted "if Condition1 is true on bar Z, then buy on 
bar Z+1 at the High of bar Z-1 plus X," then it's

if Condition1 then buy at High[1]+X stop;

Gary