Setstoploss do not work correct

Questions about MultiCharts and user contributed studies.
User avatar
Xurma
Posts: 31
Joined: 24 Nov 2020
Has thanked: 9 times

Setstoploss do not work correct

Postby Xurma » 02 Jan 2021

Happy new year everybody.
I have the issue - Setstoploss do not work. Please look at screenshot. I have really small stop - Setstoploss(10);
Upper screen is 1 day chart, lower screen is 1 hour chart. On 1 hour chart clearly can see that stop have to be worked, because 10$ stop is 0,01$ price movement. In my case enter was on price level 52.62$ and the lowest point after entering was 52.29$
Why Setstoploss not working correctly?
stop.jpg
(301.85 KiB) Not downloaded yet

User avatar
lingwuchung
Posts: 50
Joined: 03 Feb 2014
Has thanked: 6 times

Re: Setstoploss do not work correct

Postby lingwuchung » 03 Jan 2021

Is this real/paper trade or backtesting?

User avatar
Xurma
Posts: 31
Joined: 24 Nov 2020
Has thanked: 9 times

Re: Setstoploss do not work correct

Postby Xurma » 03 Jan 2021

Is this real/paper trade or backtesting?
This is backtest

User avatar
lingwuchung
Posts: 50
Joined: 03 Feb 2014
Has thanked: 6 times

Re: Setstoploss do not work correct

Postby lingwuchung » 03 Jan 2021

Is this real/paper trade or backtesting?
This is backtest
Then I am not sure if you are having the same issue as me: viewtopic.php?t=52924

Try to call the setstoploss(10) at EVERY BAR (unconditionally, say at top of the main iteration) and see if that makes a difference.

sptrader
Posts: 742
Joined: 09 Apr 2010
Location: Texas
Has thanked: 483 times
Been thanked: 274 times
Contact:

Re: Setstoploss do not work correct

Postby sptrader » 03 Jan 2021

I think the shortest time frame (1hour) needs to be data1 and daily on Data2.

User avatar
Vlada MultiCharts
Posts: 292
Joined: 22 Apr 2020
Has thanked: 8 times
Been thanked: 76 times

Re: Setstoploss do not work correct

Postby Vlada MultiCharts » 04 Jan 2021

Hello,

On our end the issue you described is not reproduced.
Please revise your signal code and temporarily comment out other exits.

Also you can try to apply this code on a new chart:

Code: Select all

buy next bar 52.62 limit; setstopcontract; setstoploss(10);

User avatar
syswizard
Posts: 295
Joined: 15 Dec 2012
Has thanked: 16 times
Been thanked: 28 times

Re: Setstoploss do not work correct

Postby syswizard » 11 Jan 2021

On our end the issue you described is not reproduced.
Please revise your signal code and temporarily comment out other exits.

Also you can try to apply this code on a new chart:

Code: Select all

buy next bar 52.62 limit; setstopcontract; setstoploss(10);
Well, I think this one issue is still not fully addressed:
1) Can SetStopLoss (and the other built-in exits) be set CONDITIONALLY.
ex:

Code: Select all

If OpenPositionProfit > 1000 Then SetStopLoss(100) Else if OpenPositionProfit < 500 SetStopLoss(50);
From what I understand, when used in a conditional, the stop loss order is only thrown at the end of the bar, not Intrabar, unless [intrabarordergeneration=True] is declared.
Am I right ?

User avatar
Vlada MultiCharts
Posts: 292
Joined: 22 Apr 2020
Has thanked: 8 times
Been thanked: 76 times

Re: Setstoploss do not work correct

Postby Vlada MultiCharts » 02 Feb 2021

syswizard,

Yes, your understanding is correct.
With Intra Bar Order Generation disabled, the new parameters of the orders are applied on the bar close.


Return to “MultiCharts”