Duplication of Stoploss in Easy Language Automated Trading  [SOLVED]

Questions about MultiCharts and user contributed studies.
sternbergleonel
Posts: 12
Joined: 03 Oct 2018

Duplication of Stoploss in Easy Language Automated Trading

Postby sternbergleonel » 03 Oct 2018

I am having issues with an automated strategy. I have an automated EL code to buy or sell orders included with the code is stoploss order. I am running this with intrabar order generation on. The strategy works fine with backtesting. The issue is that when I run live it generates two Stoploss orders. Here is a piece of my code... the conditions are irrelevant here, suffice it to say that when I ask it open an order it does so, but it adds two identical stop losses.

Code: Select all

[code]condition1=var5<tresh and var5[1]<tresh and var5[2]<tresh and var5[3]<tresh and var5[4]<tresh;
if condition1 then begin
//if it goes close to the upper bollinger band then sell short
if price crosses above var3 then
sellshort ("slopeMASE") next bar at market;
end;
setstoploss(30);
[/code]

I have tried putting the stoploss within the conditional statement, but the problem persists. I am uploading a screen shot of what typically happens. . The screen shot is for a buy order but a sellshort order does the same thing. Any suggestions would be appreciated.
Thanks
Leo
Attachments
Screenshot 2018-10-02 21.37.18.png
(119.67 KiB) Downloaded 690 times
Last edited by sternbergleonel on 03 Oct 2018, edited 1 time in total.

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Duplication of Stoploss in Easy Language Automated Trading

Postby TJ » 03 Oct 2018

See post #1 & post #2
viewtopic.php?t=11713


see also post #5

Zheka
Posts: 223
Joined: 13 Jan 2016
Has thanked: 8 times
Been thanked: 53 times

Re: Duplication of Stoploss in Easy Language Automated Trading

Postby Zheka » 04 Oct 2018

This is because you have 2 open positions. And MC manages a stop loss for both...

sternbergleonel
Posts: 12
Joined: 03 Oct 2018

Re: Duplication of Stoploss in Easy Language Automated Trading

Postby sternbergleonel » 04 Oct 2018

Doesn't sound right ... the other position is in another currency pair and I often have several other open positions in other currency pairs. By your logic I should have several stoplosses. It's always two stoplosses per currency pairs.

User avatar
ABC
Posts: 718
Joined: 16 Dec 2006
Location: www.abctradinggroup.com
Has thanked: 125 times
Been thanked: 408 times
Contact:

Re: Duplication of Stoploss in Easy Language Automated Trading

Postby ABC » 04 Oct 2018

sternbergleonel,

is it possible that you have more than one strategy applied to the same chart that uses the setstoploss reserved word?

Regards,

ABC

sternbergleonel
Posts: 12
Joined: 03 Oct 2018

Re: Duplication of Stoploss in Easy Language Automated Trading

Postby sternbergleonel » 04 Oct 2018

Humm.. I do have a long and a short strategy on the same chart...both have stoplosses. Let me try with only one on the chart and see what happens. If this is the case, the solution would be to put the stoploss in the inner conditional loop. This way the stoploss will be activated only when the order is opened. I'll get back to the discussion forum on this.

User avatar
ABC
Posts: 718
Joined: 16 Dec 2006
Location: www.abctradinggroup.com
Has thanked: 125 times
Been thanked: 408 times
Contact:

Re: Duplication of Stoploss in Easy Language Automated Trading

Postby ABC » 04 Oct 2018

sternbergleonel,

then this is likely the explanation, as both strategies issue a stop. In general these build in exit reserved words are best used unconditionally and you could have them once within a separate exit strategy.

You might also wan to explore the "Optimize Order Flow" feature, as this will likely only place one of the two exit orders your code issues.
https://www.multicharts.com/trading-sof ... Order_Flow

Regards,

ABC

Zheka
Posts: 223
Joined: 13 Jan 2016
Has thanked: 8 times
Been thanked: 53 times

Re: Duplication of Stoploss in Easy Language Automated Trading  [SOLVED]

Postby Zheka » 04 Oct 2018

sorry, it is indeed in another pair...then disregards my comment..

sternbergleonel
Posts: 12
Joined: 03 Oct 2018

Re: Duplication of Stoploss in Easy Language Automated Trading

Postby sternbergleonel » 04 Oct 2018

Yeah it worked! I combined both long and short strategies into one strategy with only one setstoploss statement. Thanks all. See attached
Attachments
Screenshot 2018-10-04 14.28.50.png
(108.67 KiB) Downloaded 635 times


Return to “MultiCharts”