本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © TFlab
//@version=5
indicator("Implied Fair Value Gap (IFVG) ICT [TradingFinder] Hidden FVG OTE", "TFlab ICT Implied", overlay = true, max_bars_back = 5000, max_lines_count = 500, max_labels_count = 500)
//import Implied Block Drawing Library
import TFlab/OrderBlockDrawing_TradingFinder/2 as Drawing
//import Alert Sender Library
import TFlab/AlertSenderLibrary_TradingFinder/1 as Alert
//Input
OBVaP = input.int(10, 'Implied Block Validity Period (Bar)' , group = 'Global Setting' , maxval = 4998 , minval = 10,
tooltip = 'You can set the validity period of each Implied Block based on the number of candles that have passed since the origin of the Implied Block.')
MLOB = input.string('Proximal' , 'Mitigation Level OB', ['Proximal', '50 % OB', 'Distal'], group = 'Global Setting' )
PImpliedFilter = input.bool(false, 'Implied Filter', group = 'Implied Filter' , inline = 'Implied Filter')
PImpliedFilterType = input.string('Very Aggressive', '',
['Very Aggressive' , 'Aggressive' , 'Defensive' , 'Very Defensive'], group = 'Implied Filter', inline = 'Implied Filter' ,
tooltip = 'If it is "On", this filter will filter "ICT Implied" based on the width of the Zone.' +
'From "Very Aggressive" to "Very Defensive" the width of the "ICT Implied" decreases.')
Show_DImp = input.bool(true, 'Show Demand Implied Block', group = 'Display Setting', inline = 'DImp')
Show_SImp = input.bool(true, 'Show Supply Implied Block', group = 'Display Setting', inline = 'SImp')
Color_DImp = input.color(#4caf4f27 , '', group = 'Display Setting', inline = 'DImp')
Color_SImp = input.color(#af4c4c27 , '', group = 'Display Setting', inline = 'SImp')
//Alert
AlertName = input.string('ICT Implied [TradingFinder]', 'Alerts Name', group = 'Alert')
Alert_Imp = input.string('On' , 'Alert ICT Implied Block Mitigation' , ['On', 'Off'], 'If you turn on the Alert ICT Implied Block Mitigation,' +
'you can receive alerts and notifications after setting the "Alert".' , group = 'Alert')
Frequncy = input.string('Once Per Bar' , 'Message Frequency' , ['All', 'Once Per Bar' , 'Per Bar Close'], 'The triggering frequency. Possible values are: All'+
' (all function calls trigger the alert), Once Per Bar (the first function call during the bar triggers the alert), ' +
' Per Bar Close (the function call triggers the alert only when it occurs during the last script iteration of the real-time bar,' +
' when it closes). The default is alert.freq_once_per_bar.)', group = 'Alert')
UTC = input.string('UTC' , 'Show Alert time by Time Zone', group = 'Alert')
//ICT Implied Detector Function
ImpliedDetector(ImpliedFilter, ImpliedFilterType)=>
var float DHighImplied = 0.0
var float DLowImplied = 0.0
var float DHighBodyImplied = 0.0
var float DLowBodyImplied = 0.0
var int DBarSImplied = 0
var float SHighImplied = 0.0
var float SLowImplied = 0.0
var float SHighBodyImplied = 0.0
var float SLowBodyImplied = 0.0
var int SBarSImplied = 0
var bool DConditionImplied = false
var bool SConditionImplied = false
//ATR
ATR = ta.atr(55)
//Demand Implied Filter Method {Choose and switch}
DConditionImplied := if ImpliedFilter == 'Off'
if ((low < high[2] ) and high[2] < ((close[0] > open[0]) ? open[0] : close[0]) and low[0] > ((close[2] > open[2]) ? close[2] : open[2]))
true
else
false
else if ImpliedFilter == 'On'
if ((low < high[2] ) and high[2] < ((close[0] > open[0]) ? open[0] : close[0]) and low[0] > ((close[2] > open[2]) ? close[2] : open[2]))
if ImpliedFilterType =='Very Aggressive' and (high > high[1] )
true
else if ImpliedFilterType =='Aggressive' and ( ((high[1] - low[1]) >= (1.0 * ATR)) and (high > high[1] ))
true
else if ImpliedFilterType == 'Defensive' and ( ((high[1] - low[1]) >= (1.5 * ATR)) and (high > high[1] ))
and ((close[2] - open[2] > 0 and close[1] - open[1] > 0) or math.abs((close[1] - open[1])/(high[1] - low[1])) > 0.7)
true
else if ImpliedFilterType =='Very Defensive' and ( ((high[1] - low[1]) >= (1.5 * ATR)) and (high > high[1] ))
and ((close[2] - open[2] > 0 and close[1] - open[1] > 0) and math.abs((close[1] - open[1])/(high[1] - low[1])) > 0.7)
and math.abs((close[2] - open[2])/(high[2] - low[2])) > 0.35 and math.abs((close - open)/(high - low)) > 0.35
true
else
false
//Supply Implied Filter Method {Choose and switch}
SConditionImplied := if ImpliedFilter == 'Off'
if ((high > low[2] ) and high[0] < ((close[2] > open[2]) ? open[2] : close[2]) and low[2] > ((close[0] > open[0]) ? close[0] : open[0]))
true
else
false
else if ImpliedFilter == 'On'
if ((high > low[2] ) and high[0] < ((close[2] > open[2]) ? open[2] : close[2]) and low[2] > ((close[0] > open[0]) ? close[0] : open[0]))
if ImpliedFilterType == 'Very Aggressive' and (low[1] > low )
true
else if ImpliedFilterType == 'Aggressive' and ( ((high[1] - low[1]) >= (1.0 * ATR)) and (low[1] > low ))
true
else if ImpliedFilterType == 'Defensive' and ( ((high[1] - low[1]) >= (1.5 * ATR)) and (low[1] > low ))
and ((close[2] - open[2] < 0 and close[1] - open[1] < 0) or math.abs((close[1] - open[1])/(high[1] - low[1])) > 0.7)
true
else if ImpliedFilterType == 'Very Defensive' and ( ((high[1] - low[1]) >= (1.5 * ATR)) and (low[1] > low ))
and ((close[2] - open[2] < 0 and close[1] - open[1] < 0) and math.abs((close[1] - open[1])/(high[1] - low[1])) > 0.7)
and math.abs((close[2] - open[2])/(high[2] - low[2])) > 0.35 and math.abs((close - open)/(high - low)) > 0.35
true
else
false
//Supply and Demand ICT Implied Detector
//Demand Implied Detector
if DConditionImplied
DHighImplied := high[2]
DLowImplied := low[0]
DHighBodyImplied := (close[2] > open[2]) ? close[2] : open[2]
DLowBodyImplied := (close[0] > open[0]) ? open[0] : close[0]
DBarSImplied := bar_index[2]
//Supply Implied Detector
if SConditionImplied
SHighImplied := high[0]
SLowImplied := low[2]
SHighBodyImplied := (close[0] > open[0]) ? close[0] : open[0]
SLowBodyImplied := (close[2] > open[2]) ? open[2] : close[2]
SBarSImplied := bar_index[2]
[DConditionImplied, DHighImplied, DLowImplied, DHighBodyImplied, DLowBodyImplied, DBarSImplied, SConditionImplied, SHighImplied, SLowImplied, SHighBodyImplied, SLowBodyImplied, SBarSImplied]
//Call Implied Detector Function
[DConditionImplied, DHighImplied, DLowImplied, DHighBodyImplied, DLowBodyImplied, DBarSImplied, SConditionImplied, SHighImplied, SLowImplied, SHighBodyImplied, SLowBodyImplied, SBarSImplied] = ImpliedDetector(PImpliedFilter ? 'On' : 'Off', PImpliedFilterType)
[Alert_DImp] = Drawing.OBDrawing('Demand' ,DConditionImplied , DLowImplied ,DHighImplied , DBarSImplied,true , OBVaP ,MLOB , true ,Show_DImp , Color_DImp )
[Alert_SImp] = Drawing.OBDrawing('Supply' ,SConditionImplied ,SHighImplied , SLowImplied , SBarSImplied,true , OBVaP ,MLOB , true ,Show_SImp , Color_SImp )
//Call Alert Function
Alert.AlertSender(Alert_DImp , Alert_Imp, AlertName, 'Demand', 'Implied Block Signal', 'Full' ,Frequncy, UTC, "Off", 'Long position in Demand Implied Block' , open, high, low, close,0,0,0,0,0)
Alert.AlertSender(Alert_SImp , Alert_Imp, AlertName, 'Supply', 'Implied Block Signal', 'Full' ,Frequncy, UTC, "Off", 'Short position in Supply Implied Block' , open, high, low, close,0,0,0,0,0)