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

[amibroker] Re: playing with exits



PureBytes Links

Trading Reference Links

Yuki,

This meets your first requirement. You can probably figure out #2, but
yell if you need help.

This was altered from someone else's sample code but I don't remember who.

//--------------------------------
// Test Next Day Exit
Buy = Sell = Short = Cover = False; // Initialize Arrays

// overide default settings
SetTradeDelays(0,0,0,0);

// make a simple trading system
Buy = Cross(RSI(),30);

// buy the next day at the open
// use Ref(Buy -1) because the Ref function returns a value
// so the "1" numbers inside the Buy array are moved forward this way.
Buy = Ref(Buy, -1);

// define the BuyPrice
BuyPrice = ValueWhen( Buy, Open);
Sell = BarsSince(Buy) == 1;

SellPrice = IIf(Open >= BuyPrice,Open,C);

Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);

Filter = 1;
AddColumn(BarsSince(Buy),"BarsSince(Buy)",1.0);
//-----------------------------------------

Regards,

Phsst

--- In amibroker@xxxxxxxxxxxxxxx, Yuki Taga <yukitaga@xxxx> wrote:
> I have a short term system that works pretty darn good liquidating on
> the next day's open.  Of course, no system produces winners every
> time, and along that line, I'd like to see what happens if I keep a
> loser (a loser on the open, that is) and try to exit a bit later that
> day, or on the close.
> 
> Right now my exit (long or short, doesn't matter) is on the open the
> day after entry -- no exceptions.  How can I change this so that:
> 
> 1) if the open is unfavorable (lower than buyprice or higher than
> shortprice), I hold until the close that day (I will still take
> winners on the open)
> 
> I have no idea whether this is even a good idea or not until I run
> some tests on it of course -- but I have had a number of losers turn
> into pushes or even winners later in the day.  This has happened
> often enough to make me want to explore the statistical probability
> of this, at least during the sample period.
> 
> 2) I would settle (very happily, thank you) for an exit right at
> buyprice or shortprice intraday when the open is unfavorable.  So I'd
> like to test both ways, as in number 1 above, but also if number 2,
> else number 1.
> 
> I do not know how to write this sell or cover statements, sadly.  Any
> help greatly appreciated.
> 
> Yuki


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/GHeqlB/TM
---------------------------------------------------------------------~->

Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 

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