[Help] Specify max number of contracts in backtest

#1
How do I specify the maximum number of contracts/shares to trade in backtesting?

The problem is I am backtesting over past 5 years of data in nifty and want to know how many points per month it makes in Nifty. So if I set initial equity of 6000 it trades in two contracts when Nifty value was below 3000.

Similarly using any constant in PositionSize does not works because Nifty has fluctuated wildly over 5 years and when it falls below certain value it started trading with two contracts.

Please help.
 

Rajvir

Active Member
#3
Hello Bro, do you have past 5 year 5 mint intraday Nifty data? Can you pls either mail me or upload it somewhere and give link in this forum for all indigent ppl. Thanks
 

Rajvir

Active Member
#4
Do or Die one solution can be set the initial equity to 3000 when nifty was below 3000. Set the date range for backtesting to the point untill it starts to trade 2 Lots. Your last date range will be till it trades 1 lot only. In next step from the date where it strated trading 2 lots, set initital equity to higher size for 1 lot and repeat similar.

I know there must be other simple way to set the contract size at 1 , but untill some1 reply , you may try this
 
#5
do or die just do this... positionsize(50,4); this will limit the trade size to be 50 nifites ie one lot.. also specify the lot size and minimum size in the settings as 50.. i have done the same thing.. sorry i didnt read the post carefully last night..was sleepy ;-)
 

Rajvir

Active Member
#8
do or die just do this... positionsize(50,4); this will limit the trade size to be 50 nifites ie one lot.. also specify the lot size and minimum size in the settings as 50.. i have done the same thing.. sorry i didnt read the post carefully last night..was sleepy ;-)
Pls tell where is positionsize(50,4); setting. Or if we need to write this in the afl, then can you pls write whole condition here so that I can copy paste that in my afl
 

Rajvir

Active Member
#9
Anyway I got it . For help of other readers

Points-only test

Points only test is equivalent to trading just one contract. This can be easily accomplished using Futures mode of the backtester and adding the following one line to your formula:

PositionSize = MarginDeposit = 1;

Trading 'n' contracts

In a similar way you can setup your formula so it always trades say 7 contracts. All you need to do is to add the following to your formula:

NumContracts = 7;
PositionSize = NumContracts * MarginDeposit;
 
#10
Anyway I got it . For help of other readers

Points-only test

Points only test is equivalent to trading just one contract. This can be easily accomplished using Futures mode of the backtester and adding the following one line to your formula:

PositionSize = MarginDeposit = 1;

Trading 'n' contracts

In a similar way you can setup your formula so it always trades say 7 contracts. All you need to do is to add the following to your formula:

NumContracts = 7;
PositionSize = NumContracts * MarginDeposit;
does this specify number of contracts as 7 or maximum 7...what i mean is initially u might just have equity to trade one contract ..but as the account grows you should be able to trade more number of lots.. does this help in limiting the maximum number of contracts that the system can go to.. eg i start at 1 lot and then increase the lot size as and when equity increases to add another lot and so on till specified number of contracts.. in this case 7.. if it doesn't then it is the same as setpositionsize(350,4);
 

Similar threads