100% found this document useful (1 vote)
452 views2 pages

SMC Trading Strategy in Pine Script

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
100% found this document useful (1 vote)
452 views2 pages

SMC Trading Strategy in Pine Script

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

//@version=5

strategy("SMC Strategy", overlay=true)

// Inputs for customization


var color bullishOrderBlockColor = [Link]([Link], 80)
var color bearishOrderBlockColor = [Link]([Link], 80)

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


//sessionStart = [Link](timestamp("2023-01-01 00:00"), title="Session Start")
//sessionEnd = [Link](timestamp("2023-12-31 00:00"), title="Session End")
showOrderBlocks = input(true, "Show Order Blocks")
riskRewardRatio = [Link](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 = [Link](10)[1] > [Link](10)[2]
isBearishShift = [Link](10)[1] < [Link](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 := [Link](left=bar_index[1], top=high,
right=bar_index[1] + 10, bottom=low, border_color=[Link], border_width=2,
bgcolor=bullishOrderBlockColor)
else
box.set_right(bullishOrderBlock, bar_index[1] + 10)

if (isBearishShift and showOrderBlocks)


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

// Define liquidity sweep zones (wicks)


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

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

// Trigger buy and sell signals


if (longCondition)
[Link]("Long", [Link])
[Link]("TP", "Long", stop=low, limit=low + (high - low) *
riskRewardRatio)
[Link](bar_index[0],low, text = "Long SL: "+ [Link](low),style =
label.style_label_down,color = [Link])
[Link](bar_index[0],low + (high - low) * riskRewardRatio, text = "Long TP:
"+ [Link](low + (high - low) * riskRewardRatio),style =
label.style_label_up,color = [Link])

if (shortCondition)
[Link]("Short", [Link])
[Link]("TP", "Short", stop=high, limit=high - (high - low) *
riskRewardRatio)
[Link](bar_index[0],high, text = "Short SL: "+ [Link](high),style =
label.style_label_down,color = [Link])
[Link](bar_index[0],high - (high - low) * riskRewardRatio, text = "Short TP:
"+ [Link](high - (high - low) * riskRewardRatio),style =
label.style_label_up,color = [Link])

// Plotting signals
plotshape(series=longCondition, title="Long Entry", location=[Link],
color=[Link], style=[Link], text="BUY")
plotshape(series=shortCondition, title="Short Entry", location=[Link],
color=[Link], style=[Link], text="SELL")

Common questions

Powered by AI

The SMC strategy determines a bullish or bearish market structure shift by comparing historical highs and lows over a defined period. A bullish shift is identified when the highest price in the last 10 periods (ta.highest(10)[1]) is greater than the previous highest price (ta.highest(10)[2]). Conversely, a bearish shift occurs when the lowest price in the last 10 periods (ta.lowest(10)[1]) is lower than the previous lowest price (ta.lowest(10)[2]).

The primary purpose of defining a risk-reward ratio in the SMC strategy is to optimize trade exits to ensure that potential rewards justify the risks. It is implemented to determine the take profit (TP) and stop loss (SL) levels in trade executions. For a long position, the stop is set at the low point of the entry candle, and the take profit is set higher by a multiple of the risk-reward ratio from the entry point. Conversely, for a short position, the stop is placed at the high and take profit lower, by the same ratio, supporting disciplined and consistent trade management .

The use of visual elements such as rectangles and labels in the SMC strategy enhances execution by providing traders with clear, graphical representations of critical levels and trade conditions. Rectangles mark the order blocks, highlighting regions of interest where significant price shifts occurred. Labels indicate entry, stop-loss, and take-profit levels, which simplifies decision-making by allowing traders to visualize key points instantly. This visual clarity facilitates more effective monitoring and adjustment of trades according to the predefined strategy rules .

The SMC strategy increases trade reliability by employing historical data comparison to identify market structure shifts and liquidity sweeps. By examining the highest and lowest prices over a defined past interval (10 periods), it detects critical changes in market dynamics, such as break of structure (BoS). This historical context allows the strategy to pinpoint potential reversal zones and trade entries, ensuring decisions are rooted in proven price patterns rather than random fluctuations, thus improving overall trade reliability .

Order blocks and liquidity sweeps help define the conditions for entry signals in the SMC strategy. Order blocks are marked after a market structure shift and are visually represented as rectangular areas on the chart. Liquidity sweep zones are identified when price exceeds recent highs or falls below recent lows, signaling potential reversal points. A long entry signal is triggered if a liquidity sweep down occurs and the close is greater than the open, while a short entry is signaled if a liquidity sweep up happens and the close is less than the open .

You might also like