I’m going to post an example since it’s too hard to explain in plain text.
Let’s say my strategy is based off the Adaptive Moving Average indicator and the Stochastic indicator exclusively.
The first screenshot is what it looks like in a 30min chart (1k candles)
My code (example, used probuilder):
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
// Conditions to enter long positions
indicator1 = AdaptiveAverage[20,2,3000](close)
indicator2 = AdaptiveAverage[70,2,3000](close)
c1 = (indicator1 CROSSES OVER indicator2)
indicator3 = Stochastic[100,50](close)
c2 = (indicator3 < 20) IF c1 AND c2 THEN BUY 1 CONTRACT AT MARKET ENDIF // Conditions to exit long positions indicator4 = AdaptiveAverage[20,2,3000](close) indicator5 = AdaptiveAverage[70,2,3000](close) c3 = (indicator4 CROSSES UNDER indicator5) IF c3 THEN SELL AT MARKET ENDIF // Conditions to enter short positions indicator6 = AdaptiveAverage[20,2,3000](close) indicator7 = AdaptiveAverage[70,2,3000](close) c4 = (indicator6 CROSSES UNDER indicator7) indicator8 = Stochastic[100,50](close) c5 = (indicator8 > 80) My problem lies in c2 and c5 where I only need it the stochastic K% line to be under 20 when the “faster, black” adaptive MA crosses over the “slower, red” one. The K% line doesn’t need to be under 20 if the K% line keeps being over the D% line, meaning if the K% line crosses under the D% line before the K% line hits the value 80 only then can the system halt buying new contracts. If not then the system can solely rely on the adaptive MA indicators as long as the K% line keeps being over the D% line
IF c4 AND c5 THEN
SELLSHORT 1 CONTRACT AT MARKET
ENDIF
// Conditions to exit short positions
indicator9 = AdaptiveAverage[20,2,3000](close)
indicator10 = AdaptiveAverage[70,2,3000](close)
c6 = (indicator9 CROSSES OVER indicator10)
IF c6 THEN
EXITSHORT AT MARKET
ENDIF