Liquidity Pools

FX365_Thailand · study · 60 行 · 点赞 9,750 · TradingView 原页

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

Pine Script

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © FX365_Thailand
 
//Revision history
//v100.0 First release
 
//@version=5
indicator('Liquidity Pools', shorttitle='Liquidity Pools(SABAI SABAI FX)', max_lines_count=500,overlay=true)
    
 
//Users' input ------
len_l = input.int(4, 'Left bar&Right bar', minval=1,group="Swing High Low Setting")
flg_shsl = input.bool(false, 'Show Swing High Swing Low')
 
i_width = input.int(1, 'Line Width', minval=1,maxval=6,group="Liquidity Pools Settings")
i_linestyle = input.string(defval=line.style_dotted,options=[line.style_solid,line.style_dashed,line.style_dotted],title="Sell Side Liquidity Color")
i_linecolor_bs = input.color(color.new(#ff5252,65),title="Buy Side Liquidity Color")
i_linecolor_ss = input.color(color.new(#0ef30e,65),title="Sell Side Liquidity Color")
 
 
h = high
l = low
 
 
//Identify swingh high/low -----
swing_h = ta.pivothigh(h, len_l, len_l)
swing_l = ta.pivotlow(l, len_l, len_l)
 
//Value of Swing High/Swing Low
LSH = ta.valuewhen(swing_h, high[len_l], 0)
LSL = ta.valuewhen(swing_l, low[len_l], 0)
 
plotshape(flg_shsl ? swing_h : na, color=color.new(color.gray, 0), style=shape.labeldown, title='Swing High', text='SH', textcolor=color.new(color.white, 0), location=location.abovebar, offset=-len_l,size=size.tiny)
plotshape(flg_shsl ? swing_l : na, color=color.new(color.gray, 0), style=shape.labelup, title='Swing Low', text='SL', textcolor=color.new(color.white, 0), location=location.belowbar, offset=-len_l,size=size.tiny)
 
 
//Draw liquidity pools
//Variables
var line lin_BSLQ_upper = na
var line lin_BSLQ_lower = na
var line lin_SSLQ_upper = na
var line lin_SSLQ_lower = na
 
//Threshold 
thresh = timeframe.isseconds ? 1.0001 :  (timeframe.period == "60" and timeframe.period=="240") ? 3 : (timeframe.isminutes and timeframe.period != "60" and timeframe.period != "240") ? 1.0001 : timeframe.isdaily ? 1.005 : timeframe.isweekly ? 1.01 : timeframe.ismonthly ? 1.01 : 1.001
thresh_ = timeframe.isseconds ? 0.9999 :  (timeframe.period == "60" and timeframe.period=="240") ? 3 : (timeframe.isminutes and timeframe.period != "60" and timeframe.period != "240") ? 0.9999 : timeframe.isdaily ? 0.995 : timeframe.isweekly ? 0.99 : timeframe.ismonthly ? 0.99 : 0.999
 
//Lines
if swing_h
    lin_BSLQ_lower := line.new(x1=bar_index-len_l,x2=bar_index, y1=LSH,y2=LSH,color=i_linecolor_bs,style= i_linestyle,width = i_width)
if swing_h
    lin_BSLQ_upper := line.new(x1=bar_index-len_l,x2=bar_index, y1=LSH*thresh,y2=LSH*thresh,color=i_linecolor_bs,style= i_linestyle,width = i_width)
if swing_l
    lin_SSLQ_lower := line.new(x1=bar_index-len_l,x2=bar_index, y1=LSL*thresh_,y2=LSL*thresh_,color=i_linecolor_ss,style=i_linestyle,width = i_width)
if swing_l
    lin_SSLQ_upper := line.new(x1=bar_index-len_l,x2=bar_index, y1=LSL,y2=LSL,color=i_linecolor_ss,style= i_linestyle,width = i_width)
 
//Fill
linefill.new(lin_BSLQ_upper,lin_BSLQ_lower,color=i_linecolor_bs)
linefill.new(lin_SSLQ_upper,lin_SSLQ_lower,color=i_linecolor_ss)

← 返回列表