MM Issues in MultiCharts

I have recently faced a loss 3 times higher then a defined risk in my copy of the MultiCharts engine implemented in Backtrader engine.

I see 2 causes of this issue:

1. 
Stop enter order is used in the strategy
Long enter signal is received
Enter price is 200
Stop loss price is 190
Last close is 220
To calculate size MM uses enter price (200)
Your real order fills around last close price (220)
And you end up with bigger risk then expected if stop loss is hit

When Limit order is used, similar situation can happen too

2.
There is an issue with stop loss and MM in MultiCharts
Stop loss is replaced by new stop loss every bar.
This can lead to bigger losses then expected too.


I know that these changes will lead to a very different results for old strategies.
But I see no way other to fix this.

Attachments
No attachments
  • Votes +1
  • Project StrategyQuant X
  • Type Bug
  • Status Refused
  • Priority Normal

History

KP
#1

CooleRnax

11.11.2019 17:09

Task created

KP
#2

CooleRnax

11.11.2019 17:19

Description changed:

I have recently faced a loss 3 times higher then a defined risk in my copy of the MultiCharts engine implemented in Backtrader engine.

I see 2 causes of this issue:

1. 
Stop enter order is used in the strategy
Long enter signal is received
Enter price is 200
Stop price is 190
Last close is 220
To calculate size MM uses enter price (200)
Your real order fills around last close price (220)
And you end up with bigger risk then expected if stop is hit


When Limit order is used, similar situation can happen too


2.
There is an issue with stop loss and MM in MultiCharts
Stop loss is replaced by new stop loss every bar
So it behaves as trailing stop
This can lead to bigger losses then expected too
Also I don't see benefit of having 2 trailing stop in single strategy

I know that these changes will lead to a very different results for old strategies.
But I see no way other to fix this.

KP
#3

CooleRnax

31.01.2020 13:07
To fix 1:

When you calculate position size and enter at stop/limit, you should check last close price to make sure that you will not get instant fill at close price instead of enter price.

To fix 2:

You need to check loss amount, and override stop loss price if loss amount is bigger than risk amount in mm.

KP
#4

CooleRnax

31.01.2020 13:07
Voted for this task.
KP
#5

CooleRnax

31.01.2020 13:20

This is how I fixed issue 1 in Backtrader:


For long:

    if self.order_type[s]['long']['open'] == bt.Order.Stop \

            and d.close[0] > price_open:

        price_open = d.close[0]

    elif self.order_type[s]['long']['open'] == bt.Order.Limit \

            and d.close[0] < price_open:

        price_open = d.close[0]

For short:

    if self.order_type[s]['short']['open'] == bt.Order.Stop \

            and d.close[0] < price_open:

        price_open = d.close[0]

    elif self.order_type[s]['short']['open'] == bt.Order.Limit \

            and d.close[0] > price_open:

        price_open = d.close[0]


MF
#6

Mark Fric

27.05.2020 10:51

Status changed from New to Refused

I thought about this, but we will not change the way it works now. 


It doesn't work only for special cases, they should be solved specially, not as a part of general SQ.


Votes: +1

Drop files to upload

or

choose files

Max size: 5MB

Not allowed: exe, msi, application, reg, php, js, htaccess, htpasswd, gitignore

...
Wait please