SL/TP execution problem

Questions about MultiCharts .NET and user contributed studies.
Bugs
Posts: 6
Joined: 20 Jul 2013

SL/TP execution problem

Postby Bugs » 29 Jul 2013

Hello,

In my strategy I am generating Stop loss & Profit Target after sending initial entry order. It works fine but in some cases SL/TP doesnt execute or executes late. Following are some of its instances

Late execution case:
------Long Signal Generated------
7/29/2013 11:03:12 AM
Close Price = 8357 | takeProfitValue = 8360 | stopLossValue = 8354 | takeProfitAmount = 75 | stopLossAmount = 75
Bar time = 09:13:00 | Close Price = 8354 | Market Position = 0 | High = 8352 | Low = 8332 | tick size = 1 | Big point value = 25
------Long Signal Generated------
7/29/2013 11:03:12 AM
Close Price = 8354 | takeProfitValue = 8357 | stopLossValue = 8351 | takeProfitAmount = 75 | stopLossAmount = 75
Bar time = 09:14:00 | Close Price = 8348 | Market Position = 0 | High = 8352 | Low = 8332 | tick size = 1 | Big point value = 25
...
Bar time = 09:23:00 | Close Price = 8337 | Market Position = 0 | High = 8352 | Low = 8332 | tick size = 1 | Big point value = 25
Bar time = 09:24:00 | Close Price = 8322 | Market Position = 0 | High = 8352 | Low = 8332 | tick size = 1 | Big point value = 25

Stop loss executes at 8322 but it should do at price 8348

No execution
------Short Signal Generated-----
7/29/2013 11:03:12 AM
Close Price = 8330 | takeProfitValue = 8327 | stopLossValue = 8333 | takeProfitAmount = 75 | stopLossAmount = 75
Bar time = 09:29:00 | Close Price = 8330 | Market Position = -1 | High = 8352 | Low = 8332 | tick size = 1 | Big point value = 25
Bar time = 09:30:00 | Close Price = 8324 | Market Position = -1 | High = 8352 | Low = 8332 | tick size = 1 | Big point value = 25

i have also attached portfolio report snapshot.

Here is the code:

Code: Select all

CurSpecOrdersMode = ESpecOrdersMode.PerPosition;
buy_order.Send(_tradeSize); //buy_order is a Market Buy order
double _takeProfitValue=CalculateTakeProfit(closePrice,_takeProfit,_tickSize,"Buy"); //CalculateTakeProfit calculates take profit price using close price and _takeProfit(pips)
double _stopLossValue=CalculateStopLoss(closePrice,_stopLoss,_tickSize,"Buy"); //CalculateStopLoss calculates stoploss price price using close price and _stopLoss(pips)
_takeProfitAmount=GetRiskAmount(closePrice,_takeProfitValue,_tradeSize,_pointValue); //GetRiskAmount calculates risk amount using takeProfitValue price
_stopLossAmount=GetRiskAmount(closePrice,_stopLossValue,_tradeSize,_pointValue); //GetRiskAmount calculates risk amount using stoplossValue price
GenerateProfitTarget(_takeProfitAmount);
GenerateStopLoss(_stopLossAmount);
Thanks
Attachments
Portfolio_report.png
(86.01 KiB) Downloaded 581 times

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: SL/TP execution problem

Postby Henry MultiСharts » 29 Jul 2013

Hello,

Are you referring to backtesting, forward testing or realtime strategy trading?
Have you checked the following article? How Signals are Calculated

User avatar
master.aurora
Posts: 33
Joined: 21 Jan 2013
Location: Islamabad
Has thanked: 6 times
Been thanked: 3 times
Contact:

Re: SL/TP execution problem

Postby master.aurora » 31 Jul 2013

Hello Support,

We are testing the strategy using the MC .NET Portfolio Backtester. Thus, it is backtesting we are referring to. Also, we are using:

Code: Select all

[IOGMode(IOGMode.Enabled)]
at the top of the strategy class. As, explained in the original post, some of the targets work correctly, while others do not.

Please advise.

Thanks
Umer

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: SL/TP execution problem

Postby Henry MultiСharts » 31 Jul 2013

Hello Umer,

In Portfolio Backtester such options as IOG and Bar Magnifier are not available at the moment. That means backtesting works the following way:
Calculation on historical data. Regular mode (IOG disabled. Bar Magnifier disabled)

The script is calculated on the bar close. It is considered that all prices were within the bar (Intra-bar Price movement assumption is used). Order is filled on any price within the bar.
Source: How Signals are Calculated


Return to “MultiCharts .NET”