本页源码来自 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 01 [TradingFinder] Double Order Blocks Confirmation" , "SMC Setup Order Blocks 01 TFlab" , overlay = true , max_bars_back = 4000 , max_boxes_count = 500 , max_labels_count = 500 , max_lines_count = 500)
PP = input.int(2 , "Pivot Period", minval = 2)
ATR =ta.atr(50)
// ArrayType, ArrayValue ,
// ZigZag(Open ,High ,Low ,Close ,Bar_Index ,PP ) =>
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 BearSetup04 = false
bool BullSetup04 = false
//Box Data
//Bearish SetUp
BeOpen1 = 0.0
BeHigh1 = 0.0
BeLow1 = 0.0
BeClose1 = 0.0
BeOpen5 = 0.0
BeHigh5 = 0.0
BeLow5 = 0.0
BeClose5 = 0.0
//Bullish SetUp
BuOpen1 = 0.0
BuHigh1 = 0.0
BuLow1 = 0.0
BuClose1 = 0.0
BuOpen5 = 0.0
BuHigh5 = 0.0
BuLow5 = 0.0
BuClose5 = 0.0
//Bearish Logic
if TypePoint0 == 'LL' and
TypePoint1 == 'HH' and
TypePoint2 == 'HL' and
TypePoint3 == 'LH' and
TypePoint4 == 'LL' and
TypePoint5 == 'LH' and
TypePoint6 == 'LL' and
PricePoint0 > PricePoint4 and
PricePoint5 > PricePoint1 and
IndexPoint0 == bar_index - PP
BearSetup04 := true
BeOpen1 := open[bar_index - IndexPoint1]
BeHigh1 := high[bar_index - IndexPoint1]
BeLow1 := low[bar_index - IndexPoint1]
BeClose1 := close[bar_index - IndexPoint1]
BeOpen5 := open[bar_index - IndexPoint5]
BeHigh5 := high[bar_index - IndexPoint5]
BeLow5 := low[bar_index - IndexPoint5]
BeClose5 := close[bar_index - IndexPoint5]
else
BearSetup04 := false
//Bullish Logic
if TypePoint0 == 'HH' and
TypePoint1 == 'LL' and
TypePoint2 == 'LH' and
TypePoint3 == 'HL' and
TypePoint4 == 'HH' and
TypePoint5 == 'HL' and
TypePoint6 == 'HH' and
PricePoint0 < PricePoint4 and
PricePoint5 < PricePoint1 and
IndexPoint0 == bar_index - PP
BullSetup04 := true
BuOpen1 := open[bar_index - IndexPoint1]
BuHigh1 := high[bar_index - IndexPoint1]
BuLow1 := low[bar_index - IndexPoint1]
BuClose1 := close[bar_index - IndexPoint1]
BuOpen5 := open[bar_index - IndexPoint5]
BuHigh5 := high[bar_index - IndexPoint5]
BuLow5 := low[bar_index - IndexPoint5]
BuClose5 := close[bar_index - IndexPoint5]
else
BullSetup04 := false
plotshape(BearSetup04 and BeLow5 <= BeHigh1 ,
"Bear Setup04" ,
style = shape.arrowup ,
location = location.belowbar ,
color = color.rgb(179, 2, 2) ,
offset = -PP ,
text = "Bear Setup04",
textcolor = color.rgb(179, 2, 22) )
plotshape(BullSetup04 and BuLow1 <= BuHigh5 ,
"Bull Setup04" ,
style = shape.arrowdown ,
location = location.abovebar ,
color = color.rgb(47, 156, 38) ,
offset = -PP ,
text = "Bull Setup04",
textcolor = color.rgb(47, 156, 38) )
var box [] supply_box_HTF = array.new_box()
var box [] supply_box_LTF = array.new_box()
var box [] Demand_box_HTF = array.new_box()
var box [] Demand_box_LTF = array.new_box()
//Supply Boxes
if BearSetup04 and BeLow5 <= BeHigh1
array.push(supply_box_HTF,
box.new(left =IndexPoint5,
top= BeHigh5 ,
right =bar_index + (bar_index - IndexPoint5),
bottom = BeLow5,
xloc = xloc.bar_index, bgcolor = color.rgb(197, 200, 202, 57),
text = "Supply OB" , text_size = size.tiny, text_valign = text.align_center))
array.push(supply_box_LTF,
box.new(left =IndexPoint1,
top= BeHigh1 ,
right =bar_index + (20),
bottom = BeLow1,
xloc = xloc.bar_index, bgcolor = color.rgb(252, 231, 48, 57),
text = "Supply OB LTF" , text_size = size.tiny, text_valign = text.align_center))
//Demand Boxes
if BullSetup04 and BuLow1 <= BuHigh5
array.push(Demand_box_HTF,
box.new(left =IndexPoint5,
top= BuHigh5 ,
right =bar_index + (bar_index - IndexPoint5),
bottom = BuLow5,
xloc = xloc.bar_index, bgcolor = color.rgb(197, 200, 202, 57),
text = "Demand OB" , text_size = size.tiny, text_valign = text.align_center))
array.push(Demand_box_LTF,
box.new(left =IndexPoint1,
top= BuHigh1 ,
right =bar_index + (20),
bottom = BuLow1,
xloc = xloc.bar_index, bgcolor = color.rgb(48, 252, 242, 57),
text = "Demand OB LTF" , text_size = size.tiny, text_valign = text.align_center))