SetStopLoss with highs and lows.

Questions about MultiCharts and user contributed studies.
Eric1704
Posts: 20
Joined: 29 Nov 2022
Has thanked: 8 times

SetStopLoss with highs and lows.

Postby Eric1704 » 16 Feb 2023

Hi. Can the keyword SetStopLoss in Stop Loss default Signal be modified and used with highs and lows instead of dollar amount? Like stop at high of bar number 5 or stop at lowest of last 2 bars? Is price recognized by this keyword?
Thanks.

ScottishSpeculator
Posts: 47
Joined: 03 Jan 2023
Been thanked: 3 times

Re: SetStopLoss with highs and lows.

Postby ScottishSpeculator » 18 Feb 2023

I think you can create a variable and just reference it with stop. Someone will probably correct this but off top of head something like

Code: Select all

Input: Length(2); Var: stophigh(0); stophigh = Highest(High, Length); If marketposition =-1 then begin buytocover next bar at stophigh stop; end;

Eric1704
Posts: 20
Joined: 29 Nov 2022
Has thanked: 8 times

Re: SetStopLoss with highs and lows.

Postby Eric1704 » 20 Feb 2023

I think you can create a variable and just reference it with stop. Someone will probably correct this but off top of head something like

Code: Select all

Input: Length(2); Var: stophigh(0); stophigh = Highest(High, Length); If marketposition =-1 then begin buytocover next bar at stophigh stop; end;
Thanks. This works if you wait for a bar after entry to set the stop. I want it done right after entry on same bar. So have to use SetStopLoss which can only be in dollars or points I was told.
Thanks.

ScottishSpeculator
Posts: 47
Joined: 03 Jan 2023
Been thanked: 3 times

Re: SetStopLoss with highs and lows.

Postby ScottishSpeculator » 20 Feb 2023

hmm I am new myself to PL , id also like to know the solution. Perhaps you can use 2 different data sources in code with different time frames. What bar time frame are you using? If it was daily then perhaps you could set up a data2 with smaller time frame so it would occur within the daily bar?

Eric1704
Posts: 20
Joined: 29 Nov 2022
Has thanked: 8 times

Re: SetStopLoss with highs and lows.

Postby Eric1704 » 21 Feb 2023

hmm I am new myself to PL , id also like to know the solution. Perhaps you can use 2 different data sources in code with different time frames. What bar time frame are you using? If it was daily then perhaps you could set up a data2 with smaller time frame so it would occur within the daily bar?
I am using mostly 5 and 15 minute charts. Does not make sense to use a second data series if I am trading on one time frame. One way to do that would be to turn on IOG that would really slow down your program depending on how many charts you have open. Anyone from MC see these posts to offer any help??

User avatar
Svetlana MultiCharts
Posts: 645
Joined: 19 Oct 2017
Has thanked: 3 times
Been thanked: 163 times

Re: SetStopLoss with highs and lows.

Postby Svetlana MultiCharts » 22 Feb 2023

Hi Eric1704,
Can the keyword SetStopLoss in Stop Loss default Signal be modified and used with highs and lows instead of dollar amount?
No, it cannot. Stop Loss is always calculated as an offset from the entry price.
You can use regular stop orders for your needs.

Eric1704
Posts: 20
Joined: 29 Nov 2022
Has thanked: 8 times

Re: SetStopLoss with highs and lows.

Postby Eric1704 » 22 Feb 2023

Hi Eric1704,
Can the keyword SetStopLoss in Stop Loss default Signal be modified and used with highs and lows instead of dollar amount?
No, it cannot. Stop Loss is always calculated as an offset from the entry price.
You can use regular stop orders for your needs.
Thanks. I do not want to wait for a bar to close to place an order. That is why I am using SetStopLoss for stop right away upon entry bar itself.

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

Re: SetStopLoss with highs and lows.

Postby TJ » 23 Feb 2023

If you want to trade at the end of the bar, but set your stop intra-bar, you can do the following:

1. Enable IOG IntrabarOrderGeneration.
2. On your trading logic, add BARSTATUS=2.

Eric1704
Posts: 20
Joined: 29 Nov 2022
Has thanked: 8 times

Re: SetStopLoss with highs and lows.

Postby Eric1704 » 23 Feb 2023

If you want to trade at the end of the bar, but set your stop intra-bar, you can do the following:

1. Enable IOG IntrabarOrderGeneration.
2. On your trading logic, add BARSTATUS=2.
Thanks TJ. Does setting IOG to ON slow down MC in any way? Especially with an instrument like NQ.
Thanks.

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

Re: SetStopLoss with highs and lows.

Postby TJ » 23 Feb 2023

If you want to trade at the end of the bar, but set your stop intra-bar, you can do the following:

1. Enable IOG IntrabarOrderGeneration.
2. On your trading logic, add BARSTATUS=2.
Thanks TJ. Does setting IOG to ON slow down MC in any way? Especially with an instrument like NQ.
Thanks.
No, not that I can notice.

At any rate, with today's computer prices, you can always get a more powerful computer, for very little money.

Eric1704
Posts: 20
Joined: 29 Nov 2022
Has thanked: 8 times

Re: SetStopLoss with highs and lows.

Postby Eric1704 » 24 Feb 2023

If you want to trade at the end of the bar, but set your stop intra-bar, you can do the following:

1. Enable IOG IntrabarOrderGeneration.
2. On your trading logic, add BARSTATUS=2.
Thanks TJ. Does setting IOG to ON slow down MC in any way? Especially with an instrument like NQ.
Thanks.
No, not that I can notice.

At any rate, with today's computer prices, you can always get a more powerful computer, for very little money.
Thanks TJ. I have seen like half a second to a secong lag between time a bar closes and order generation. Maybe upgrade the VPS?

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

Re: SetStopLoss with highs and lows.

Postby TJ » 24 Feb 2023

Thanks TJ. I have seen like half a second to a secong lag between time a bar closes and order generation. Maybe upgrade the VPS?
Theoretically, it should not make a difference.

Your need is to evaluate the stop position at every tick. Whether it is done through the built-in stoploss or through coding, MC will have to do the same calculation.

Eric1704
Posts: 20
Joined: 29 Nov 2022
Has thanked: 8 times

Re: SetStopLoss with highs and lows.

Postby Eric1704 » 24 Feb 2023

Thanks TJ. I have seen like half a second to a secong lag between time a bar closes and order generation. Maybe upgrade the VPS?
Theoretically, it should not make a difference.

Your need is to evaluate the stop position at every tick. Whether it is done through the built-in stoploss or through coding, MC will have to do the same calculation.
What I have seen with MC is the lag of a second or so after bar close to see entry order pop up. In NT 8 it is almost instantaneous. No lag.


Return to “MultiCharts”