Hello everyone
Since I am a newbie to Amibroker, I still face problems with encoding my
idea in AFL. Therefore I would like to ask for your help with the
following issue. I want to compose a formula for so calles Fixed Ratio
Position Sizing developed by Ryan Jones in "The trading game" 1999,
which you can look up here:
http://www.stator-afm.com/fixed-ratio-position-sizing.html
<http://www.stator-afm.com/fixed-ratio-position-sizing.html> . The
general rule assume that we start with one contract/lot/microlot/etc and
increase (or afterwards decrease) the position size according to Delta,
which is used to estimate total net profit threshold that is required to
add another contract. Equistion looks as follows:
position=0,5*[(1+8*profit/delta)^0,5+1].
I prepered the formula:
capital=Equity();
capital[0]=a;//a is initial equity//
profit[0]=0;
for(i=0;i<Barcount;i++)
{profit[i]=capital[i]-capital[0];}
d=Optimize("delta",500,500,10000,500);
PositionSize=0.5*((1+8*profit/d)^0.5+1);
...and it doesn't work in the backtest (it always sets the same number
of contracts for the whole backtest period that is 1 contract), since
<profit> return no value but <0> (zero)... :( . Replacing PositionSize
with SetPositionSize(0.5*((1+8*profit/d)^0.5+1), 1) doesn't work, too.
Can you give me some advice about this code? How to make <profit> work?
What's wrong with this formula?
I will be very grateful for any advice.
Best regards
Tomasz