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

Re: [amibroker] Simple Buy on Close, Sell on Open not as expected


  • Date: Sat, 30 Jan 2010 11:39:05 -0800 (PST)
  • From: B S <bs2167@xxxxxxxxx>
  • Subject: Re: [amibroker] Simple Buy on Close, Sell on Open not as expected

PureBytes Links

Trading Reference Links

Anthony- Off-topic question if you don't mind - what do the numbers in parantheses next to "Long" in the Trade column signify?

 


From: Anthony Faragasso <ajf1111@xxxxxxxx>
To: amibroker@xxxxxxxxxxxxxxx
Sent: Sat, January 30, 2010 1:36:51 PM
Subject: Re: [amibroker] Simple Buy on Close, Sell on Open not as expected

 

----- Original Message -----
Sent: Saturday, January 30, 2010 12:54 PM
Subject: Re: [amibroker] Simple Buy on Close, Sell on Open not as expected

Anthony --
Thanks for your effort.  I tried your exact code (copy and paste).  It still skips every other day.

Also, I reduced the code to absolute minimum as:
Buy = 1;
BuyPrice = Close;
Sell = Ref(Buy, -1);
SellPrice = Open;


Been through my settings many times.  Still the same.


BTW, I'm running 5.26beta.

-- Keith


Anthony Faragasso wrote:
 

Keith
 
give this a try:
 
Settings window:
 
allow same bar exit is enabled
all stops are disabled
 
In the trades window of the settings I set up the trades as follows probably do not need it :
buy=close, delay 0;sell=open, delay 0
short=close, delay 0 ,cover = open, delay 0

// BuyClose SellOpen Daily.afl

SetTradeDelays(0,0,0,0);

Buy = Ref(Close,-1);

BuyPrice = ValueWhen(Buy,Ref(C,-1));

Sell = Open;

SellPrice = Open;

Short = Cover = False; // long only strategy

 
----- Original Message -----
Sent: Saturday, January 30, 2010 1:09 AM
Subject: [amibroker] Simple Buy on Close, Sell on Open not as expected

 

Just fooling around with a very simple idea, but can't get the code to work.
The idea is to sell at close of every day, hold over night, and sell at open the following day.
Code below sorta works, but skips every other day.  For example:
Day 1, buy on close; Day2, sell on open.
Day 3, buy on close; Day4, sell on open.
etc.
But I can't make it buy on close of days 2, 4, etc.
Tried "Allow same bar exit" in settings, but that makes it sell the same day that it buys, which is wrong.

// BuyClose SellOpen Daily.afl
SetTradeDelays(0,1,0,0);  // has no effect
Buy = Close;
BuyPrice = Close;
Sell = Open;
SellPrice = Open;
Short = Cover = False; // long only strategy
Buy = ExRem(Buy, Sell);  // has no effect
Sell = ExRem(Sell, Buy);  // has no effect


Well?
-- Keith