NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

//@version=5
indicator(shorttitle="MS One", title="MS One", overlay=true)

firstConditionMet = false
secondConditionMet = false
thirdConditionMet = false

// BB calculations
length = 20 //input.int(20, minval=1)
src = close //input(close, title="Source")
mult = 2.0 //input.float(2.0, minval=0.001, maxval=50, title="StdDev")
basis = ta.sma(src, length)
dev = mult * ta.stdev(src, length)
upper = basis + dev
lower = basis - dev
offset = 0 //input.int(0, "Offset", minval = -500, maxval = 500)

//Fractals calculations
fractalPeriod = 2 //input.int(title="Periods", defval=2, minval=2)


// UpFractal
bool upflagDownFrontier = true
bool upflagUpFrontier0 = true
bool upflagUpFrontier1 = true
bool upflagUpFrontier2 = true
bool upflagUpFrontier3 = true
bool upflagUpFrontier4 = true

for i = 1 to fractalPeriod
upflagDownFrontier := upflagDownFrontier and (high[fractalPeriod-i] < high[fractalPeriod])
upflagUpFrontier0 := upflagUpFrontier0 and (high[fractalPeriod+i] < high[fractalPeriod])
upflagUpFrontier1 := upflagUpFrontier1 and (high[fractalPeriod+1] <= high[fractalPeriod] and high[fractalPeriod+i + 1] < high[fractalPeriod])
upflagUpFrontier2 := upflagUpFrontier2 and (high[fractalPeriod+1] <= high[fractalPeriod] and high[fractalPeriod+2] <= high[fractalPeriod] and high[fractalPeriod+i + 2] < high[fractalPeriod])
upflagUpFrontier3 := upflagUpFrontier3 and (high[fractalPeriod+1] <= high[fractalPeriod] and high[fractalPeriod+2] <= high[fractalPeriod] and high[fractalPeriod+3] <= high[fractalPeriod] and high[fractalPeriod+i + 3] < high[fractalPeriod])
upflagUpFrontier4 := upflagUpFrontier4 and (high[fractalPeriod+1] <= high[fractalPeriod] and high[fractalPeriod+2] <= high[fractalPeriod] and high[fractalPeriod+3] <= high[fractalPeriod] and high[fractalPeriod+4] <= high[fractalPeriod] and high[fractalPeriod+i + 4] < high[fractalPeriod])
flagUpFrontier = upflagUpFrontier0 or upflagUpFrontier1 or upflagUpFrontier2 or upflagUpFrontier3 or upflagUpFrontier4

upFractal = (upflagDownFrontier and flagUpFrontier)


// downFractal
bool downflagDownFrontier = true
bool downflagUpFrontier0 = true
bool downflagUpFrontier1 = true
bool downflagUpFrontier2 = true
bool downflagUpFrontier3 = true
bool downflagUpFrontier4 = true

for i = 1 to fractalPeriod
downflagDownFrontier := downflagDownFrontier and (low[fractalPeriod-i] > low[fractalPeriod])
downflagUpFrontier0 := downflagUpFrontier0 and (low[fractalPeriod+i] > low[fractalPeriod])
downflagUpFrontier1 := downflagUpFrontier1 and (low[fractalPeriod+1] >= low[fractalPeriod] and low[fractalPeriod+i + 1] > low[fractalPeriod])
downflagUpFrontier2 := downflagUpFrontier2 and (low[fractalPeriod+1] >= low[fractalPeriod] and low[fractalPeriod+2] >= low[fractalPeriod] and low[fractalPeriod+i + 2] > low[fractalPeriod])
downflagUpFrontier3 := downflagUpFrontier3 and (low[fractalPeriod+1] >= low[fractalPeriod] and low[fractalPeriod+2] >= low[fractalPeriod] and low[fractalPeriod+3] >= low[fractalPeriod] and low[fractalPeriod+i + 3] > low[fractalPeriod])
downflagUpFrontier4 := downflagUpFrontier4 and (low[fractalPeriod+1] >= low[fractalPeriod] and low[fractalPeriod+2] >= low[fractalPeriod] and low[fractalPeriod+3] >= low[fractalPeriod] and low[fractalPeriod+4] >= low[fractalPeriod] and low[fractalPeriod+i + 4] > low[fractalPeriod])
flagDownFrontier = downflagUpFrontier0 or downflagUpFrontier1 or downflagUpFrontier2 or downflagUpFrontier3 or downflagUpFrontier4

