0% found this document useful (0 votes)
22 views6 pages

多空

Uploaded by

maobeiyong
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views6 pages

多空

Uploaded by

maobeiyong
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 6

//@version=5

// srflip2011

// Ema Crossover Alerts are setup with Ema 1 & Ema 2


indicator(title='需要稳定的策略脚本。联系地球 V:ar8w17', overlay=true)

// --- inputs
source = close
TITLE = input(false, title='Turn on Alerts & Enable Background Color options are
based on EMA1 & EMA2 Crossovers, (This button does nothing)')
turnon2 = input(true, title='Turn on Alerts?')
colorbars = input(true, title = "Color Bars?")
colorbars2 = input(true,title = "Color Bar when price closes under / above Ema 1 &
2?" , inline = "1")
barc1 = input (color.rgb(0, 38, 255), "", inline = "1")
barc2 = input(color.orange, "", inline ="1")
turnon = input(true, title='Turn on Ema 1 & 2?')
backgroundcolor = input(false, title='Enable Background Color?')

// Dashboard
showTable = input.bool(defval=false, title='Display Ema Dashboard', group='EMA
Dashboard🤖')
tablePosition = input.string(title='Dashboard Position?', defval=position.top_right,
options=[position.bottom_left, position.top_left, position.bottom_right,
position.top_right], group='Trend Dashboard🤖', tooltip = "Allows you to change the
position of the dashboard on the chart.")
tableTextSize = input.string(title='Dashboard Size?', defval=size.small,
options=[size.auto, size.tiny, size.small, size.normal, size.large, size.huge],
group='Trend Dashboard🤖', tooltip = "Use Tiny if on Mobile, Use Small if on Web
browser.")

//Ema 1 & 2
len1 = input.int(10, minval=1, title='EMA1')
len2 = input.int(21, minval=1, title='EMA2')
ema1 = ta.ema(source, len1)
ema2 = ta.ema(source, len2)
//---

cond1 = ta.crossover(close,ema1) and ta.crossover(close,ema2)


cond2 = ta.crossunder(close,ema1) and ta.crossunder(close,ema2)

barcolor(cond1 ? color.rgb(0, 38, 255) : cond2 ? color.orange: na)


alertcondition(cond1, title = "Alert when price rises above Ema1 and Ema 2?",
message = "Price rose above Ema 1 & Ema 2")
alertcondition(cond2, title = "Alert when price drops below Ema1 and Ema 2?",
message = "Price closed below Ema 1 & Ema 2")
//-- Candle Color
colbar = ema1 > ema2 ? color.rgb(15, 250, 23) : color.rgb(255, 0, 0)
barcolor(colorbars ? colbar :na)

// --- Ema Inputs


//Ema 3
turnon3 = input(false, title='Turn on EMA3?')
len3 = input.int(5, minval=1, title='EMA3')
ema3 = ta.ema(source, len3)
plot(turnon3 ? ema3 : na, 'Ema 3', style=plot.style_line, linewidth=2,
color=color.new(color.blue, 0))

//Ema 4
turnon4 = input(false, title='Turn on EMA4')
len4 = input.int(8, minval=1, title='EMA4')
ema4 = ta.ema(source, len4)
plot(turnon4 ? ema4 : na, 'Ema 4', style=plot.style_line, linewidth=2,
color=color.new(color.orange, 0))

//Ema 5
turnon5 = input(false, title='Turn on EMA5?')
len5 = input.int(34, minval=1, title='EMA5')
ema5 = ta.ema(source, len5)
plot(turnon5 ? ema5 : na, 'Ema 5', style=plot.style_line, linewidth=2,
color=color.new(color.yellow, 0))

//Ema 6
turnon6 = input(false, title='Turn on EMA6?')
len6 = input.int(55, minval=1, title='EMA6')
ema6 = ta.ema(source, len6)
plot(turnon6 ? ema6 : na, 'Ema 6', style=plot.style_line, linewidth=2,
color=color.new(color.purple, 0))

//Ema 7
turnon7 = input(false, title='Turn on EMA7?')
len7 = input.int(89, minval=1, title='EMA7')
ema7 = ta.ema(source, len7)
plot(turnon7 ? ema7 : na, 'Ema 7', style=plot.style_line, linewidth=2,
color=color.new(color.fuchsia, 0))

//Ema 8
turnon8 = input(false, title='Turn on EMA8?')
len8 = input.int(144, minval=1, title='EMA8')
ema8 = ta.ema(source, len8)
plot(turnon8 ? ema8 : na, 'Ema 8', style=plot.style_line, linewidth=2,
color=color.new(color.teal, 0))

// Ema 9
turnon9 = input(false, title='Turn on EMA9?')
len9 = input.int(200, minval=1, title='EMA9')
ema9 = ta.ema(source, len9)
plot(turnon9 ? ema9 : na, 'Ema 9', style=plot.style_line, linewidth=2,
color=color.new(color.aqua, 0))

// Ema Cross
mylong = ta.crossover(ema1, ema2)
myshort = ta.crossunder(ema1, ema2)

first = ta.ema(close, len1)


sec = ta.ema(close, len2)

// Calculations
last_long = float(na)
last_short = float(na)
last_long := mylong ? time : nz(last_long[1])
last_short := myshort ? time : nz(last_short[1])

in_long = last_long > last_short ? 2 : 0


in_short = last_short > last_long ? 2 : 0

condlongx = in_long
condlong = ta.crossover(condlongx, 1.9)
condlongclose = ta.crossunder(condlongx, 1.9)

condshortx = in_short
condshort = ta.crossover(condshortx, 1.9)
condshortclose = ta.crossover(condshortx, 1.9)

// Color Fill
fcolor = first > sec ? #0aff68 : first < sec ? #ff0a5a : #cccccc

// Ema Output
F1 = plot(turnon ? first : na, color=fcolor, linewidth=2)
S2 = plot(turnon ? sec : na, color=fcolor, linewidth=2)
fill(F1, S2, title='Channel Fill', color=fcolor, transp=60)

// Plots
plotshape(turnon2 ? condlong : na, title='Breakout', color=color.rgb(19, 236, 56),
location=location.belowbar, style=shape.labelup, text='多',
textcolor=color.new(color.white, 0), size=size.small, offset=1)
plotshape(turnon2 ? condshort : na, title='Breakdown', color=color.new(#9d0d0d, 0),
style=shape.labeldown, text='空', textcolor=color.new(color.white, 0), size=size.small,
offset=1)

// Alerts Ema 1 & 2 Crossover & Crossunder


alertcondition(condlong, 'Breakout')
alertcondition(condshort, 'Breakdown')
//---

// Background Color
bgcolor(backgroundcolor ? fcolor : na, transp=67)
// Start Ema Dashboard inputs
// Signal Crossover
Dema1 = ema1 > ema2 ? "Above" : "Below"
Dema11 = ema1 > ema2 ? color.rgb(47, 78, 48) : color.rgb(255, 0, 0)

// Start Emas
// len1
Dema2 = close > ema1 ? "Above" : "Below"
Dema22 = close > ema1 ? color.rgb(47, 78, 48) : color.rgb(255, 0, 0)
//
// len2
Dema3 = close > ema2 ? "Above" : "Below"
Dema33 = close > ema2 ? color.rgb(47, 78, 48) : color.rgb(255, 0, 0)
//
Dema4 = close > ema3 ? "Above" : "Below"
Dema44 = close > ema3 ? color.rgb(47, 78, 48) : color.rgb(255, 0,0)
//
Dema5 = close > ema4 ? "Above" : "Below"
Dema55 = close > ema4 ? color.rgb(47, 78, 48) : color.rgb(255, 0, 0)
//
Dema6 = close > ema5 ? "Above" : "Below"
Dema66 = close > ema5 ? color.rgb(47, 78, 48) : color.rgb(255, 0,0)
//
Dema7 = close > ema6 ? "Above" : "Below"
Dema77 = close > ema6 ? color.rgb(47, 78, 48) : color.rgb(255, 0,0)
//
Dema8 = close > ema7 ? "Above" : "Below"
Dema88 = close > ema7 ? color.rgb(47, 78, 48) : color.rgb(255, 0,0)
//
Dema9 = close > ema8 ? "Above" : "Below"
Dema99 = close > ema8 ? color.rgb(47, 78, 48) : color.rgb(255, 0,0)
//
Dema10 = close > ema9 ? "Above" : "Below"
Dema101 = close > ema9 ? color.rgb(47, 78, 48) : color.rgb(255, 0,0)

var ssltable = table.new(tablePosition, 2, 21, border_width = 3,bgcolor =


color.new(color.black,0), border_color=color.new(#333333,0))
if barstate.islast
if showTable
table.cell(ssltable, 0, 0, text='EMA', text_color=color.new(color.white, 0),
text_size=tableTextSize)
table.cell(ssltable, 1, 0, text='Above / Below',
text_color=color.new(color.white, 0), text_size=tableTextSize)
if showTable
table.cell(ssltable, 0, 1, text='Ema Cross', text_color=color.new(color.white,
0), text_size=tableTextSize,bgcolor=color.new(color.gray,0))
table.cell(ssltable, 1, 1, text= Dema1, text_color=color.new(color.white, 0),
text_size=tableTextSize,bgcolor=Dema11) // Buy / Sell Signal
if showTable
table.cell(ssltable, 0, 2, text='Ema - '+ str.tostring(math.round(len1, 0)),
text_color=color.new(color.white, 0),
text_size=tableTextSize,bgcolor=color.new(color.gray,0))
table.cell(ssltable, 1, 2, text= Dema2, text_color=color.new(color.white, 0),
text_size=tableTextSize,bgcolor=Dema22) // Buy / Sell Signal
if showTable
table.cell(ssltable, 0, 3, text='Ema - ' + str.tostring(math.round(len2,
0)),text_color=color.new(color.white, 0),
text_size=tableTextSize,bgcolor=color.new(color.gray,0))
table.cell(ssltable, 1, 3, text=Dema3, text_color=color.new(color.white, 0),
text_size=tableTextSize,bgcolor=Dema33) // Bull / Bear Line
if showTable
table.cell(ssltable, 0, 4, text='Ema - ' + str.tostring(math.round(len3, 0)),
text_color=color.new(color.white, 0),
text_size=tableTextSize,bgcolor=color.new(color.gray,0))
table.cell(ssltable, 1, 4, text=Dema4, text_color=color.new(color.white, 0),
text_size=tableTextSize,bgcolor=Dema44) // Stoch Cross
if showTable
table.cell(ssltable, 0, 5, text='Ema - ' + str.tostring(math.round(len4,
0)),text_color=color.new(color.white, 0),
text_size=tableTextSize,bgcolor=color.new(color.gray,0))
table.cell(ssltable, 1, 5, text=Dema5, text_color=color.new(color.white, 0),
text_size=tableTextSize,bgcolor=Dema55) // Stoch in reversal Zone
if showTable
table.cell(ssltable, 0, 6, text='Ema - ' + str.tostring(math.round(len5, 0)),
text_color=color.new(color.white, 0),
text_size=tableTextSize,bgcolor=color.new(color.gray,0))
table.cell(ssltable, 1, 6, text=Dema6, text_color=color.new(color.white, 0),
text_size=tableTextSize,bgcolor=Dema66)
if showTable
table.cell(ssltable, 0, 7, text='Ema - ' + str.tostring(math.round(len6, 0)),
text_color=color.new(color.white, 0),
text_size=tableTextSize,bgcolor=color.new(color.gray,0))
table.cell(ssltable, 1, 7, text=Dema7, text_color=color.new(color.white, 0),
text_size=tableTextSize,bgcolor=Dema77)
if showTable
table.cell(ssltable, 0, 8, text='Ema - ' + str.tostring(math.round(len7, 0)),
text_color=color.new(color.white, 0),
text_size=tableTextSize,bgcolor=color.new(color.gray,0))
table.cell(ssltable, 1, 8, text= Dema8, text_color=color.new(color.white, 0),
text_size=tableTextSize,bgcolor=Dema88)
if showTable
table.cell(ssltable, 0, 9, text='Ema - ' + str.tostring(math.round(len8, 0)),
text_color=color.new(color.white, 0),
text_size=tableTextSize,bgcolor=color.new(color.gray,0))
table.cell(ssltable, 1, 9, text= Dema9, text_color=color.new(color.white, 0),
text_size=tableTextSize,bgcolor=Dema99)
if showTable
table.cell(ssltable, 0, 10, text='Ema - ' + str.tostring(math.round(len9, 0)),
text_color=color.new(color.white, 0),
text_size=tableTextSize,bgcolor=color.new(color.gray,0))
table.cell(ssltable, 1, 10, text= Dema10, text_color=color.new(color.white, 0),
text_size=tableTextSize,bgcolor=Dema101)

You might also like