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

Re: [EquisMetaStock Group] Buying and selling on the same EOD bar



PureBytes Links

Trading Reference Links

Hi Tan Ming


Buying and selling on the same EOD is quite easy to do with the Enhanced System Tester once you understand that the EST cannot "consider" a buy and sell on the same bar. The trick is to forward reference the buy window formula by one bar so that the EST "considers" the buy one bar before considering the sell. Then a one day strategic delay is applied to the buy window so that it executes on the correct bar.

The sell window formula can use the same formula as the buy window but without a forward reference, and with no strategic delay.

For the simulation set the buy price to OPEN and the sell price to CLOSE and you're done. The only drawback is that the last bar of data cannot be included in the test (because of the forward reference).


{Buy Order window}
Signal:=Ref(Fml("my buy signal"),-1); {all conditions are met for trade to buy and sell on the next bar}
Signal:=Signal and Alert(Signal=0,2); {retain only the first of several signals in a contiguous group}
Buy:=Ref(Signal,+1); {advance "consider" stage of buy by 1 bar}
Buy;

{apply 1 bar Strategic delay}


{Sell Order window}
Signal:=Ref(Fml("my buy signal"),-1); {all conditions are met for trade to buy and sell on the next bar}
Signal:=Signal and Alert(Signal=0,2); {retain only the first of several signals in a contiguous group}
Sell:=Signal; {do not advance or delay "consider" stage of sell}
Sell;

{do not apply a Strategic delay}


{Simulation, Trade Execution}
Untick "Realistic Market Prices"
Buy Price: Open
Sell Price: Close
Delay order opening  0 bars.

There are other factors that can affect the successful execution of buy and sell but those factors are not unique to buy and sell on the same bar so I've not made any attempt to list them.

To summarize the procedure for buy and sell on the same bar:
{for Buy Order}
All buy/sell conditions are TRUE on previous bar.
Generate signal on current bar and limit signal to TRUE for one bar only.
Advance signal to buy on next bar. (fools the EST into considering the buy trade 1 bar early)
Apply a Strategic delay to restore the correct timing of buy to the current bar.

{for Sell Order}
Duplicate the buy order but remove the forward reference and Strategic delay.

Set Simulation Buy and Sell prices to OPEN and CLOSE. 

If you wish to buy at some other price than OPEN you must generate a price (value) signal for the Buy Price window that coincides with the Buy Order signal. The Simulation buy price is then best set to CLOSE which acts as the default buy price when the stipulated buy price falls outside the H/L range. This can happen when using HIGH or LOW as well as an illegal price so beware.

Hope this points you in the right direction.


Regards

Roy

  ----- Original Message ----- 
  From: tan ming 
  To: equismetastock@xxxxxxxxxxxxxxx 
  Sent: Wednesday, July 25, 2007 12:48 AM
  Subject: [EquisMetaStock Group] Buying and selling on the same EOD bar


  Hi, how to code a buy or sell on the next EOD bar open price and close the 
  position on the close of same EOD bar?

  __________________________________________________________
  Try it now! Live Search: Better results, fast. 
  http://get.live.com/search/overview Try it now.



   

  __________ NOD32 2417 (20070724) Information __________

  This message was checked by NOD32 antivirus system.
  http://www.eset.com


[Non-text portions of this message have been removed]



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/equismetastock/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/equismetastock/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:equismetastock-digest@xxxxxxxxxxxxxxx 
    mailto:equismetastock-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    equismetastock-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/