PureBytes Links
Trading Reference Links
|
Hi. Im stuck. I wonder if anyone can
help...
I've desgined a system that seems to work when I
back test it as if I were buying/selling equities.
However, I intend to operate it in a UK
spreadbetting account. I dont know if this is available in the US, but
basically, you decide on a "bet size" and bet in the direction you think a
share/index/commodity will go. For example, lets say my system tells me to sell
Microsoft, I can "bet" £1 - £50 per point (cents, pence etc) move. So if I bet
£10 per point that MSFT will fall, and MSFT goes down 20 points, my account is
credited with £200 ... and vice versa. Very simple.
Now, Im stuck on how to program this in AB using
the position size, pointvalue and num contracts, etc. Can someone tell me if my
logic is correct?
1) Im expetcing to be in positions for days/weeks
so I buy on close or open next day using a simple breakout system, so Im always
above (long) or below (short) a moving average. Lets say Im going long and
I decide the "points" I am prepared to lose will be the
difference between my entry and an 8 day moving average: <FONT face=Arial
size=2>stop= abs(c - MA(C,8));
2) I will be risking 2% of my current equity on
every operation: risk = round(0.02*Equity()); NOTE: Ive also tried setting risk
to a fixed value, 200, and it still doesnt give meaningful results.
3) As contracts per se dont exist, I set the
numcontracts to 1. Im not sure this is correct, but it seems logical as bet
size or pointvalue is variable. In futures you buy variable numbers of contracts
and have a fixed point value, in spreadbetting you decide your own point value
and dont "buy" any contracts at all.
4) The number of points to the stop must be less
than the £ risk for the position to be affordable: for example, if the stop is
40 points away, and my risk is calculated to be 200, my bet size will be 5. If I
am stopped out right away, I will lose 5*40 = 200. If the stop is 300 points
away, and my risk is 200, I cant enter that position (bet size<1 is not
allowed by the system)
5) Pointsvalue will be:
pointvalue=round(risk/stop);
6) I have absolutely NO idea how to use
positionsize in this set up ... Do I need it? Should I set
positionsize=-2?
7) Futures mode is ON when I back
test.
8) I have also no idea how to set margindeposit,
cos there isnt any "deposit" made, so I havent included it in the
coding..
Here is my final code:
Stoptrigger=MA(c,8);
Numcontracts=1;
E=Equity(1,-1);
stop=abs(c-stoptrigger);
risk=0.02*E;
buy=rule1 AND risk>stop;
short=rule2 AND risk>stop;
cover=rule3;
sell=rule4;
pointvalue=round(risk/stop);
This gives me exponential negative numbers in the
backtest (and low positive numbers in the simple equity back test) ... so I
think Im doing something wrong ... what coding have I missed out to be able to
run the backtester OK?
Any ideas anyone?
Thanks ...
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.
|