Standards
Standards
0 at
https://mozilla.org/MPL/2.0/
// © ko
//@version=5
indicator("M7 Standards V2", shorttitle = "M7 Standards v2",
max_labels_count=500,max_boxes_count =500, overlay=true)
_extendTDRC = 1 *24
float val=na
if close > open
bodyLow := open
bodyHigh := close
else
bodyLow := close
bodyHigh := open
if close[1] > open[1]
prevBodyLow := open[1]
prevBodyHigh := close[1]
else
prevBodyLow := close[1]
prevBodyHigh := open[1]
// Functions {
f_insession(_session) =>
not na(time(timeframe.period, _session, TIMEZONE))
array.push(l1,newbox1 )
array.push(c1, 0)
array.push(cTTT1, -2)
if ( bodyLow == high[1] and low == prevBodyHigh and bodyLow > prevBodyHigh)
newbox1 = box.new(bar_index-1, bodyLow, bar_index + _extendTDRC, low,text
= "", text_size =labelSize, text_color =sessText, text_halign = text.align_right,
xloc=xloc.bar_index, bgcolor=currentColor, border_color = currentBorderColor )
box.set_extend(newbox1, extend.right)
array.push(l1,newbox1 )
array.push(c1, 0)
array.push(cTTT1, -2)
var box myBox = na
var label myLabel = na
var int myCount = na
var int myCountTTT = na
arraySize = array.size(l1)
if arraySize > 0
for i = 0 to arraySize-1
if i <= arraySize-1 and arraySize > 0
myCount := array.get(c1, i)
myBox := array.get(l1, i)
myCountTTT := array.get(cTTT1, i)
boxstart = box.get_left(myBox)
if (stopBodies and maxBodies >0 and myCount <maxBodies ) or
(stopBodies == false)
b1 = box.get_top(myBox)
b2 = box.get_bottom(myBox)
if b1>b2
boxTop := b1
boxBottom := b2
else
boxTop := b2
boxBottom := b1
if(bodyLow < boxBottom and bodyHigh > boxTop)
myCount :=myCount +1
if(open == boxTop or close == boxTop or open == boxBottom or
close==boxBottom)
myCountTTT := myCountTTT +1
//mylabelxx = label.new(time,low,"BT:"+str.tostring(boxTop)+"
BB:"+str.tostring(boxBottom)+"o"+str.tostring(open)+"
c:"+str.tostring(close),xloc.bar_time,yloc.abovebar,color = color.blue, style =
label.style_circle)
array.set(c1, i, myCount )
array.set(cTTT1, i, myCountTTT )
if (myCount == maxBodies and stopBodies)
box.set_right(myBox, bar_index)
box.set_extend(myBox, extend.none)
array.clear(bl1)
if array.size(l1) > 0
for i = 0 to array.size(l1)-1
if i <= array.size(l1)-1 and array.size(l1) > 0
myBox := array.get(l1, i)
myCount := array.get(c1, i)
myCountTTT := array.get(cTTT1, i)
boxstart = box.get_left(myBox)
dateago := ""
if useFilter and myCount >= filterMinimumBodyClose and ( myCountTTT
/ myCount) < (filterRejectionRatio/filterBodyCloseRatio) /// remove if ratio is
worse
x=11
myBox.set_bgcolor(color =color.rgb(0,0,0,100))
myBox.set_border_color(color =color.rgb(0,0,0,100))
myBox.set_text_color(color.rgb(0,0,0,90))
box.set_text(myBox, str.tostring(myCountTTT) +" TTT ("
+str.tostring(myCount)+")")
//arraySize2 := arraySize2-1
else
boxBottom :=
box.get_bottom(myBox) /////////////////////////////////////////
//////////////////
boxTop :=
box.get_top(myBox) ////////////////////////////////////////////
///////////////
bb = boxTop > boxBottom ? boxBottom :boxTop
bbIndex := array.indexof(bl1, bb)
bbLastIndex:=na
if bbIndex >0 ///// exists
array.sort(bl1,order.ascending)
bbIndex := array.indexof(bl1, bb)
bbLastIndex := array.lastindexof(bl1, bb)
diff = bbLastIndex - bbIndex
buffer := duplicatesCandles * (diff+1)
else
buffer :=0
array.push(bl1, bb)
///////////////////
////////////////////////////////////////
timex := bar_index+statOffset +buffer //+
math.round(math.random(10,90,1))
//if array.includes(boxLevels, boxHigh)
//array.includes(levels, value)
if showBodyCloseStat
if buffer > 0
box.set_text(myBox, str.tostring(myCountTTT) +" T ("
+str.tostring(myCount)+")" + dateago)
else
box.set_text(myBox, str.tostring(myCountTTT) +" T ("
+str.tostring(myCount)+")" +dateago)
else
box.set_text(myBox, str.tostring(myCountTTT) +" T "
+dateago)