Million Moves Algo V4.3
Million Moves Algo V4.3
Million Moves Algo V4.3
bullColor = #e43a72
bearColor = #00ffcc
// Signals
supertrend(_close, factor, atrLen) =>
atr = ta.atr(atrLen)
upperBand = _close + factor * atr
lowerBand = _close - factor * atr
prevLowerBand = nz(lowerBand[1])
prevUpperBand = nz(upperBand[1])
lowerBand := lowerBand > prevLowerBand or close[1] < prevLowerBand ?
lowerBand : prevLowerBand
upperBand := upperBand < prevUpperBand or close[1] > prevUpperBand ?
upperBand : prevUpperBand
int direction = na
float superTrend = na
prevSuperTrend = superTrend[1]
if na(atr[1])
direction := 2
else if prevSuperTrend == prevUpperBand
direction := close > upperBand ? -1 : 1
else
direction := close < lowerBand ? 1 : -1
superTrend := direction == -1 ? lowerBand : upperBand
[superTrend, direction]
sma1 = ta.sma(close, 8)
sma2 = ta.sma(close, 9)
sma3 = ta.sma(close, 13)
[supertrend, direction] = supertrend(open, sigsensiviti, factor)
bull = ta.crossover(close, supertrend) and close >= sma3 and not(close[1] > ema and
close > ema)
bear = ta.crossunder(close, supertrend) and close <= sma3 and not(not(close[1] >
ema and close > ema))
Sbull = ta.crossover(close, supertrend) and close >= sma3 and (close[1] > ema and
close > ema)
Sbear = ta.crossunder(close, supertrend) and close <= sma3 and not(close[1] > ema
and close > ema)
countbull = ta.barssince(Cbull)
countbear = ta.barssince(Cbear)
Trigger = nz(countbull, bar_index) < nz(countbear, bar_index) ? 1 : 0
// Trends
HighestTrend = ta.ema(close, 20)
LowestTrend = ta.ema(close, 55)
Trend01 = ta.ema(close,50)
Trend02 = ta.ema(close,45)
Trend03 = ta.ema(close,40)
Trend04 = ta.ema(close,35)
Trend05 = ta.ema(close,30)
Trend06 = ta.ema(close,25)
// Dashboard
indicatorTF = "Chart"
// -- MTF Function
f_chartTfInMinutes() =>
float _resInMinutes = timeframe.multiplier * (
timeframe.isseconds ? 1. / 60 :
timeframe.isminutes ? 1. :
timeframe.isdaily ? 60. * 24 :
timeframe.isweekly ? 60. * 24 * 7 :
timeframe.ismonthly ? 60. * 24 * 30.4375 : na)
// Wywołanie funkcji
adxTrend = detectADXTrend()
// MTF
TF1Bull = securityNoRep(syminfo.tickerid, "1" , adxTrend)
TF3Bull = securityNoRep(syminfo.tickerid, "3" , adxTrend)
TF5Bull = securityNoRep(syminfo.tickerid, "5" , adxTrend)
TF10Bull = securityNoRep(syminfo.tickerid, "10" , adxTrend)
TF15Bull = securityNoRep(syminfo.tickerid, "15" , adxTrend)
TF30Bull = securityNoRep(syminfo.tickerid, "30" , adxTrend)
TF60Bull = securityNoRep(syminfo.tickerid, "60" , adxTrend)
TF120Bull = securityNoRep(syminfo.tickerid, "120" , adxTrend)
TF240Bull = securityNoRep(syminfo.tickerid, "240" , adxTrend)
TF720Bull = securityNoRep(syminfo.tickerid, "720" , adxTrend)
TFDBull = securityNoRep(syminfo.tickerid, "1440", adxTrend)
// -- Volatility
atrr = 3 * ta.atr(10)
stdAtr = 2 * ta.stdev(atrr, 20)
smaAtr = ta.sma(atrr, 20)
topAtrDev = smaAtr + stdAtr
bottomAtrDev = smaAtr - stdAtr
calcDev = (atrr - bottomAtrDev) / (topAtrDev - bottomAtrDev)
percentVol = 40 * calcDev + 30
bullishThreshold = 50
tb = table.new(table_position, 18, 8
, bgcolor = #11172565
, border_color = #373a4600
, border_width = 1
, frame_color = #000000
, frame_width = 1)
if showDashboard
if barstate.islast
table.cell(tb, 0, 0, ' Million Moves
Dashboard ', text_color = color.white,text_halign =
text.align_left, text_size = table_size,bgcolor = #18233a)
table.merge_cells(tb, 0, 0, 3, 0)
tb.cell(0, 2, "⚠️ Volatility", text_color = color.white, text_size =
table_size, text_halign = text.align_center)
tb.cell(1, 2, VolStatus, text_color = color.white, text_size = table_size,
text_halign = text.align_center)
tb.cell(2, 2, " RSI", text_color = color.white, text_size = table_size,
text_halign = text.align_center)
tb.cell(3, 2, str.tostring(rsiValue,"#.##"), text_color = rsiColor,
text_size = table_size, text_halign = text.align_center)
// bgcolor
// Define the RSI
rsi_Source = close
rsi_Period = 14
rsi_ = ta.rsi(rsi_Source, rsi_Period)
//Ema Cloud
ema150 = ta.ema(close, 150)
ema250 = ta.ema(close, 250)
fill(plot(trend_cloud? ema150: na, "", na, editable=false), plot(trend_cloud?
ema250: na, "", na, editable=false), ema150 > ema250 ? color.new(color.green, 70) :
ema150 < ema250 ? color.new(color.red, 70) : na)
// Bar color
src = close
len = 14//input.int(14, minval=1, title='RSI Length')
up = ta.rma(math.max(ta.change(src), 0), len)
down = ta.rma(-math.min(ta.change(src), 0), len)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - 100 / (1 + up / down)
if (tierMid)
colorVar := rsi <= 50 ? #9900ca : #b200ff // Gradient between the mid values
if (tierHigh)
colorVar := rsi <= 65 ? #30b56a : #30b56a // Gradient between high values
green = #00DD00
red = #DD0000
barcolor(candlestick_color?candletype=="CleanScalper"?colorVar:candletype=="Trend
Ribbon"?uptrend?green:red:close[1] > ema and close > ema ? green : red:na)
color upTier = na
color downTier = na
downTier := tierLow1 ? #e43a72 : tierLow2 ? #e6002352 : color(na)
upTier := tierHigh2 ? #00ffcc : tierHigh3 ? #00ffcc65 :color(na)
// Cloud
k_length = 0.425
uphighColor = #ca009e4d
uplowColor = #ca009e27
downhighColor = #b300ff2f
downlowColor = #9700ca10
//Tralling Step
atr2 = ta.atr(100) / 2
dev = channelDeviation * atr2
highPrice1 = high[math.abs(ta.highestbars(amplitude))]
lowPrice1 = low[math.abs(ta.lowestbars(amplitude))]
highma = ta.sma(high, amplitude)
lowma = ta.sma(low, amplitude)
if nextTrend == 1
maxLowPrice := math.max(lowPrice1, maxLowPrice)
if trend == 0
if not na(trend[1]) and trend[1] != 0
up1 := na(down1[1]) ? down1 : down1[1]
arrowUp := up_a - atr2
arrowUp
else
up1 := na(up1[1]) ? maxLowPrice : math.max(maxLowPrice, up1[1])
up1
atrHigh := up1 + dev
atrLow := up1 - dev
atrLow
else
if not na(trend[1]) and trend[1] != 1
down1 := na(up1[1]) ? up1 : up1[1]
arrowDown := down1 + atr2
arrowDown
else
down1 := na(down1[1]) ? minHighPrice : math.min(minHighPrice, down1[1])
down1
atrHigh := down1 + dev
atrLow := down1 - dev
atrLow
// Risk Manager
tpLabels(tp,bull,bear) =>
rsi1 = ta.rsi(close, 14)
countBull = ta.barssince(bull)
countBear = ta.barssince(bear)
trigger = nz(countBull, bar_index) < nz(countBear, bar_index) ? 1 : 0
tp1Bull = ta.crossover (rsi1, 70), tp2Bull = ta.crossover (rsi1, 85), tp3Bull =
ta.crossover (rsi1, 100)
tp1Bear = ta.crossunder(rsi1, 30), tp2Bear = ta.crossunder(rsi1, 15), tp3Bear =
ta.crossunder(rsi1, 5)
tp1Bull := tp1Bull and (nz(ta.barssince(tp1Bull)[1], 9999) > countBull),
tp2Bull := tp2Bull and (ta.barssince(tp1Bull)[1] <= countBull), tp2Bull := tp2Bull
and (nz(ta.barssince(tp2Bull)[1], 9999) > countBull), tp3Bull := tp3Bull and
(ta.barssince(tp2Bull)[1] <= countBull), tp3Bull := tp3Bull and
(nz(ta.barssince(tp3Bull)[1], 9999) > countBull)
tp1Bear := tp1Bear and (nz(ta.barssince(tp1Bear)[1], 9999) > countBear),
tp2Bear := tp2Bear and (ta.barssince(tp1Bear)[1] <= countBear), tp2Bear := tp2Bear
and (nz(ta.barssince(tp2Bear)[1], 9999) > countBear), tp3Bear := tp3Bear and
(ta.barssince(tp2Bear)[1] <= countBear), tp3Bear := tp3Bear and
(nz(ta.barssince(tp3Bear)[1], 9999) > countBear)
trigger ? (tp == 1 ? tp1Bull : tp == 2 ? tp2Bull : tp3Bull) : (tp == 1 ?
tp1Bear : tp == 2 ? tp2Bear : tp3Bear)
_bull = Cbull
_bear = Cbear
risksteps = tpstrength
enableTpSlAreas = riskmanage
// Plots
none = close > 0
countBull = ta.barssince(_bull)
countBear = ta.barssince(_bear)
trigger = nz(countBull, bar_index) < nz(countBear, bar_index) ? 1 : 0
atrBand = usePercSL ? (trigger ? low : high) * (percTrailingSL / 100) : ta.atr(14)
* 2.2
atrStop = trigger ? low - atrBand : high + atrBand
lastTrade(src) => ta.valuewhen(_bull or _bear, src, 0)
entry_y = lastTrade(close)
stop_y = lastTrade(atrStop)
tp1_y = (entry_y-lastTrade(atrStop))*multTP1 + entry_y
tp2_y = (entry_y-lastTrade(atrStop))*multTP2 + entry_y
tp3_y = (entry_y-lastTrade(atrStop))*multTP3 + entry_y
labelTpSl(cond, y, txt, color) =>
label labelTpSl = enableTpSlAreas and cond ? label.new(bar_index + 1, y, txt,
xloc.bar_index, yloc.price, color, label.style_label_left, color.white,
size.normal) : na
label.delete(labelTpSl[1])
labelTpSl(none, entry_y, "Entry : " + str.tostring(math.round_to_mintick(entry_y)),
color.orange)
labelTpSl(none, stop_y , "Stop loss : " +
str.tostring(math.round_to_mintick(atrStop)), color.red)
labelTpSl(useTP1 and multTP1 != 0, tp1_y, "TP 1 : " +
str.tostring(math.round_to_mintick(tp1_y)), color.green)
labelTpSl(useTP2 and multTP2 != 0, tp2_y, "TP 2 : " +
str.tostring(math.round_to_mintick(tp2_y)), color.green)
labelTpSl(useTP3 and multTP3 != 0, tp3_y, "TP 3 : " +
str.tostring(math.round_to_mintick(tp3_y)), color.green)
lineTpSl(cond, y, color, style) =>
line lineTpSl = enableTpSlAreas and cond ? line.new(bar_index - (trigger ?
countBull : countBear), y, bar_index + 1, y, xloc.bar_index, extend.none, color,
style) : na
line.delete(lineTpSl[1])
lineTpSl(none, entry_y, color.orange, line.style_dashed)
lineTpSl(none, stop_y , color.red , line.style_solid )
lineTpSl(useTP1 and multTP1 != 0, tp1_y, color.green, line.style_dotted)
lineTpSl(useTP2 and multTP2 != 0, tp2_y, color.green, line.style_dotted)
lineTpSl(useTP3 and multTP3 != 0, tp3_y, color.green, line.style_dotted)
// Reversal Signals
enableReversal = true
ReversalInputs = 25//input.int(14, minval=1, title="Reversals Sensitivity",
group="Reversal Settings")
overbought = 75//input(75, 'Reversal Down Level', group='Reversal Settings')
oversold = 25//input(25, 'Reversal Up Level', group='Reversal Settings')
//Channel Breakouts
bars = 3//input(3)
checkbox = true//input.bool(title= "color chenging by trend", defval=true)
//INIT VARIABLES
var int ph_uptrend_flag = 0
var float ph_valid1 = 0
var float ph_valid2 = 0
var float ph_valid3 = 0
var float ph_valid4 = 0
var float ph_valid5 = 0
var float pl_valid1 = 0
var float pl_valid2 = 0
var float pl_valid3 = 0
var float pl_valid4 = 0
var float pl_valid5 = 0
var float ph_valid_old = 2
var float pl_valid_old = 0 // non meaningful number here for initialization only
ph_non_na = nz(ph, 0)
pl_non_na = nz(pl, 0) // stores 0's instead of na's for non-pivot-pointed bars
if ph_non_na != 0
ph_valid5 := ph_valid4
ph_valid4 := ph_valid3
ph_valid3 := ph_valid2
ph_valid2 := ph_valid1
ph_valid1 := ph_non_na
ph_valid_old := ph_valid1
ph_valid_old
else
ph_valid1 := ph_valid1
ph_valid_old := ph_valid_old
ph_valid_old
if pl_non_na != 0
pl_valid5 := pl_valid4
pl_valid4 := pl_valid3
pl_valid3 := pl_valid2
pl_valid2 := pl_valid1
pl_valid1 := pl_non_na
pl_valid_old := pl_valid1
pl_valid_old
else
pl_valid1 := pl_valid1
pl_valid_old := pl_valid_old
pl_valid_old
// OrderBlock
box_ob = order_blocks//input.bool(false, "Toggle Order Block",
group="ORDER BLOCK")
box_hide_gray = true//input.bool(false, "Hide gray boxes", group="ORDER BLOCK")
bos_type = "High and Low"//input.string("High and Low", "MSB trigger",
["High and Low", "Close and Open"], group="ORDER BLOCK")
box_sv = true//input.bool(true, "Plot demand boxes", group="ORDER
BLOCK")
box_test_delay = 3//input.int(3, "Delay to count test of demand box", 1,
group="ORDER BLOCK")
box_fill_delay = 3//input.int(3, "Delay to count fill of demand box", 1,
group="ORDER BLOCK")
box_test_sv = true//input.bool(true, "Dim tested demand boxes", group="ORDER
BLOCK")
box_stop_sv = true//input.bool(true, "Stop plotting filled demand boxes",
group="ORDER BLOCK")