Hello guys,
I am struggling several days to set proper backtesting for futures and I would appreciate if you could help me.
The thing is that for some reason (may be I am a bit dumb but please don't judge me ) I can't make Amibroker calculate the correct profit/loss.
Here is the example with simple system of course:
SetOption("MaxOpenPositions", 100);
SetOption("AllowSameBarExit", False);
SetTradeDelays(0,0,0,0);
MarginDeposit = -2;
BuyPrice = Close;
SellPrice = Close;
ShortPrice = Close;
CoverPrice = Close;
Buy = C >= HHV(C, 50) AND MA(C, 50) > MA(C, 100);
Sell = 0;
Short = C <= HHV(C, 50) AND MA(C, 50) < MA(C, 100);
Cover = 0;
RiskPerContract = 3 * ATR( 30 );
ApplyStop( stopTypeTrailing, stopModePoint, RiskPerContract, True );
//
// risk 1% of entire equity on single trade
PositionRisk = 2;
PctSize = PositionRisk * (MarginDeposit*(-1)) / ( RiskPerContract * PointValue );
SetPositionSize( PctSize, spsPercentOfEquity );
I would like to trade CL1! (Crude Oil futures contracts).
tick size = 0.01
Point value = 1
Margin deposit = 2%
So the problem:
By my understanding the profit should be like:
28.02 - 27.91 = 0.11
0.11 = 11 points
1 point = 1 USD
Amibroker gets 279.7 Contracts
So total loss should be = 279.7*11 = 3076.7 USD
Amibroker loss result = 30.77 USD
So obviously something I don't understand at setting up futures mode in Amibroker.
Little help will be greatly appreciated.