Hi all,
Here is a simple code asked by one of my website user.
We have a BUY signal (green) if :
- the exponential average 5 (close) > the triangular average 8 (close)
- close > triangular average 8 but close of the previous candle < triangular average 8
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
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" |
Share this
No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.
ProRealTime ITF files and other attachments :PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials
I added a simple momentum indicator (MACD). I think much better results:
achat = 0vente = 0MACD12M = MACDline[12,26,9](close)MACD12S = ExponentialAverage[9](MACD12M)
// INDICATEURSEMA5 = ExponentialAverage[5](close)TMA8 = TriangularAverage[8](close)
// ACHATca1 = close[1] < TMA8 and close > TMA8ca2 = EMA5 > TMA8
IF ca1 and ca2 AND MACD12M>MACD12S AND MACD12M[1]>MACD12S[1] THENachat = 1ENDIF
// VENTEcv1 = close[1] > TMA8 and close < TMA8cv2 = EMA5 < TMA8
IF cv1 and cv2 AND MACD12M<MACD12S AND MACD12M[1]<MACD12S[1] THENvente = -1ENDIF
return achat as “ACHAT”, vente as “VENTE”
happy New Year !!!
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
ca3 = MACD12M>MACD12S AND MACD12M[1]>MACD12S[1]
IF ca1 and ca2 AND ca3 THEN
achat = 1
ENDIF
// VENTE
cv1 = close[1] > TMA8 and close < TMA8
cv2 = EMA5 < TMA8
cv3 = MACD12M<MACD12S AND MACD12M[1]<MACD12S[1]
IF cv1 and cv2 AND cv3 THEN
vente = -1
ENDIF
return achat as \"ACHAT\", vente as \"VENTE\"