0% found this document useful (0 votes)
138 views

EMA CDC LuaScript

The document defines an indicator with multiple moving average and stochastic RSI signals. It includes: - Inputs to configure the RSI, KDJ, fast/slow/trend moving averages, and StochRSI levels - Plots the moving averages and draws arrows/areas for signals based on crosses between the averages and StochRSI levels - Draws arrows on the chart at candle closes when signals are generated
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
138 views

EMA CDC LuaScript

The document defines an indicator with multiple moving average and stochastic RSI signals. It includes: - Inputs to configure the RSI, KDJ, fast/slow/trend moving averages, and StochRSI levels - Plots the moving averages and draws arrows/areas for signals based on crosses between the averages and StochRSI levels - Draws arrows on the chart at candle closes when signals are generated
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 6

instrument {

name = 'EMA CDC',


short_name = 'EMA CDC',
icon = 'https://document-export.canva.com/E_v8w/DAEnLmE_v8w/27/thumbnail/
0001.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAQYCGKMUHWDTJW6UD
%2F20210819%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210819T045322Z&X-Amz-
Expires=83842&X-Amz-
Signature=60ed1040581d846265865dabcf9c62ed39dd618b19976fd445ff043467aba233&X-Amz-
SignedHeaders=host&response-expires=Fri%2C%2020%20Aug%202021%2004%3A10%3A44%20GMT',
overlay = true
}

RSI_period = input(14,"RSI period",input.integer,1,1000,1)


RSI_average = input(4,"RSI Average",input.string_selection,averages.titles)

K_period = input(13,"K period",input.integer,1,1000,1)


K_title = input(1,"K apply price",input.string_selection,inputs.titles)
D_period = input(3,"D period",input.integer,1,1000,1)
Smooth = input(3,"SMA Smooth",input.integer,1,1000,1)

Sto_OVB = input(80,"Sto OVB",input.double,0.01,100,1,false)


Sto_OVS = input(20,"Sto OVS",input.double,0.01,100,1,false)
--print(Sto_OVB,Sto_OVS)

MaFast_period = input(12,"Ma Fast period",input.integer,1,1000,1)


MaFast_average = input(2,"Ma Fast average", input.string_selection,averages.titles)
MaFast_title = input(1,"Ma Fast title", input.string_selection,inputs.titles)

MaSlow_period = input(26,"Ma Slow period",input.integer,1,1000,1)


MaSlow_average = input(2,"Ma Slow average", input.string_selection,averages.titles)
MaSlow_title = input(1,"Ma Slow title", input.string_selection,inputs.titles)

MaTrend_period = input(200,"Ma Trend period",input.integer,1,1000,5)


MaTrend_average = input(2,"Ma Trend average",
input.string_selection,averages.titles)
MaTrend_title = input(1,"Ma Trend title", input.string_selection,inputs.titles)

input_group {
"Ma Fast Line",
colorFast = input { default = "#ff56e8", type = input.color },
widthFast = input { default = 1, type = input.line_width},
visibleFast = input { default = false, type = input.plot_visibility }
}

input_group {
"Ma Slow Line",
colorSlow = input { default = "#2d2af7", type = input.color },
widthSlow = input { default = 2, type = input.line_width},
visibleSlow = input { default = false, type = input.plot_visibility }
}

input_group {
"Ma Trend Line",
colorTrend = input { default = "#f74200", type = input.color },
widthTrend = input { default = 3, type = input.line_width},
visibleTrend = input { default = false, type = input.plot_visibility }
}

input_group {
"StochRSI cross up OVS (no filter)",
colorBuy = input { default = "LightGreen", type = input.color },
visibleBuy = input { default = true, type = input.plot_visibility }
}

input_group {
"StochRSI cross down OVB (no filter)",
colorSell = input { default = "Salmon", type = input.color },
visibleSell = input { default = true, type = input.plot_visibility }
}

input_group {
"StochRSI signal cross up Trend filter",
colorBuy1 = input { default = "rgba(50, 205, 50,0.8)", type = input.color },
visibleBuy1 = input { default = true, type = input.plot_visibility }
}

input_group {
"StochRSI signal cross down Trend filter",
colorSell1 = input { default = "rgba(255, 0, 0,0.8)", type = input.color },
visibleSell1 = input { default = true, type = input.plot_visibility }
}

input_group {
"Area",
colorAreaUp = input { default = "rgba(60, 179, 113,0.8)", type = input.color },
colorAreaDown = input { default = "rgba(199, 21, 133,0.8)", type =
input.color },
visibleArea = input { default = true, type = input.plot_visibility }
}

input_group {
"Ma cross up Trend filter",
colorArrowUp = input { default = "rgba(60, 179, 113,0.8)", type =
input.color },
visibleArrowUp = input { default = true, type = input.plot_visibility }
}

input_group {
"Ma cross down Trend filter",
colorArrowDown = input { default = "rgba(199, 21, 133,0.8)", type = input.color
},
visibleArrowDown = input { default = true, type = input.plot_visibility }
}

input_group {
"Ma cross up StochRSI filter",
colorMASRUp = input { default = "rgba(60, 179, 113,0.4)", type = input.color },
visibleMASRUp = input { default = true, type = input.plot_visibility }
}

