PureBytes Links
Trading Reference Links
|
Fred,
Here is some code fragments from my system that you might find
useful. The time parameters are a bit hokey, but they work. I
wanted a time slider that I could see the effect of different trading
starts and stops by the time of day. I did not know how to make it
skip 60-99 minutes. So it has a positions that are on the hour.
Dennis
Daytrade = ParamToggle("Daytrade?","No|Yes",1);
plotEquity = ParamToggle("Plot Equity?","No|Yes",0);
TradeBeg = 100*Param("| All Trading Begins HHMM", 930, 930, 1559,
5); /* select trading start time with parameter window */
TradeEnd = 100*Param("| All Trading Ends HHMM", 1550, 930, 1559,
5); /* select trading end time with parameter window */
TradeEnd2 = 100*Param("| New Trading Ends HHMM", 1550, 930, 1559,
5); /* select trading end time with parameter window */
//
// AFL trading rules
//
//daytrading rules
if (Daytrade==1)//toggle daytrading vs swing trading
{
//enable trading hours
Buy &= TimeNum()>=TradeBeg AND TimeNum()<TradeEnd2; //time of day to
place buys
Sell &= TimeNum()>=TradeBeg AND TimeNum()<TradeEnd; //time of day to
place sells
Short &= TimeNum()>=TradeBeg AND TimeNum()<TradeEnd; //time of day to
place shorts
Cover &= TimeNum()>=TradeBeg AND TimeNum()<TradeEnd2; //time of day
to place covers
//close out at end of day
Sell |= TimeNum()>TradeEnd; //close trade at end of day
Cover |= TimeNum()>TradeEnd; //close trade at end of day
}
// Show me the money
if(plotEquity == 1){Plot(Equity
(0,-1),"equity",colorGold,styleOwnScale);}
On May 7, 2007, at 9:19 PM, jjj_98 wrote:
> Is there a function or box in some menu that tells the backtest to
> exit
> all positions on the close of the day or at a given time or do I have
> to write code to exit the trades. I assume I could just use the
> TimeNum
> () function to set the time to sell or cover any outstanding
> positions.
>
> Just wondering if there was an easier way.
>
> thx,
>
> Fred
>
>
>
> Please note that this group is for discussion between users only.
>
> To get support from AmiBroker please send an e-mail directly to
> SUPPORT {at} amibroker.com
>
> For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
> http://www.amibroker.com/devlog/
>
> For other support material please check also:
> http://www.amibroker.com/support.html
>
> Yahoo! Groups Links
>
>
>
Please note that this group is for discussion between users only.
To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
For other support material please check also:
http://www.amibroker.com/support.html
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/amibroker/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:amibroker-digest@xxxxxxxxxxxxxxx
mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx
<*> To unsubscribe from this group, send an email to:
amibroker-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|