Move snippets and strategies folders to misc directory

This commit is contained in:
2025-02-28 15:20:34 -08:00
parent 7174c8dca2
commit 25f43bc40c
10 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,74 @@
//@version=6
indicator("Label Example", overlay=true)
// Calculate a condition for when to create a label
condition = close > math.avg(close, 20)
// Create a new label if the condition is true, update the label's text with the current close price
//label_id = label.new(title="Price Label", x=bar_index, y=close, text=str.tostring(close), color=color.green, style=label.style.plain)
// Create an array to store boxes and labels
var box[] boxArray = array.new_box()
var label[] labelArray = array.new_label()
labelDemo() =>
// Remove a specific label by index
if (array.size(labelArray) > 0)
label.delete(array.get(labelArray, 0))
array.remove(labelArray, 0)
label newLabel = label.new(x=bar_index, y=close, text='H:' + str.tostring(high, '#.##') + '\nL:' + str.tostring(low, '#.##'), xloc=xloc.bar_index, yloc=yloc.price, color=color.blue, style=label.style_label_down, textcolor=color.white, size=size.normal, textalign=text.align_center, tooltip='SIZE: ' + str.tostring(high-low, '#.##'))
// Add new labels to array
array.push(labelArray, newLabel)
labelDemo()
// Input parameters
var float buyLimitPrice = input.price(title="Buy Limit Price", defval=0.0)
var float sellLimitPrice = input.price(title="Sell Limit Price", defval=0.0)
var int rectangleWidth = input.int(title="Rectangle Width (Price Units)", defval=10, minval=1)
var bool showDebugInfo = input.bool(title="Show Debug Information", defval=false)
var color buyShadeColor = input.color(title="Buy Limit Shade Color", defval=#4caf4f46)
var color sellShadeColor = input.color(title="Sell Limit Shade Color", defval=#ff52523a)
var color borderColor = input.color(title="Border Color", defval=color.gray)
buyLimitPrice := high + 10
sellLimitPrice := low - 10
cleanupBoxes() =>
// Remove oldest boxes if exceed max limit
while (array.size(boxArray) > 0)
box.delete(array.get(boxArray, 0))
array.remove(boxArray, 0)
// Function to draw order levels
f_drawOrderLevels() =>
cleanupBoxes()
var boxes = array.new_box()
// Buy limit rectangle
if (buyLimitPrice > 0)
float buyRectTop = high + rectangleWidth //buyLimitPrice + rectangleWidth / 2
float buyRectBottom = (high + low) / 2 //buyLimitPrice - rectangleWidth / 2
box newBox1 = box.new(left=bar_index, top=buyRectTop, right=bar_index + 10, bottom=buyRectBottom, border_color=borderColor, border_width=1, bgcolor=buyShadeColor, text=str.tostring(buyRectTop, '#.##'), text_color=color.white, text_halign=text.align_center, text_valign=text.align_top, text_size = size.small)
array.push(boxArray, newBox1)
if (showDebugInfo)
//label.new(x=bar_index, y=close, text='H:' + str.tostring(high, '#.##') + '\nL:' + str.tostring(low, '#.##'), xloc=xloc.bar_index, yloc=yloc.price, color=color.blue, style=label.style_label_down, textcolor=color.white, size=size.normal, textalign=text.align_center, tooltip='SIZE: ' + str.tostring(high-low, '#.##'))
label.new(x=bar_index, y=buyLimitPrice, text='Buy Limit\nPrice: ' + str.tostring(buyLimitPrice, format.mintick) + '\nTop: ' + str.tostring(buyRectTop, format.mintick) + '\nBottom: ' + str.tostring(buyRectBottom, format.mintick), color=color.blue)
// Sell limit rectangle
if (sellLimitPrice > 0)
float sellRectTop = (high + low) / 2 //sellLimitPrice + rectangleWidth / 2
float sellRectBottom = low - rectangleWidth //sellLimitPrice - rectangleWidth / 2
box newBox2 = box.new(left=bar_index, top=sellRectTop, right=bar_index + 10, bottom=sellRectBottom, border_color=borderColor, border_width=1, bgcolor=sellShadeColor, text=str.tostring(sellRectBottom, '#.##'), text_color=color.white, text_halign=text.align_center, text_valign=text.align_bottom, text_size = size.small)
array.push(boxArray, newBox2)
if (showDebugInfo)
label.new(x=bar_index, y=sellLimitPrice, text='Sell Limit\nPrice: ' + str.tostring(sellLimitPrice, format.mintick) + '\nTop: ' + str.tostring(sellRectTop, format.mintick) + '\nBottom: ' + str.tostring(sellRectBottom, format.mintick), color=color.red)
// Execute the function to draw order levels
f_drawOrderLevels()