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

RE: [amibroker] Exploration Problem



PureBytes Links

Trading Reference Links

Ron, you can set the trade delay and buy/sell prices in the settings in AA
Or you can simply write

SetTradeDelays(1,1,1,1);
BuyPrice = O;
SellPrice = O;

These make it much simpler

If you want to buy the day after a buy condition was met, remember that you
also have the buy trade occuring then, so you will buy and sell the same
day. Do you mean the day after you enter the trade? In which case use these
lines

SetTradeDelays(1,2,1,1);//buy at 1 day delay, sell at 2 days delay
BuyPrice = O;
SellPrice = O;
Buy = your buy conditions
Sell = buy ;



Days in trade would be better if you used Barindex() or Cum(1) to calculate
the days in the trade

Entryday = valuewhen( buy, Cum(1) );
Exitday = valuewhen( sell, Cum(1) );
Daysintrade = Exitday - Entryday; //The actual trade days, not calendar days

Cheers,
Graham
http://groups.msn.com/ASXShareTrading
http://groups.msn.com/FMSAustralia
-----Original Message-----
From: mrdavis9 [mailto:mrdavis9@xxxxxxxxxx] 
Sent: Thursday, 18 September 2003 11:46 AM
To: amibrokeryahoogroups
Subject: [amibroker] Exploration Problem


Steve, Graham, and all, thanks for your great help.  I haven't yet tried to
get my creaky mind to fully understand this current iteration (pasted below)
of my first exploration.  I have added three more columns that are supposed
to show the entry day, exit day, and the number of days in the trade.   When
I run it, it shows that all exits occur on the same day as the entry. This
(days in trade  problem ) is most likely due to incorrect coding that I used
to find these values.  
This basic concept  of buying  and selling on the open  is to be used for an
EOD trading system that is based entirely on buying and selling
unconditionally on the open price of the day following the buy and sell
signals. These stochk crosses are not the actual system, but they are a
great thing to use in order for me to learn to do explorations that are
designed to work just like the ultimate trading system will work. 
In an effort to increase my AFL knowledge, I'd like to call attention to my
origional "Entryprice= "coding that is supposed to cause an entry to occur
at the opening price of the day "AFTER" the buy condition was met.  This is
my attempt to refer to tomorrow's opening price in order to identify the
correct  "(buy on the open price)" for tomorrow.  Will  my coding
immediately below do this, and if not, then I wonder why will it not ?
Entryprice=ValueWhen(Cross(StochK(14),StochD(14)),Ref(Open,0),1);//opening
price of  the Day after Buy=Cross(FastStoch, SlowStoch);
==============================================
 Immediately below here is my origional "Exitprice=" coding that is supposed
to cause an exit to occurr at the opening price of the day "AFTER" the buy
condition was met.  This "Exitprice= "code is supposed to select tomorrow's
opening price  as the Exit price.    I understand that
ValueWhen(Cross(StochD(14),StochK(14)),Open,1); ,    would  referr to  the
opening price today, which is the day that the buy signal actually occurrs.
Since I want to reference tomorrow's opening price, which is the day after
the buy signal actually occurrs, I have replaced   ,Open,1);    with the
following:    ,Ref(Open,0),BarsSince(Cross(StochK(14),StochD(14)));  In this
revised code, "Open" has been changed to> "Ref(Open,O)" and the number "1);"
has been changed to > ",BarsSince(cross(stochK(14),stochD(14)));"
This "Exitprice=" coding of mine produces a syntax error at the ; at the
right end of the code line'
Exitprice=ValueWhen(Cross(StochD(14),StochK(14)),Ref(Open,0),BarsSince(Cross
(StochK(14),StochD(14)));//Open price of Sell Day.
I will study this revised code below as soon as I send this.  Regardless of
whether this current version copied below is correct or not,  I would like
to hear comments regarding my logic, or lack thereof, in the coding that I
used in both the "EntryPrice=" and "ExitPrice=" codes that I created. 
Did I use the correct codes to produce the three additional columns of
Buydate, Selldate, and Daysintrade?  If my last three colums are coded
correctly, then this current version is not selling on the following day, or
on a later day,  as it should be.   Once again, I greatly appreciate all of
your great help.
Ron D   
============================================================================
==
FastStoch = StochK( 14 );
SlowStoch = StochD( 14 );
Buy = Cross( FastStoch, SlowStoch );
Sell = Cross( SlowStoch, FastStoch );
StochKBuy = ValueWhen( Buy, FastStoch );
StochKSell = ValueWhen( Sell, FastStoch );
StochKDiff = StochKSell - StochKBuy;
EPrice = ValueWhen( Ref( Buy, -1), Open );
XPrice = ValueWhen( Ref( Sell,-1), Open );
Rtn = XPrice - EPrice;
PctRtn = Rtn / EPrice * 100;
Buydate=ValueWhen(EPrice,Day(),1);
Selldate=ValueWhen(XPrice,Day(),1);
Daysintrade=Selldate-Buydate;
Filter = C > 1 AND C < 100 AND V > 100000;
AddColumn( StochKBuy, "Buy Value", 1.2 );
AddColumn( StochKSell, "Sell Value", 1.2 );
AddColumn( StochKDiff, "%K Diff", 1.2 );
AddColumn( EPrice, "Entry $", 1.2 );
AddColumn( XPrice, "Exit $", 1.2 );
AddColumn( Rtn, "made$", 1.2 );
AddColumn( PctRtn, "% Rtn", 1.2 );
AddColumn( Buydate, "Eday", 1.2 );
AddColumn( Selldate, "Xday", 1.2 );
AddColumn( Daysintrade, "X-E", 1.2 );

Yahoo! Groups Sponsor
ADVERTISEMENT




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 the Yahoo! Terms of Service. 


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Remanufactured Ink Cartridges & Refill Kits at MyInks.com for: HP $8-20. Epson $3-9, Canon $5-15, Lexmark $4-17. Free s/h over $50 (US & Canada).
http://www.c1tracking.com/l.asp?cid=6351
http://us.click.yahoo.com/0zJuRD/6CvGAA/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/