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!
Proper Exit Strategy Code For Each Entry Name
-
- Posts: 11
- Joined: 03 Jan 2020
- Has thanked: 1 time
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2223 times
-
- Posts: 11
- Joined: 03 Jan 2020
- Has thanked: 1 time
Re: Proper Exit Strategy Code For Each Entry Name
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
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
- Kate MultiCharts
- Posts: 598
- Joined: 21 Oct 2020
- Has thanked: 9 times
- Been thanked: 149 times
-
- Posts: 11
- Joined: 03 Jan 2020
- Has thanked: 1 time