Cycle Indicator
Posted: Mon Sep 06, 2021 8:42 pm
Hi Guys,
This is my first indicator so, be kind with me...
I want to use this indicator into a strategy, but i need to use it with different timframe at the same time.
I don't know how to chage my code for achive the result.
could u help me?
TY
study("Cycle", overlay = false, format=format.price, precision=2, resolution="")
//***************************************************
//* MIDDLE CALCULATIONS *
//***************************************************
//A
KAinput = input (3, title = "A Stoch period")
kA = 100*((close - lowest(low,KAinput)) / (highest(high,KAinput) - lowest(low, KAinput)))
A=sma(kA,5)
//B
KBinput = input (3, title = "B Stoch period")
kB = 100*((close - lowest(low,KBinput)) / (highest(high,KBinput) - lowest(low, KBinput)))
B=sma(kB,14)
//C
KCinput = input (14, title = "C Stoch period")
kC = 100*((close - lowest(low,KCinput)) / (highest(high,KCinput) - lowest(low, KCinput)))
C=sma(kC,45)
//D
KDinput = input (20, title = "D Stoch period")
kD = 100*((close - lowest(low,KDinput)) / (highest(high,KDinput) - lowest(low, KDinput)))
D=sma(kD,75)
//***************************************************
//* INDICATOR FORMULE *
//***************************************************
I=(4.1*A+ 2.5*B+ C + 4*D)/11.6
mm=sma(I,9)
Cycle= I-mm
//***************************************************
//* PLOTS *
//***************************************************
p1=plot(Cycle,color=color.blue)
p2=plot(0, color = color.gray)
fill(p1, p2, color = Cycle > 0 ? color.green : color.red)
This is my first indicator so, be kind with me...
I want to use this indicator into a strategy, but i need to use it with different timframe at the same time.
I don't know how to chage my code for achive the result.
could u help me?
TY
study("Cycle", overlay = false, format=format.price, precision=2, resolution="")
//***************************************************
//* MIDDLE CALCULATIONS *
//***************************************************
//A
KAinput = input (3, title = "A Stoch period")
kA = 100*((close - lowest(low,KAinput)) / (highest(high,KAinput) - lowest(low, KAinput)))
A=sma(kA,5)
//B
KBinput = input (3, title = "B Stoch period")
kB = 100*((close - lowest(low,KBinput)) / (highest(high,KBinput) - lowest(low, KBinput)))
B=sma(kB,14)
//C
KCinput = input (14, title = "C Stoch period")
kC = 100*((close - lowest(low,KCinput)) / (highest(high,KCinput) - lowest(low, KCinput)))
C=sma(kC,45)
//D
KDinput = input (20, title = "D Stoch period")
kD = 100*((close - lowest(low,KDinput)) / (highest(high,KDinput) - lowest(low, KDinput)))
D=sma(kD,75)
//***************************************************
//* INDICATOR FORMULE *
//***************************************************
I=(4.1*A+ 2.5*B+ C + 4*D)/11.6
mm=sma(I,9)
Cycle= I-mm
//***************************************************
//* PLOTS *
//***************************************************
p1=plot(Cycle,color=color.blue)
p2=plot(0, color = color.gray)
fill(p1, p2, color = Cycle > 0 ? color.green : color.red)