JSParticipant
Senior
I’ve tried it for you but it’s not a good combination.
When I add the RSI, two of the three conditions must make a crossing at the same time because xClose must cross over the average and at the same time the RSI must cross over 20.
The RSI is not a good addition here as a third condition.
If it is not too much to ask – could you just apply any third variable (MACD, RSI, as you deem fit) – for me to see how the code would look like such case. Thank you so much in advance for this and for all your replies before. Very very helpful and very much appreciated.
JSParticipant
Senior
Hi @jonpt88
This is what the code could look like with a third condition.
I have used the example of the RSI here but as indicated the extra RSI condition is not an improvement.
// Festlegen der Code-Parameter
DEFPARAM CumulateOrders = False // Kumulieren von Positionen deaktiviert
Once n=16
// Heikin Ashi setup
once xOpen = open
xClose = (open + close + high + low) / 4
if barindex > 0 then
xOpen = (xOpen + xClose[1]) / 2
endif
xLow = min(low,min(xClose,xOpen))
xHigh = max(high,max(xClose,xOpen))
//
Bullish = xClose > xOpen
Bearish = xClose < xOpen
indicator2 = RSI[n](Close)
// Bedingungen zum Einstieg in Long-Positionen
indicator1 = Average[n](close)
c1 = (Bullish AND Bearish[1]) and xClose Crosses Over indicator1 and indicator2 Crosses Over 20
IF C1 THEN
BUY 1 CONTRACT AT MARKET
ENDIF
// exit LONG trade on a Bearish candlestick
c2 = (Bearish and xClose Crosses Under indicator1)
IF c2 THEN
SELL AT MARKET
ENDIF
// SHORT trades when switching from bullish to bearish
c3 = (Bearish AND Bullish[1]) and xClose < indicator1 and indicator2 Crosses Under 80
IF c3 THEN
SELLSHORT 1 CONTRACT AT MARKET
ENDIF
// exit SHORT trade on a Bullish candlestick
c4 = (Bullish and xClose Crosses Over indicator1)
IF c4 THEN
EXITSHORT AT MARKET
ENDIF