本页源码来自 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
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © chartbox90
//@version=5
indicator("Smart Money Setup 07 [TradingFinder] Liquidity Hunts & Minor OB" , "SMC Setup Order Blocks 07 TFlab" , overlay = true , max_bars_back = 5000 , max_boxes_count = 500 , max_labels_count = 500 , max_lines_count = 500)
//import Libraries
//import Order Block Refiner
import TFlab/OrderBlockRefiner_TradingFinder/2 as Refiner
//import Order Block Drawing Library
import TFlab/OrderBlockDrawing_TradingFinder/4 as Drawing
//import Order Block Overlapping
import TFlab/AlertSenderLibrary_TradingFinder/1 as Alert
//Input
PP = input.int(2 , "Pivot Period", minval = 2)
OBVaP = input.int(500, 'Order Block Validity Period (Bar)' , group = 'Global Setting' , maxval = 4998 , minval = 10,
tooltip = 'You can set the validity period of each Order Block based on the number of candles that have passed since the origin of the Order Block.')
MLOB = input.string('Proximal' , 'Mitigation Level OB', ['Proximal', '50 % OB', 'Distal'] )
Refine= input.bool(true, 'Order Block Refine.',
'If you want this "Supply Main Order Block, ChoCh Origin" to be refined to display a optimal range,' +
'you should select "On" and if you want to see the original' +
'range of the block order, you should select "Off".' +
'\nAlso, if you are a risk taker, you can choose the "Aggressive" Refine method,' +
'and if you are risk averse, you can choose the "Defensive" Refine method.'
, group ='Order Blocks Refinement ', inline = 'Refine')
RefineMe = input.string('Defensive', '', ['Defensive', 'Aggressive'] ,
group = 'Order Blocks Refinement ', inline = 'Refine')
//Calculation
ATR =ta.atr(50)
Open = open
High = high
Low = low
Close = close
Bar_Index = bar_index
var ArrayType = array.new_string()
var ArrayValue = array.new_float()
var ArrayIndex = array.new_int()
var Line = array.new_line()
HighPivot = ta.pivothigh(PP,PP)
LowPivot = ta.pivotlow(PP,PP)
HighValue = ta.valuewhen(HighPivot ,high[PP], 0)
LowValue = ta.valuewhen(LowPivot ,low[PP], 0)
HighIndex = ta.valuewhen(HighPivot ,bar_index[PP], 0)
LowIndex = ta.valuewhen(LowPivot ,bar_index[PP], 0)
Correct_HighPivot = 0.0
Correct_LowPivot = 0.0
PASS = 0
if HighPivot and LowPivot
if ArrayType.size() == 0
PASS := 1
else if ArrayType.size() >= 1
if ((ArrayType.get(ArrayType.size() - 1)) == "L" or
(ArrayType.get(ArrayType.size() - 1)) == "LL")
if LowPivot < ArrayValue.get(ArrayType.size() - 1)
array.remove(ArrayType,ArrayType.size() - 1)
array.remove(ArrayValue,ArrayValue.size() - 1)
array.remove(ArrayIndex,ArrayIndex.size() - 1)
array.push(ArrayType,ArrayType.size()>2? ArrayValue.get(ArrayType.size() - 2) < LowValue ? "HL" : "LL" : "L")///////////////////////////////Here
array.push(ArrayValue, LowValue)
array.push(ArrayIndex, LowIndex)
Correct_LowPivot := LowValue
else
array.push(ArrayType,ArrayType.size()>2? ArrayValue.get(ArrayType.size() - 2) < HighValue ? "HH" : "LH" : "H" ) ///////////////////////////////Here
array.push(ArrayValue, HighValue)
array.push(ArrayIndex, HighIndex)
Correct_HighPivot := HighValue
else if (ArrayType.get(ArrayType.size() - 1)) == "H" or
(ArrayType.get(ArrayType.size() - 1)) == "HH"
if HighPivot > ArrayValue.get(ArrayType.size() - 1)
array.remove(ArrayType,ArrayType.size() - 1)
array.remove(ArrayValue,ArrayValue.size() - 1)
array.remove(ArrayIndex,ArrayIndex.size() - 1)
array.push(ArrayType,ArrayType.size()>2? ArrayValue.get(ArrayType.size() - 2) < HighValue ? "HH" : "LH" : "H")///////////////////////////////Here
array.push(ArrayValue, HighValue)
array.push(ArrayIndex, HighIndex)
Correct_HighPivot := HighValue
else
array.push(ArrayType,ArrayType.size()>2? ArrayValue.get(ArrayType.size() - 2) < LowValue ? "HL" : "LL" : "L")///////////////////////////////Here
array.push(ArrayValue, LowValue)
array.push(ArrayIndex, LowIndex)
Correct_LowPivot := LowValue
else if (ArrayType.get(ArrayType.size() - 1)) == "LH"
if HighPivot < ArrayValue.get(ArrayType.size() - 1)
array.push(ArrayType,ArrayType.size()>2? ArrayValue.get(ArrayType.size() - 2) < LowValue ? "HL" : "LL" : "L")///////////////////////////////Here
array.push(ArrayValue, LowValue)
array.push(ArrayIndex, LowIndex)
Correct_LowPivot := LowValue
else if HighPivot > ArrayValue.get(ArrayType.size() - 1)
if close < ArrayValue.get(ArrayType.size() - 1)
array.remove(ArrayType,ArrayType.size() - 1)
array.remove(ArrayValue,ArrayValue.size() - 1)
array.remove(ArrayIndex,ArrayIndex.size() - 1)
array.push(ArrayType,ArrayType.size()>2? ArrayValue.get(ArrayType.size() - 2) < HighValue ? "HH" : "LH" : "H")///////////////////////////////Here
array.push(ArrayValue, HighValue)
array.push(ArrayIndex, HighIndex)
Correct_HighPivot := HighValue
else if close > ArrayValue.get(ArrayType.size() - 1)
array.push(ArrayType,ArrayType.size()>2? ArrayValue.get(ArrayType.size() - 2) < LowValue ? "HL" : "LL" : "L")///////////////////////////////Here
array.push(ArrayValue, LowValue)
array.push(ArrayIndex, LowIndex)
Correct_LowPivot := LowValue
else if (ArrayType.get(ArrayType.size() - 1)) == "HL"
if LowPivot > ArrayValue.get(ArrayType.size() - 1)
array.push(ArrayType,ArrayType.size()>2? ArrayValue.get(ArrayType.size() - 2) < HighValue ? "HH" : "LH" : "H" ) ///////////////////////////////Here
array.push(ArrayValue, HighValue)
array.push(ArrayIndex, HighIndex)
Correct_HighPivot := HighValue
else if LowPivot < ArrayValue.get(ArrayType.size() - 1)
if close > ArrayValue.get(ArrayType.size() - 1)
array.remove(ArrayType,ArrayType.size() - 1)
array.remove(ArrayValue,ArrayValue.size() - 1)
array.remove(ArrayIndex,ArrayIndex.size() - 1)
array.push(ArrayType,ArrayType.size()>2? ArrayValue.get(ArrayType.size() - 2) < LowValue ? "HL" : "LL" : "L")///////////////////////////////Here
array.push(ArrayValue, LowValue)
array.push(ArrayIndex, LowIndex)
Correct_LowPivot := LowValue
else if close < ArrayValue.get(ArrayType.size() - 1)
array.push(ArrayType,ArrayType.size()>2? ArrayValue.get(ArrayType.size() - 2) < HighValue ? "HH" : "LH" : "H")///////////////////////////////Here
array.push(ArrayValue, HighValue)
array.push(ArrayIndex, HighIndex)
Correct_HighPivot := HighValue
else if HighPivot
if ArrayType.size() == 0
array.insert(ArrayType, 0, "H")
array.insert(ArrayValue, 0, HighValue)
array.insert(ArrayIndex, 0, HighIndex)
Correct_HighPivot := HighValue
else if ArrayType.size() >= 1
if ((ArrayType.get(ArrayType.size() - 1)) == "L" or
(ArrayType.get(ArrayType.size() - 1)) == "HL" or
(ArrayType.get(ArrayType.size() - 1)) == "LL")
if HighPivot > ArrayValue.get(ArrayType.size() - 1)
array.push(ArrayType,ArrayType.size()>2? ArrayValue.get(ArrayType.size() - 2) < HighValue ? "HH" : "LH" : "H" ) ///////////////////////////////Here
array.push(ArrayValue, HighValue)
array.push(ArrayIndex, HighIndex)
Correct_HighPivot := HighValue
else if HighPivot < ArrayValue.get(ArrayType.size() - 1)
array.remove(ArrayType,ArrayType.size() - 1)
array.remove(ArrayValue,ArrayValue.size() - 1)
array.remove(ArrayIndex,ArrayIndex.size() - 1)
array.push(ArrayType,ArrayType.size()>2? ArrayValue.get(ArrayType.size() - 2) < LowValue ? "HL" : "LL" : "L")///////////////////////////////Here
array.push(ArrayValue, LowValue)
array.push(ArrayIndex, LowIndex)
Correct_LowPivot := LowValue
else if (ArrayType.get(ArrayType.size() - 1)) == "H" or
(ArrayType.get(ArrayType.size() - 1)) == "HH" or
(ArrayType.get(ArrayType.size() - 1)) == "LH"
if (ArrayValue.get(ArrayValue.size() - 1)) < HighValue
array.remove(ArrayType,ArrayType.size() - 1)
array.remove(ArrayValue,ArrayValue.size() - 1)
array.remove(ArrayIndex,ArrayIndex.size() - 1)
array.push(ArrayType,ArrayType.size()>2? ArrayValue.get(ArrayType.size() - 2) < HighValue ? "HH" : "LH" : "H")///////////////////////////////Here
array.push(ArrayValue, HighValue)
array.push(ArrayIndex, HighIndex)
Correct_HighPivot := HighValue
else if LowPivot
if ArrayType.size() == 0
array.insert(ArrayType, 0, "L")
array.insert(ArrayValue, 0, LowValue)
array.insert(ArrayIndex, 0, LowIndex)
Correct_LowPivot := LowValue
else if ArrayType.size() >= 1
if (ArrayType.get(ArrayType.size() - 1)) == "H" or
(ArrayType.get(ArrayType.size() - 1)) == "HH" or
(ArrayType.get(ArrayType.size() - 1)) == "LH"
if LowPivot < ArrayValue.get(ArrayType.size() - 1)
array.push(ArrayType,ArrayType.size()>2? ArrayValue.get(ArrayType.size() - 2) < LowValue ? "HL" : "LL" : "L")///////////////////////////////Here
array.push(ArrayValue, LowValue)
array.push(ArrayIndex, LowIndex)
Correct_LowPivot := LowValue
else if LowPivot > ArrayValue.get(ArrayType.size() - 1)
array.remove(ArrayType,ArrayType.size() - 1)
array.remove(ArrayValue,ArrayValue.size() - 1)
array.remove(ArrayIndex,ArrayIndex.size() - 1)
array.push(ArrayType,ArrayType.size()>2? ArrayValue.get(ArrayType.size() - 2) < HighValue ? "HH" : "LH" : "H")///////////////////////////////Here
array.push(ArrayValue, HighValue)
array.push(ArrayIndex, HighIndex)
Correct_HighPivot := HighValue
else if (ArrayType.get(ArrayType.size() - 1)) == "L" or
(ArrayType.get(ArrayType.size() - 1)) == "HL" or
(ArrayType.get(ArrayType.size() - 1)) == "LL"
if (ArrayValue.get(ArrayValue.size() - 1)) > LowValue
array.remove(ArrayType,ArrayType.size() - 1)
array.remove(ArrayValue,ArrayValue.size() - 1)
array.remove(ArrayIndex,ArrayIndex.size() - 1)
array.push(ArrayType,ArrayType.size()>2? ArrayValue.get(ArrayType.size() - 2) < LowValue ? "HL" : "LL" : "L")///////////////////////////////Here
array.push(ArrayValue, LowValue)
array.push(ArrayIndex, LowIndex)
Correct_LowPivot := LowValue
var string TypePoint0 = ''
var string TypePoint1 = ''
var string TypePoint2 = ''
var string TypePoint3 = ''
var string TypePoint4 = ''
var string TypePoint5 = ''
var string TypePoint6 = ''
var string TypePoint7 = ''
var float PricePoint0 = 0.0
var float PricePoint1 = 0.0
var float PricePoint2 = 0.0
var float PricePoint3 = 0.0
var float PricePoint4 = 0.0
var float PricePoint5 = 0.0
var float PricePoint6 = 0.0
var float PricePoint7 = 0.0
var int IndexPoint0 = 0
var int IndexPoint1 = 0
var int IndexPoint2 = 0
var int IndexPoint3 = 0
var int IndexPoint4 = 0
var int IndexPoint5 = 0
var int IndexPoint6 = 0
var int IndexPoint7 = 0
if ArrayType.size() > 8
TypePoint0 := ArrayType.get(ArrayType.size() - 1)
TypePoint1 := ArrayType.get(ArrayType.size() - 2)
TypePoint2 := ArrayType.get(ArrayType.size() - 3)
TypePoint3 := ArrayType.get(ArrayType.size() - 4)
TypePoint4 := ArrayType.get(ArrayType.size() - 5)
TypePoint5 := ArrayType.get(ArrayType.size() - 6)
TypePoint6 := ArrayType.get(ArrayType.size() - 7)
TypePoint7 := ArrayType.get(ArrayType.size() - 8)
PricePoint0 := ArrayValue.get(ArrayType.size() - 1)
PricePoint1 := ArrayValue.get(ArrayType.size() - 2)
PricePoint2 := ArrayValue.get(ArrayType.size() - 3)
PricePoint3 := ArrayValue.get(ArrayType.size() - 4)
PricePoint4 := ArrayValue.get(ArrayType.size() - 5)
PricePoint5 := ArrayValue.get(ArrayType.size() - 6)
PricePoint6 := ArrayValue.get(ArrayType.size() - 7)
PricePoint7 := ArrayValue.get(ArrayType.size() - 8)
IndexPoint0 := ArrayIndex.get(ArrayType.size() - 1)
IndexPoint1 := ArrayIndex.get(ArrayType.size() - 2)
IndexPoint2 := ArrayIndex.get(ArrayType.size() - 3)
IndexPoint3 := ArrayIndex.get(ArrayType.size() - 4)
IndexPoint4 := ArrayIndex.get(ArrayType.size() - 5)
IndexPoint5 := ArrayIndex.get(ArrayType.size() - 6)
IndexPoint6 := ArrayIndex.get(ArrayType.size() - 7)
IndexPoint7 := ArrayIndex.get(ArrayType.size() - 8)
bool BearSetup07 = false
bool BullSetup07 = false
//Box Data
//Bearish SetUp
var int BeOBI = 0
//Bullish SetUp
var int BuOBI = 0
//Bearish Logic
if TypePoint0 == 'LL' and
TypePoint1 == 'LH' and
TypePoint2 == 'HL' and
TypePoint3 == 'LH' and
TypePoint4 == 'LL' and
TypePoint5 == 'LH' and
TypePoint6 == 'LL' and
PricePoint0 > PricePoint4 and
IndexPoint0 == bar_index - PP
BearSetup07 := true
BeOBI := IndexPoint5
else
BearSetup07 := false
//Bullish Logic
if TypePoint0 == 'HH' and
TypePoint1 == 'HL' and
TypePoint2 == 'LH' and
TypePoint3 == 'HL' and
TypePoint4 == 'HH' and
TypePoint5 == 'HL' and
TypePoint6 == 'HH' and
PricePoint0 < PricePoint4 and
IndexPoint0 == bar_index - PP
BullSetup07 := true
BuOBI := IndexPoint5
else
BullSetup07 := false
plotshape(BearSetup07 ,
"Bear Setup07" ,
style = shape.arrowup ,
location = location.belowbar ,
color = color.rgb(179, 2, 2) ,
offset = -PP ,
text = "Bear Setup07",
textcolor = color.rgb(179, 2, 22) )
plotshape(BullSetup07 ,
"Bull Setup07" ,
style = shape.arrowdown ,
location = location.abovebar ,
color = color.rgb(47, 156, 38) ,
offset = -PP ,
text = "Bull Setup07",
textcolor = color.rgb(47, 156, 38) )
////////////////////////////////////////////////////
///////////////Order Block Refinement///////////////
////////////////////////////////////////////////////
[Bu_Xd1, Bu_Xd2, Bu_Yd12, Bu_Xp1, Bu_Xp2, Bu_Yp12] =
Refiner.OBRefiner('Demand', Refine ? 'On' : 'Off', RefineMe,BullSetup07 , BuOBI)
[Be_Xd1, Be_Xd2, Be_Yd12, Be_Xp1, Be_Xp2, Be_Yp12] =
Refiner.OBRefiner('Supply', Refine ? 'On' : 'Off', RefineMe ,BearSetup07 , BeOBI)
////////////////////////////////////////////////////
////////////////////////Drawing/////////////////////
////////////////////////////////////////////////////
[Alert_DAMM, Alert_SAMMbb, PASBB, DASBB, IASBB] = Drawing.OBDrawing('Demand', BullSetup07 ,Bu_Yd12 ,Bu_Yp12 ,Bu_Xd1 ,true , OBVaP ,MLOB ,MLOB , true ,false ,true, false, #2d9b3167, na)
[Alert_SMMM, Alert_DMMMbb, PMDBB, DMDBB, IMDBB] = Drawing.OBDrawing('Supply', BearSetup07 ,Be_Yd12 ,Be_Yp12 ,Be_Xd1 ,true , OBVaP ,MLOB ,MLOB , true ,false ,true, false, #ff525254 , na)