PHP Code:
//@version=5
strategy(title='Moonhub Cycle Index', shorttitle='deneme', overlay=true)
// Input parameters
len_DIema = input.int(5, minval=1, title='COEMA Length')
len_DIsma = input.int(20, minval=1, title='COSMA Length')
start1 = input(0)
increment1 = input(0.1)
maximum1 = input(1, "Max Value")
out1 = ta.sar(start1, increment1, maximum1)
start2 = input(0)
increment2 = input(0.01)
maximum2 = input(0.1, "Max Value")
out2 = ta.sar(start2, increment2, maximum2)
start3 = input(0.1)
increment3 = input(0.1)
maximum3 = input(0.1, "Max Value")
out3 = ta.sar(start3, increment3, maximum3)
// Create a custom index
index = (out1 + out2 + out3) / 3
// Calculate COEMA and COSMA for the Custom Index
DI_index_Co_E = ta.ema(index, len_DIema)
DI_Co_indexS = ta.sma(index, len_DIsma)
// Plot the index
plot(index, title='Index', color=color.new(#ff5252, 100), linewidth=2)
plot(DI_index_Co_E, title='5EMA', color=color.new(#2195f3, 100), linewidth=2)
plot(DI_Co_indexS, title='20SMA', color=color.new(#4caf4f, 100), linewidth=2)
changebarcol = input.bool(true, title='Change Bar Color', inline='bcol')
bcolup = input.color(color.rgb(103, 243, 76), title='', inline='bcol')
bcoldn = input.color(color.rgb(248, 78, 78), title='', inline='bcol')
var color lastBarColor = na
BullishColor = input.color(color.rgb(125, 247, 77))
BearishColor = input.color(color.rgb(245, 76, 76))
barColorBasedOnDEMATrend = close > out1 and close > out2 and close > out3 ? BullishColor : close < out1 and close < out2 and close < out3 ? BearishColor : nz(lastBarColor[1])
lastBarColor := barColorBasedOnDEMATrend
barcolor(color=changebarcol ? barColorBasedOnDEMATrend : na)
xa = ta.crossover(close,out1) and ta.crossover(close,out2) and ta.crossover(close,out3)
ys = ta.crossunder(close,out1) and ta.crossunder(close,out2) and ta.crossunder(close,out3)
in_b = ta.barssince(xa)[1] < ta.barssince(ys)[1]
in_s = ta.barssince(ys)[1] < ta.barssince(xa)[1]
if xa
strategy.entry("Long",strategy.long)
if ys
strategy.close("Long")
///////////////////////////////////////////////////
Yer İmleri