ORB With Buffer, Target & Stop Loss

Tamil_FNO_Trader · study · 54 行 · 点赞 1,063 · TradingView 原页

本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。

Pine Script

// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Tamil_FNO_Trader
 
// @version=5
indicator(title="ORB With Buffer, Target & Stop Loss", shorttitle="ORB With Buffer ", overlay=true)
 
// User Input To Enable / Disable, Either / Both Side Levels
bullishbreakout = input(true, title="Bullish Target & SL")
bearishbreakout = input(true, title="Bearish Target & SL")
 
// Identify High & Low for Selected Scripts
prevClose = request.security(syminfo.tickerid, "D", close[1])
 
is_newbar(res) => ta.change(time(res)) != 0
 
adopt(r, s) =>  request.security(syminfo.tickerid, r, s)
 
open_range_high = ta.valuewhen(is_newbar('D'),high,0)  
open_range_low = ta.valuewhen(is_newbar('D'),low,0)
 
// Buffer_Calculations For Buffer, TP & SL Levels
Buffer_Calc = prevClose * 0.001
TP_SL_Calc = prevClose * 0.011
 
// Plot ORB, Buffer, TP & SL Levels
var orbhigh = plot(adopt('15', open_range_high), color = color.blue, linewidth=1, title = "ORB High")
var bufferhigh = plot(adopt('15', (open_range_high+Buffer_Calc)), color = color.blue, linewidth=1, title = "Buffer High")
 
var orblow = plot(adopt('15', open_range_low), color = color.blue, linewidth=1, title = "ORB Low" )
var bufferlow = plot(adopt('15', (open_range_low-Buffer_Calc)), color = color.blue, linewidth=1, title = "Buffer Low")
 
buytarget = plot(bullishbreakout ? adopt('15', (open_range_high+TP_SL_Calc)): na, color = color.green, linewidth=1, title = "Buy Target" )
buystoploss = plot(bullishbreakout ? adopt('15', open_range_high - TP_SL_Calc + (Buffer_Calc * 2)):na, color = color.red, linewidth = 1, title = "Buy Stop Loss")
 
selltarget = plot(bearishbreakout ? adopt('15', (open_range_low-TP_SL_Calc)): na, color = color.green, linewidth=1, title = "Sell Target")
sellstoploss = plot(bearishbreakout ? adopt('15', open_range_low + TP_SL_Calc - (Buffer_Calc *2)):na, color = color.red, linewidth = 1, title = "Sell Stop Loss")
 
// Fill Buffer Zons
fill(orbhigh, bufferhigh, color=color.new(color.blue, 70), title = "Bullish Buffer BG")
fill(orblow, bufferlow, color=color.new(color.blue, 70), title = "Bearish Buffer BG")
 
// Draw Labels to Visualize All Levels
drawLabel(yloc, label_text, color) =>
    var label_id = label.new(bar_index, na, text = label_text, color = color, style = label.style_label_lower_left, textcolor = color.white)
    label.set_xy(label_id, bar_index, yloc)
 
drawLabel(bullishbreakout ? (adopt('15', (open_range_high+Buffer_Calc))) : na, "Buy", color.green)
drawLabel(bearishbreakout ? (adopt('15', (open_range_low-Buffer_Calc))) : na, "Sell", color.red)
 
drawLabel(bullishbreakout ? (adopt('15', (open_range_high+TP_SL_Calc))) : na, "Buy TP", color.green)
drawLabel(bullishbreakout ? (adopt('15', open_range_high - TP_SL_Calc + (Buffer_Calc * 2))) : na, "Buy SL", color.red)
 
drawLabel(bearishbreakout ? (adopt('15', (open_range_low-TP_SL_Calc))) : na, "Sell TP", color.green) 
drawLabel(bearishbreakout ? (adopt('15', open_range_low + TP_SL_Calc - (Buffer_Calc *2))) : na, "Sell SL", color.red)

← 返回列表