Hi all,
Here is a simple code asked by one of my website user.
We have a BUY signal (green) if :
Of course, we have a SELL signal (red) for the inverted conditions.
Don’t forget to set “achat” and “vente” to Histogram, and to set the colors.
I also added a blue line with value “0”.
The EMA5 is in red, the TMA8 is in blue.
achat = 0
vente = 0
// INDICATEURS
EMA5 = ExponentialAverage[5](close)
TMA8 = TriangularAverage[8](close)
// ACHAT
ca1 = close[1] < TMA8 and close > TMA8
ca2 = EMA5 > TMA8
IF ca1 and ca2 THEN
achat = 1
ENDIF
// VENTE
cv1 = close[1] > TMA8 and close < TMA8
cv2 = EMA5 < TMA8
IF cv1 and cv2 THEN
vente = -1
ENDIF
return achat as "ACHAT", vente as "VENTE"
You must be logged in to post a comment.
I added a simple momentum indicator (MACD). I think much better results:
achat = 0
vente = 0
MACD12M = MACDline[12,26,9](close)
MACD12S = ExponentialAverage[9](MACD12M)
// INDICATEURS
EMA5 = ExponentialAverage[5](close)
TMA8 = TriangularAverage[8](close)
// ACHAT
ca1 = close[1] < TMA8 and close > TMA8
ca2 = EMA5 > TMA8
IF ca1 and ca2 AND MACD12M>MACD12S AND MACD12M[1]>MACD12S[1] THEN
achat = 1
ENDIF
// VENTE
cv1 = close[1] > TMA8 and close < TMA8
cv2 = EMA5 < TMA8
IF cv1 and cv2 AND MACD12M<MACD12S AND MACD12M[1]<MACD12S[1] THEN
vente = -1
ENDIF
return achat as "ACHAT", vente as "VENTE"
happy New Year !!!