PureBytes Links
Trading Reference Links
|
Imagine this simple system:
Rule: Stock's close is above MA(50)
If rule is fulfilled, send a limit order, 2% below yesterday close.
AFL Code:
/*******************************************************************
//Stock above MA
Rule1=Ref(Close,-1)>MA(Ref(Close,-1),50);
//Stock drops 2%
Rule2=Iif(Low<0.98*Ref(Close,-1),1,0);
Buy=Iif(Rule1==1 AND Rule2==1,1,0);
//Buyprice can be 2% below yesterday close, or even better.
BuyPrice=Iif(Open<0.98*Ref(Close,-1),Open,0.98*Ref(Close,-1));
SetOption("MaxOpenPositions", 5 ); // no more than 5 positions
PositionScore=ROC(C,40);
/*******************************************************************
As you can imagine, this simple system will trigger lots of buy signals every day. Without PositionScoring, I guess Amibroker choose the stocks by alphabetically order?
So, to solve this question, i thought in a simple ranking filter.
Lets say: PositionScore=ROC(C,40);
But, now there is my problem. If i apply PositionScore to the system above, system will be forward-looking.
The rank is applied to every stocks dropping 3%, and the ones with better rank are chosen.
In real life, if I already have 4 open positions, only the stock with highest rank should be considered.
Anyone can help?
Probably my explanation wasn't clear, this isn't easy to explain. Ask me any questions, if that was the case.
Many thanks!
------------------------------------
**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.
TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com
TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
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:
amibroker-digest@xxxxxxxxxxxxxxx
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/
|