Nicolas

Supertrend + CCI

Category: Indicators By: Nicolas Created: January 6, 2021, 1:29 PM
January 6, 2021, 1:29 PM
Indicators
12 Comments
Supertrend + CCI

Another SuperTrend version, which uses the ATR distance from price to calculate its own levels, but this time combined with CCI condition to turn bullish or bearish.

You can modify the CCI period into the setting and also at which level the Supertrend can switch from bullish trend to bearish trend and vice-versa.

Indicator translated from MT5 version, following a request into the Indicator’s forum:

https://www.prorealcode.com/topic/conversion-indicateur-supertrend-mt5/

//PRC_Supertrend+CCI | indicator
//06.01.2021
//Nicolas @ www.prorealcode.com
//Sharing ProRealTime knowledge
//converted from MT5 version 

// --- settings 
CCIPeriod=50 // CCI indicator period
ATRPeriod=5  // ATR indicator period
Level=0 // CCI activation level
// --- end of settings

icci = CCI[CCIPeriod](typicalPrice)
iatr = AverageTrueRange[ATRPeriod](close)
TrendUp=0.0
TrendDown=0.0
SignUp=0.0
SignDown=0.0

if(iCCI>=Level and iCCI[1]<Level) then 
 TrendUp=TrendDown[1]
endif

if(iCCI<=Level and iCCI[1]>Level) then
 TrendDown=TrendUp[1]
endif

if(iCCI>Level) then 
 TrendUp=low-iATR
 r=0
 g=255
 if(TrendUp<TrendUp[1] and iCCI[1]>=Level) then 
  TrendUp=TrendUp[1]
 endif
endif
if(iCCI<Level) then 
 TrendDown=high+iATR
 r=255
 g=0
 if(TrendDown>TrendDown[1] and iCCI[1]<=Level) then 
  TrendDown=TrendDown[1]
 endif
endif
if(TrendDown[1]<>0.0 and TrendUp<>0.0) then 
 SignUp=TrendUp
 drawtext("●",barindex,signup,dialog,bold,20) coloured(72,209,204)
endif
if(TrendUp[1]<>0.0 and TrendDown<>0.0) then 
 SignDown=TrendDown
 drawtext("●",barindex,signdown,dialog,bold,20) coloured(255,140,0)
endif 
st = max(trendup,trenddown)
 

return st coloured(r[1],g[1],0) style(line,2) as "Supertrend+CCI"

 

 

Download
Filename: PRC_SupertrendCCI.itf
Downloads: 1006
Nicolas
Nicolas Legend
I created ProRealCode because I believe in the power of shared knowledge. I spend my time coding new tools and helping members solve complex problems. If you are stuck on a code or need a fresh perspective on a strategy, I am always willing to help. Welcome to the community!
Author’s Profile

Comments

redisdead
5 years ago
#

Bonjour, J'ai cherché sur le forum une trace de la demande de robi38 sans résultat. Est il possible de savoir si le passage en screener a été fait ? Est il possible de choisir un horizon de temps antérieurs où le signal hausse / baisse est détecté ? (par exemple : faire la recherche pour un signal détecté il y a 5 jours) Merci

robi38
6 years ago
#

Bonjour, est-il possible d'avoir un screener faisant ressortir les valeurs dont l'indicateur vient de passer au vert ? Merci pour votre réponse

Nicolas
6 years ago
#

oui bien sûr, merci de formuler la demande dans le forum ProScreener en respectant les règles de publication.

jebou02300
6 years ago
#

Merci beaucoup pour votre travail et le partage !

Novice_Surfer
6 years ago
#

Bonjour Nicolas, comment faites-vous pour afficher votre indicateur directement sur le graphique de cotation svp ? Chez moi il s'affiche en dessous, de la même façon que s'affiche le RSI ou le MACD.

Nicolas
6 years ago
#

Appliquez le sur le prix.

DimKar
6 years ago
#

Very nice thank you for sharing

ndu159
6 years ago
#

ATRPeriod=5 // ATR indicator period syntax error :unexpected identifier any correction suggestions

Nicolas
6 years ago
#

This is a code to be used on the ProRealTime platform. https://www.prorealtime.com

Razz
6 years ago
#

Sorry ;-)))

Razz
6 years ago
#

Hello Nicolas Whether the level is 0 or 1 makes no difference in the display is that normal?

Nicolas
6 years ago
#

The CCI scale is -100 / +100 , so indeed it will not make a big difference if you set that setting to 1 only! :)

ProRealCode ProRealCode
Loading...