PureBytes Links
Trading Reference Links
|
In-Reply-To: <p04320410b7bacf4b682e@[140.239.87.114]>
Bob, you're a genius!! (:-))
It's fixed the main problem although it's shoved a few bits of code of out
whack! Hopefully, however, I can fix them (otherwise I'll be back, guys...)
Thanks a million! And thanks to everyone else who helped out.
Cheers,
Ian
> At 7:18 PM +0100 9/4/01, Ian Waugh wrote:
>
> >Seems a bit loopy. Can't it work out the entry price *after* the buy bar
> >but before the next one?
>
> Your code runs conceptually on each bar after the close of the bar but
> before the open of the next bar. While the data is accumulating for a bar
> you code is not running. It is waiting for the end of the bar to run
> again.
>
> So if you want something to occur withing some bar, you need o issue the
> order while your code runs at the end of the previous bar.
>
> >So is there any way to buy at the close and then get out on a stop or
> some
> >condition interbar on the following bar...? I can't believe this is an
> >unreasonable - or rare - requirement.
>
> It is very common. From your original post:
>
> if blah blah blah... then buy this bar at close; {this bit works just
> fine}
> if OpenPositionProfit<-50 then exitlong;
>
> It looks as if you want to buy 1 contract at the close of a bar and set
> an exit stoploss of $50. This code should do it:
>
> if blah blah blah... then begin
> Buy this bar at close;
> XLStop = Close - 50 / BigPointValue; {Calculate stop value}
> end;
> ExitLong next bar at XLStop stop; {Keep stop in place for each
> bar}
>
> The ExitLong statement is only good for the next bar so it has to be
> executed on every bar to keep the stop in place. But you only want to set
> the stop value from the Close of the entry bar so you need to save that
> value.
>
> The statement:
>
> ExitLong next bar at Close - 50 / BigPointValue stop;
>
> would recalculate the stop value each bar which is not what you appear to
> want.
>
> Bob Fulks
>
>
>
|