Max allocation issue

I am facing a issue with Max allocation it is not working in backtest.

Check the Below screenshots I have run same backtest twice for a previous period and then for a later period, in the first backtest the signals are less even when more time is selected. While in second the signals are more even when less time is selected.

I checked with multiple parameters and the issue seems with capital based position, if I remove that it works fine. Why it is not taking trades after 6th march in first image

(The conditions are same no change in that I dont want to reveal that hence blurred) @Kunal_Streak

Seems you had lost 10k by 6th March so the capital was down to 20k. After 6th March you may not have enough capital to buy the BankNifty lot. Hence, it is not generating any trades. Just a guess from my end.

1 Like

I have analyzed the backtest screenshots and this is not an issue but the difference seems to be because of the combination of Max allocation and Initial Capital.

You are using the Initial Capital as 30000. Thus in backtesting, an entry will be taken only when the notional value of the trade is less than the ‘initial capital + Cumulative Profit or Loss’.

Now when you are running the backtest from 03 Mar 2023 to 31 May 2023, the trades till 06 Mar 2023 are incurring a loss of -9716.25. Hence, the capital available now is 20,283.75 (i.e. initial capital + Cumulative Profit or Loss’ = 30,000 + (-9716.25) ). As you have used the Capital based position sizing and the max allocation of 30,000 the quantity will be selected for 30,000 but, when the system checks for the next entry it will only take entry when the entry price is fetching the quantity within the available capital.

However, with the initial capital of 30,000, the available capital now is 20,283.75 (after the calculation of the previous loss as explained above). Thus the fetched quantities with the Max allocation can not be bought with the available capital, hence the trade is avoided.

Similarly, the other trades are avoided as the notional value of the trades is higher than the available capital. You can keep a large number as initial capital so that all trades in backtests are considered.

However, when you run the backtest from 01 May 2023 to 31 May 2023 the trades do not occur a major loss thus the initial capital must not be going lower than the notional values of the trades, and the trades as visible in this backtest period. Therefore, you can keep a large number as initial capital so that all trades in backtests are considered.

You can reverify the details by increasing the initial capital.

In case you are facing any further issues you can also share the Strategy link to [email protected] so that the team can check in detail and assist you further.

1 Like