downFractal = (downflagDownFrontier and flagDownFrontier)

// first condition calculation
if lower >= low
firstConditionMet := true


// EMA calculations
EMA_LENGTH = 5
srcEma = close //input(close, title="Source")
offsetEma = 0 //input.int(title="Offset", defval=0, minval=-500, maxval=500)
outEma = ta.ema(srcEma, EMA_LENGTH)


// second condtion is met when close is greater or equal to EMA
// and the first condition was met in any of the last 5 bars
secondConditionMet := outEma <= close and (firstConditionMet[0] == true or firstConditionMet[1] == true or firstConditionMet[2] == true or firstConditionMet[3] == true or firstConditionMet[4] == true)

// check the third condition
// third condition is met when the previous bar had the second condition met and the high has crossed the previous bar's high
thirdConditionMet := secondConditionMet[1] and high >= high[1]


// plotting starts here
// plot BB, but only if the user has selected to do so
plotBB = input.bool(title="Plot BB?", defval=false)
plot(basis, "Basis", color= (plotBB ? #FF6D00 : na), offset = offset)
p1 = plot(upper, "Upper", color= (plotBB ? #2962FF : na), offset = offset)
p2 = plot(lower, "Lower", color= (plotBB ? #2962FF : na), offset = offset)
fill(p1, p2, title = "Background", color=(plotBB ? color.rgb(33, 150, 243, 95) : na))

// plot EMA, but only if the user has selected to do so
EMA_COLOR=color.black
plotEMA = input.bool(title="Plot EMA?", defval=false)
plot(outEma, title="EMA", color= (plotEMA ? EMA_COLOR : na), offset=offsetEma)

// plot fractals, only if the user has selected to do so
plotFractals = input.bool(title="Plot Fractals?", defval=false)
plotshape(downFractal, style=shape.triangledown, location=location.belowbar, offset=-fractalPeriod, color=(plotFractals ? #F44336 : na), size = size.small)
plotshape(upFractal, style=shape.triangleup, location=location.abovebar, offset=-fractalPeriod, color=(plotFractals ? #009688 : na), size = size.small)

// plot a character 'F' when first condition is met
plotFirstCondition = input.string(title="Show First Condition", defval="No", options=["No", "Above Bar", "Below Bar", "Absolute Bottom"])
firstConditionLocation = (plotFirstCondition == "Below Bar" ? location.belowbar : (plotFirstCondition == "Absolute Bottom" ? location.bottom : location.abovebar))
plotchar(firstConditionMet and plotFirstCondition != "No", char='F', location=firstConditionLocation)

// plot a character 'S' when second condition is met
plotSecondCondition = input.string(title="Show Second Condition", defval="No", options=["No", "Above Bar", "Below Bar", "Absolute Bottom"])
secondConditionLocation = (plotSecondCondition == "Below Bar" ? location.belowbar : (plotSecondCondition == "Absolute Bottom" ? location.bottom : location.abovebar))
plotchar(secondConditionMet and plotSecondCondition != "No", char='S', location=secondConditionLocation)

// plot a character 'T' when the third condition is met
plotThirdCondition = input.string(title="Show Third Condition", defval="Absolute Bottom", options=["No", "Above Bar", "Below Bar", "Absolute Bottom"])
thirdConditionLocation = (plotThirdCondition == "Below Bar" ? location.belowbar : (plotThirdCondition == "Absolute Bottom" ? location.bottom : location.abovebar))
plotchar(thirdConditionMet and plotThirdCondition != "No", char='T', location=thirdConditionLocation)
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.