Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
581 views2 pages

PinescriptSMC Pine

The document outlines a trading strategy called 'SMC Strategy' implemented in Pine Script for use on trading platforms. It includes features for detecting market structure shifts, marking order blocks, and plotting liquidity sweeps, along with entry conditions for long and short positions based on these indicators. The strategy allows customization of order block visibility and risk-reward ratios for trades.

Uploaded by

warumonokisou
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
581 views2 pages

PinescriptSMC Pine

The document outlines a trading strategy called 'SMC Strategy' implemented in Pine Script for use on trading platforms. It includes features for detecting market structure shifts, marking order blocks, and plotting liquidity sweeps, along with entry conditions for long and short positions based on these indicators. The strategy allows customization of order block visibility and risk-reward ratios for trades.

Uploaded by

warumonokisou
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

//@version=5

strategy("SMC Strategy", overlay=true)

// Inputs for customization


var color bullishOrderBlockColor = color.new(color.green, 80)
var color bearishOrderBlockColor = color.new(color.red, 80)

// Define time periods to focus (useful for different trading sessions)


//sessionStart = input.time(timestamp("2023-01-01 00:00"), title="Session Start")
//sessionEnd = input.time(timestamp("2023-12-31 00:00"), title="Session End")
showOrderBlocks = input(true, "Show Order Blocks")
riskRewardRatio = input.float(2.0, "Risk-Reward Ratio")

// Define SMC concepts


var float highPoint = na
var float lowPoint = na

// Market structure shift - look for break of structure (BoS)


isBullishShift = ta.highest(10)[1] > ta.highest(10)[2]
isBearishShift = ta.lowest(10)[1] < ta.lowest(10)[2]

// Mark order blocks after market shift


if (isBullishShift)
highPoint := high
if (isBearishShift)
lowPoint := low

// Define order blocks


var line bullishOB = na
var line bearishOB = na
// Order Block Detection and Drawing with Rectangles
var box bullishOrderBlock = na
var box bearishOrderBlock = na
if (isBullishShift and showOrderBlocks)
if (na(bullishOrderBlock))
bullishOrderBlock := box.new(left=bar_index[1], top=high,
right=bar_index[1] + 10, bottom=low, border_color=color.green, border_width=2,
bgcolor=bullishOrderBlockColor)
else
box.set_right(bullishOrderBlock, bar_index[1] + 10)

if (isBearishShift and showOrderBlocks)


if (na(bearishOrderBlock))
bearishOrderBlock := box.new(left=bar_index[1], top=high,
right=bar_index[1] + 10, bottom=low, border_color=color.red, border_width=2,
bgcolor=bearishOrderBlockColor)
else
box.set_right(bearishOrderBlock, bar_index[1] + 10)

// Define liquidity sweep zones (wicks)


liquiditySweepUp = high > ta.highest(10)[1]
liquiditySweepDown = low < ta.lowest(10)[1]
// Plot liquidity sweeps as liquidity floors and ceilings
if (liquiditySweepDown)
line.new(bar_index[0], low, bar_index[0] + 5, low, width=2,
color=color.new(color.blue, 0), style=line.style_solid)

if (liquiditySweepUp)
line.new(bar_index[0], high, bar_index[0] + 5, high, width=2,
color=color.new(color.purple, 0), style=line.style_solid)
// Entry strategy
longCondition = liquiditySweepDown and close > open
shortCondition = liquiditySweepUp and close < open

// Trigger buy and sell signals


if (longCondition)
strategy.entry("Long", strategy.long)
strategy.exit("TP", "Long", stop=low, limit=low + (high - low) *
riskRewardRatio)
label.new(bar_index[0],low, text = "Long SL: "+ str.tostring(low),style =
label.style_label_down,color = color.red)
label.new(bar_index[0],low + (high - low) * riskRewardRatio, text = "Long TP:
"+ str.tostring(low + (high - low) * riskRewardRatio),style =
label.style_label_up,color = color.green)

if (shortCondition)
strategy.entry("Short", strategy.short)
strategy.exit("TP", "Short", stop=high, limit=high - (high - low) *
riskRewardRatio)
label.new(bar_index[0],high, text = "Short SL: "+ str.tostring(high),style =
label.style_label_down,color = color.red)
label.new(bar_index[0],high - (high - low) * riskRewardRatio, text = "Short TP:
"+ str.tostring(high - (high - low) * riskRewardRatio),style =
label.style_label_up,color = color.green)

// Plotting signals
plotshape(series=longCondition, title="Long Entry", location=location.belowbar,
color=color.green, style=shape.labelup, text="BUY")
plotshape(series=shortCondition, title="Short Entry", location=location.abovebar,
color=color.red, style=shape.labeldown, text="SELL")

You might also like