Please Understand The Pine and Write A Code With o
Please Understand The Pine and Write A Code With o
SAME FUNCTIONS FAVORABLE FOR FUTURE UPDATES THE CODE IS GIVEN BELOW:
//@version=5
indicator("Pure Price Action Structures SAM", 'SAM - Pure Price Action Structures', true,
max_labels_count = 500, max_boxes_count = 500, max_lines_count = 500)
//---------------------------------------------------------------------------------------------------------------------
// Settings
//---------------------------------------------------------------------------------------------------------------------{
//---------------------------------------------------------------------------------------------------------------------}
// User Defined Types
//---------------------------------------------------------------------------------------------------------------------{
type BAR
float open = open
float high = high
float low = low
float close = close
int index = bar_index
type ICTMS
float lastPrice
float midPrice
float prevPrice
int lastIndex
int midIndex
int prevIndex
label lastLabel
label midLabel
label prevLabel
bool isCrossed
int marketStructure
line msLine
box msLabel
type MS
int type = 0
//---------------------------------------------------------------------------------------------------------------------}
// Generic Variables
//---------------------------------------------------------------------------------------------------------------------{
//---------------------------------------------------------------------------------------------------------------------}
// Functions / Methods
//---------------------------------------------------------------------------------------------------------------------{
textSize(sizeInText) =>
switch sizeInText
'Tiny' => size.tiny
'Small' => size.small
'Normal' => size.normal
=> size.large
lineStyle(styleInText) =>
switch styleInText
'Solid' => line.style_solid
'Dotted' => line.style_dotted
'Dashed' => line.style_dashed
if labelEnabled
this.msLabel := box.new(this.lastIndex, this.lastPrice, bar.index, this.lastPrice, color(na), bgcolor
= color(na),
text = marketStructure.type == (isBullish ? -1 : 1) ? termText + '-MSS' : termText + '-BOS',
text_size = size.tiny, text_halign = text.align_left, text_valign = isBullish ? text.align_bottom :
text.align_top, text_color = color.new(color, 17))
marketStructure.setType(isBullish ? 1 : -1)
//---------------------------------------------------------------------------------------------------------------------}
// Calculations - ICT Short Term Market Structures
//---------------------------------------------------------------------------------------------------------------------{
//---------------------------------------------------------------------------------------------------------------------}
// Calculations - ICT Intermediate Term Market Structures
//---------------------------------------------------------------------------------------------------------------------{
cITL = stLow.queryPatterns(false)
itLow.lastLabel := stLow.midLabel
if itSwings != 'Disabled'
TX = itSwings == '△▽' ? '△' : itSwings == '◈' ? '◈' : itLow.lastPrice > itLow.midPrice ? 'IT-LH' : 'IT-
LL'
stLow.midLabel.set_text(TX)
stLow.midLabel.set_size(textSize(itSwingsSZ))
stLow.midLabel.set_textcolor(itBearMSColor)
cITH = stHigh.queryPatterns(true)
itHigh.lastLabel := stHigh.midLabel
if itSwings != 'Disabled'
TX = itSwings == '△▽' ? '▽' : itSwings == '◈' ? '◈' : itHigh.lastPrice > itHigh.midPrice ? 'IT-HH' : 'IT-
HL'
stHigh.midLabel.set_text(TX)
stHigh.midLabel.set_size(textSize(itSwingsSZ))
stHigh.midLabel.set_textcolor(itBullMSColor)
if itMarketStructures
itLow.renderStructures(false, itMS, 'IT', itBearMSColor, itMSLineStyle, itMSLineWidth, itMSText)
itHigh.renderStructures(true, itMS, 'IT', itBullMSColor, itMSLineStyle, itMSLineWidth, itMSText)
//---------------------------------------------------------------------------------------------------------------------}
// Calculations - ICT Long Term Market Structures
//---------------------------------------------------------------------------------------------------------------------{
cLTL = itLow.queryPatterns(false)
ltLow.lastPrice := itLow.midPrice
ltLow.lastIndex := itLow.midIndex
if ltSwings != 'Disabled'
itLow.midLabel.set_text(TX)
itLow.midLabel.set_size(textSize(ltSwingsSZ))
itLow.midLabel.set_textcolor(ltBearMSColor)
cLTH = itHigh.queryPatterns(true)
TX = ltSwings == '▲▼' ? '▼' : ltSwings == '◉' ? '◉' : ltHigh.lastPrice > itHigh.midPrice ? 'LT-HL' : 'LT-
HH'
ltHigh.lastPrice := itHigh.midPrice
ltHigh.lastIndex := itHigh.midIndex
if ltSwings != 'Disabled'
itHigh.midLabel.set_text(TX)
itHigh.midLabel.set_size(textSize(ltSwingsSZ))
itHigh.midLabel.set_textcolor(ltBullMSColor)
if ltMarketStructures
ltLow.renderStructures(false, ltMS, 'LT', ltBearMSColor, ltMSLineStyle, ltMSLineWidth, ltMSText)
ltHigh.renderStructures(true, ltMS, 'LT', ltBullMSColor, ltMSLineStyle, ltMSLineWidth, ltMSText)
//---------------------------------------------------------------------------------------------------------------------}