input_group {
"Ma cross down StochRSI filter",
colorMASRDown = input { default = "rgba(199, 21, 133,0.4)", type =
input.color },
visibleMASRDown = input { default = true, type = input.plot_visibility }
}
local avgFast = averages[MaFast_average]
local titleFast = inputs[MaFast_title]

local avgSlow = averages[MaSlow_average]


local titleSlow = inputs[MaSlow_title]

local avgTrend = averages[MaTrend_average]


local titleTrend = inputs[MaTrend_title]

if visibleFast == true then


plot(avgFast(titleFast,MaFast_period),"Ma Fast",colorFast,widthFast)
end

if visibleSlow == true then


plot(avgSlow(titleSlow,MaSlow_period),"Ma Slow",colorSlow,widthSlow)
end

if visibleTrend == true then


plot(avgTrend(titleTrend,MaTrend_period),"Ma Trend",colorTrend,widthTrend)
end

candle_time = {"1s", "5s", "10s", "15s", "30s", "1m", "2m", "5m", "10m", "15m",
"30m", "1H", "2H", "4H", "8H", "12H", "1D", "1W", "1M", "1Y"}
candle_time_res = input(6,"Candle check
resolution",input.string_selection,candle_time)

sec = security (current_ticker_id, candle_time[candle_time_res])

local SK_title = inputs[K_title]


local RSI_AVG = averages[RSI_average]

delta = SK_title - SK_title[1]


up = RSI_AVG(max(delta,0), RSI_period)
down = RSI_AVG(max(-delta,0), RSI_period)
RS = up/down

RES = 100 - 100/(1+RS)

LL = lowest(RES,K_period)
HH = highest(RES,K_period)
K = (RES - LL) / (HH - LL)

Per_K = (sma(K,Smooth))*100
Per_D = sma(Per_K,D_period)

--plot(Per_K,"Per_K","Cyan",1)
--plot(Per_D,"Per_D","Orange",1)

if (sec ~= nil) and (sec.open_time == open_time) then

MaFast0 = avgFast(titleFast,MaFast_period) --Ma Fast bar 0


MaFast1 = MaFast0[1] --Ma Fast bar 1

MaSlow0 = avgSlow(titleSlow,MaSlow_period) --Ma Slow bar 0


MaSlow1 = MaSlow0[1] --Ma Slow bar 1

MaTrend0 = avgTrend(titleTrend,MaTrend_period) --Ma Trend 0


MaTrend1 = MaTrend0[1] --Ma Trend 1
if(visibleBuy == true) then
plot_shape(Per_K[1] < Sto_OVS and Per_K > Sto_OVS ,
"Call",
shape_style.arrowup,
shape_size.huge,
colorBuy,
shape_location.belowbar,
0,
"OVS",
colorBuy
)
end

if(visibleSell == true) then


plot_shape(Per_K[1] > Sto_OVB and Per_K < Sto_OVB ,
"Put",
shape_style.arrowdown,
shape_size.huge,
colorSell,
shape_location.abovebar,
0,
"OVB",
colorSell
)
end

if(visibleBuy1 == true) then


plot_shape(Per_K > Per_D and Per_K[1] < Per_D[1] and close > MaFast0 and
MaFast0 > MaSlow0 and MaSlow0 > MaTrend0 ,
"Call1",
shape_style.arrowup,
shape_size.huge,
colorBuy1,
shape_location.belowbar,
0,
"SRX",
colorBuy1
)
end

if(visibleSell1 == true) then


plot_shape(Per_K < Per_D and Per_K[1] > Per_D[1] and close < MaFast0 and
MaFast0 < MaSlow0 and MaSlow0 < MaTrend0 ,
"Put1",
shape_style.arrowdown,
shape_size.huge,
colorSell1,
shape_location.abovebar,
0,
"SRX",
colorSell1
)
end

if (visibleArea == true) then


fill(MaFast0,MaSlow0,"Area", MaFast0 > MaSlow0 and colorAreaUp or MaFast0 <
MaSlow0 and colorAreaDown )

end
if(visibleArrowUp == true) then
plot_shape(MaFast0 > MaSlow0 and MaFast0[1] < MaSlow0[1] and MaFast0 >
MaTrend0 and MaSlow0 > MaTrend0 ,
"Call2",
shape_style.arrowup,
shape_size.huge,
colorArrowUp,
shape_location.belowbar,
0,
"Xup",
colorArrowUp
)
end

if(visibleArrowDown == true) then


plot_shape(MaFast0 < MaSlow0 and MaFast0[1] > MaSlow0[1] and MaFast0 <
MaTrend0 and MaSlow0 < MaTrend0 ,
"Put2",
shape_style.arrowdown,
shape_size.huge,
colorArrowDown,
shape_location.abovebar,
0,
"Xdn",
colorArrowDown
)
end

if(visibleMASRUp == true) then


plot_shape(MaFast0 > MaSlow0 and MaFast0[1] < MaSlow0[1] and Per_K >
Per_D ,
"Call3",
shape_style.arrowup,
shape_size.huge,
colorMASRUp,
shape_location.belowbar,
0,
"MASR",
colorMASRUp
)
end

if(visibleMASRDown == true) then


plot_shape(MaFast0 < MaSlow0 and MaFast0[1] > MaSlow0[1] and Per_K <
Per_D ,
"Put3",
shape_style.arrowdown,
shape_size.huge,
colorMASRDown,
shape_location.abovebar,
0,
"MASR",
colorMASRDown
)
end

end

You might also like