Skip to content

Instantly share code, notes, and snippets.

//@version=5
indicator(title="Interval Vertical Lines", shorttitle="Int Lines", overlay=true, max_lines_count=500)
// --- User Inputs ---
group_tf = "Timeframe & Interval Settings"
targetTfInput = input.string("D", title="Reference Timeframe", tooltip="Timeframe to base intervals on (e.g., '1', '5', '15', '60', '240', 'D', 'W', 'M'). Use TradingView format.", group = group_tf, inline="tf")
intervalValInput = input.int(1, title="Interval Value", minval=1, group = group_tf, inline="interval")
intervalUnitInput = input.string("Hours", title="Interval Unit", options=["Minutes", "Hours", "Days", "Weeks", "Months"], group = group_tf, inline="interval")
group_style = "Line Appearance"
//@version=5
indicator(title="Dynamic TP/SL Lines with Risk and ATR", shorttitle="Dyn TP/SL Risk ATR", overlay=true, precision=2, max_lines_count = 52, max_labels_count = 50) // Increased max_lines_count
// === INPUTS ===
group_levels = "Level Configuration"
numLevels = input.int(3, title="Number of Levels (Each Side)", minval=1, maxval=25, group=group_levels, tooltip="How many TP/SL levels to draw above and below the price.") // Max 25 to stay within limits
pointIncrement = input.float(5.0, title="Point Increment Per Level", minval=0.25, step=0.25, group=group_levels, tooltip="The distance in points between consecutive TP/SL levels.")
startingNumber = input.int(0, title = "Starting number", minval=0, group=group_levels, tooltip="What distance should the increments start from")
atrLength = input.int(14, title="ATR Length (1min Chart)", minval=1, group=group_levels, tooltip="Length of the ATR calculation on the 1-minute chart.")
atrMultiplier = input.int(2, title="ATR Multiple", minval=1, group=group_levels,
//@version=5
indicator("ATR Risk Calc (1min TF, Custom SL, Rounded) - Explicit Format", shorttitle="ATR Risk (1m, Custom) EF", overlay=true)
// --- User Inputs ---
i_atrLength = input.int(14, title="ATR Length (on 1min TF)", minval=1)
i_riskAmount = input.float(100.0, title="Max Desired Risk ($)", minval=0.0, step=1.0) // Renamed for clarity vs Actual Risk
// --- Instrument Specific Inputs ---
i_pointValue = input.float(2.00, title="Point Value ($) - e.g., MNQ=2.00, MES=5.00", minval=0.01, step=0.01)
i_atrMultiplier = input.float(2.0, title="ATR Multiplier for Stop Loss", minval=0.1, step=0.1) // Defaulted to 2x
// --- Display ---
// Store a reference to the native appendChild function
const nativeAppend = Node.prototype.appendChild;
// Override the appendChild method
Node.prototype.appendChild = function(node) {
// If the node is a "robber" don't append it
if (node.id === 'robber') {
console.log('denying robber entry to the bank');
return;
}
// Select the node that will be observed for mutations
const bank = document.getElementById('bank');
// Options for the observer (which mutations to observe)
const config = { childList: true };
// Callback function to execute when mutations are observed
const callback = function(mutationsList, observer) {
// Loop through all mutations
mutationsList.forEach(mutation => {
const items = ['apple', 'orange', 'banana'];
// Here we are storing a reference to the native Array push method
const nativePush = Array.prototype.push;
Array.prototype.push = function(item) {
console.log(`Array push intercepted. Pushing ${item} into [${this}]`);
// Push the item into the array
nativePush.call(this, item);
}
const items = ['apple', 'orange', 'banana'];
Array.prototype.push = function(item) {
console.log(`Array push intercepted. Pushing ${item} into [${this}]`);
}
items.push('grape'); // Will log the above statement to the console
class Director {
constructor(builder) {
this.builder = builder;
}
constructFamilyHouse() {
return this.builder
.buildWalls(4)
.buildRoof('sloped')
.buildGarden(['trees', 'grass', 'peacocks'])
class House {
constructor() {
this.walls = null;
this.roof = null;
this.pool = null;
this.garden = null;
this.internet = null;
}
setWalls(walls) {
class DressClothesFactory {
constructor() {
}
getShoes() {
return new DressShoes();
}
getShirt() {