Proper Exit Strategy Code For Each Entry Name

Questions about MultiCharts and user contributed studies.
3Dimention
Posts: 11
Joined: 03 Jan 2020
Has thanked: 1 time

Proper Exit Strategy Code For Each Entry Name

Postby 3Dimention » 02 Sep 2021

hey, so how do I code for two separate strategies whereby their exits will only work for their corresponding entry order.

Example rule - assume both strategies have an open position:

If {rule1 = true} then Buy ("LE_Spiker") next bar market ;
If {long under} ("LE_Spiker") and {rule2 = true} then {only} sell ("LE_Spiker") next bar market ;

If {rule3 = true} then Buy ("LE_Trend") next bar market ;
If {long under} ("LE_Trend") and {rule4 = true} then {only} sell ("LE_Trend") next bar market ;


So if I'm long both signals, I only want to sell if that position's particular rule is triggered, but not the other.

Hope that makes sense, and thank you! :D

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

Re: Proper Exit Strategy Code For Each Entry Name

Postby TJ » 02 Sep 2021

See post #1 & #2
1. [FAQ] How to Post Codes ... so that people can read.
viewtopic.php?t=11713

3Dimention
Posts: 11
Joined: 03 Jan 2020
Has thanked: 1 time

Re: Proper Exit Strategy Code For Each Entry Name

Postby 3Dimention » 02 Sep 2021

OK, Take 2:


If C > C[1] then Buy ("LE_Spiker") next bar market ; // example 1 of 2 entry name

If H > H[1] then sell ("SPK_LX") next bar H stop {the "LE_Spike" position} ; // I only want to sell the position opened by the "LE_Spike" position and/or not a different strategy position (such as the example below) that might be open at the same time


If C > C[2] then Buy ("LE_Trend") next bar market ; // example 2 of 2 entry name

If H > H[3] then sell ("TRN_LX") next bar H stop {the "LE_Trend" position} ; // I only want to sell the position opened by the "LE_Trend" position and/or not a different strategy position (such as the example above) that might be open at the same time

User avatar
Kate MultiCharts
Posts: 575
Joined: 21 Oct 2020
Has thanked: 7 times
Been thanked: 144 times

Re: Proper Exit Strategy Code For Each Entry Name

Postby Kate MultiCharts » 09 Sep 2021

Hello 3Dimention,

You could try using the From Entry parameter for Sell.
More info here.

3Dimention
Posts: 11
Joined: 03 Jan 2020
Has thanked: 1 time

Re: Proper Exit Strategy Code For Each Entry Name

Postby 3Dimention » 09 Sep 2021

There it is. Thank you, Kate. Well done.


Return to “MultiCharts”