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

[amibroker] Using AFL to change PointValue() dynamically



PureBytes Links

Trading Reference Links

I'm using AFL to change the PointValue for a backtest.

My formula is to set the PointValue for all days from the longsetup 
day to the Sell day to that calculated on the longsetup day. This is 
what you do in spreadbetting - place your buy and stoploss orders at 
£x per point on the longsetup day.

My formula for deciding pointvalue on the longsetup day is:

A: Capital to Risk = (Total Capital * MaxRisk) / 100   // ie. risk 5% 
of total capital per trade
B: Points between buy order and stop loss
C: Bet per point = (A/B) * 100

The routine then changes all days from the longsetup day to the sell 
day to PointValue C.

However, the AFL is not working!!!!!!

Can anyone try out the code and advise. Many thanks - Alex


MaxRisk = 5;
e = Equity();
flag2 = 0;
mk2 = 0;

for (i=1; i<BarCount; i++)
{
  if (LongSetup[i]==1)
  {
   f = ((e * MaxRisk)/100);
   g = (abs(stopbuy[i] - LongStop[i]))*100;   //*100 as $0.01 = 1point
   PV = (f/g)*100;     // *100 as PointValue of £1 = 100 in AFL
   flag2 = 1;
   mk2 = i;    // Log setup day barindex
  }

   if (Sell[i]==1)
    { if (flag2 == 1)
      { for (j=mk2; j<i+1; j++)
        { PointValue = PV; }
          flag2 = 0;
      }
    }
}


Content-Description: "AVG certification"
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.441 / Virus Database: 268.17.37/682 - Release Date: 2/12/2007 1:23 PM