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

[amibroker] Code for what has happened after 3 big down days before...



PureBytes Links

Trading Reference Links


I was curious to know if there was any pattern to what happens after 
the market has dropped by at least 1% for 3 consecutive days in the 
past - to see if there is a buying or shorting opportunity 
(statistically).

I downloaded all daily data back to the 20's for the DOW from Yahoo 
and put some code together (below).    In some backtests and 
optimizations (with some code that needs to be modified slightly) it 
appears that if you buy on open on Monday and hold about 86 days you 
can make a nice gain.

I'm having one problem w/ the code.   I'm optimizing for the # of 
days, which seems to be holding 86 days as the best scenario, but 
when I run the backtest for 86 days I get 3 or 4 sell signals that 
don't conform to 86 days.   I assume that my sell signal is getting 
confused w/ multiple buy signals or something else is going on but I 
havn't been able to figure out why it isn't working.   What I'd want 
to do is have it buy after 3 consecutive days down more than 1% and 
then sell x days later (in this case whichever ends up optimized).

If someone can help tell me how to fix the sell signal I'd be happy 
to post the final results.

Here is the code:

PositionSize = 1000;
C1 = Ref(C,-1);
C2 = Ref(C,-2);
C3 = Ref(C,-3);
Holdtime = Optimize("hold time",86,1,180,1);
dropamt = .01;
bigdrop = (C1-C)/C1;
bigdrop2 = (C2-C1)/C2;
bigdrop3 = (C3-C2)/C3;
threedays = (bigdrop >= dropamt) AND (bigdrop2 >= dropamt) AND 
bigdrop3 >= dropamt);
Buy = threedays;
Sell = Ref(Buy,-Holdtime);
Short = False;
Cover = False;
AddColumn(Buy,"buy",3.3);
AddColumn(bigdrop,"bd",3.3);
AddColumn(bigdrop2,"bd2",3.3);
AddColumn(bigdrop3,"bd3",3.3);
AddColumn(threedays,"threedays",3);
Filter = Buy; 





------------------------ Yahoo! Groups Sponsor --------------------~--> 
What would our lives be like without music, dance, and theater?
Donate or volunteer in the arts today at Network for Good!
http://us.click.yahoo.com/Tcy2bD/SOnJAA/cosFAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

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 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/

<*> 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/