Ivan’s indicator SMC is far too interesting and advanced not to be used in a strategy. Unfortunately, my skills aren’t sufficient to fully harness the indicator’s potential. Is there anyone here who wants to give it a try?
Smart Money Concepts (SMC)
Smart Money Concepts (SMC) Indicator
You have top use CALL to get data returned from the indicator. It requires 10 input paraemters and returns none:
CALL "PRC_Smart Money Concepts"[50, 1, 1, 1, 1, 1, 1, 5, 0, 1]
The web page in the link you posted explains those parameters (see also my attached pic).
In any case, since it returns no data, it’s impossible to use it in a strategy, it’s just for manual trading.
To be able to use it in a strategy you need to specify what signals you want to be returned.
I think, you should allow Ivan some time as the indicator seems complex to convert into a strategy, especially if you consider different timeframes showing different demand / supply zones and then how to define which one to target.
Ivan would it be possible to make a strategy based on your indicator?
Hi. This would take quite a few hours 🙂
We can do something quick. For example use the internal structure change signals to enter longs and shorts.
Copy and paste the indicator into the backtester. You will see that there are errors due to the drawing functions.
We do a quick clean up by removing the drawing lines.
At the end of the code we enter the buy/sell orders:
mytopsignal=$itopy[m]
mybotsignal=$iboty[s]
if mytopsignal<>mytopsignal[1] and $ichoch[m]=1 then
buy 10 contract at market
set stop %loss 5
set target %profit 5
endif
//-----------------------------------------------------------------------------//
if mybotsignal<>mybotsignal[1] and $ibotchoch[s]=1 then
sellshort 10 contract at market
set stop %loss 5
set target %profit 5
endif
The following code will give you buy and sell signals. Notice that it is far from debugged and that there are variables that are not used. I just want to show a base to start from.
//--------------------------------------------------------------------------------//
//PRC_Smart Money Concepts
//version = 1
//29.07.2024
//Iván González @ www.prorealcode.com
//Sharing ProRealTime knowledge
//--------------------------------------------------------------------------------//
//-----Inputs---------------------------------------------------------------------//
length=50
n=barindex
showswings=1
showHLswings=1
showinternals=1
showibull=1//1=all 2=bos 3=CHoCH
showibear=1//1=all 2=bos 3=CHoCH
showStructure=1
showbull=1//1=all 2=bos 3=CHoCH
showbear=1//1=all 2=bos 3=CHoCH
showOB=1
showiOB=1
showlastOB=5
ifilterConfluence=0
obFilter=1 //1=ATR 0=Cumulative mean Range
mult=2
bblength=20
//--------------------------------------------------------------------------------//
//--------------------------------------------------------------------------------//
atr=averagetruerange[200](close)
cmeanrange=summation[max(1,n)](high-low)/n
//--------------------------------------------------------------------------------//
//-----Bollinger Bands Calculation------------------------------------------------//
averageBB=average[bblength](close)
dev=mult*std[bblength](close)
upperBB=averageBB+dev
lowerBB=averageBB-dev
//--------------------------------------------------------------------------------//
//-----Swings---------------------------------------------------------------------//
//---Swing length
os=0
upper=highest[length](high)
lower=lowest[length](low)
if high[length]>upper then
os=0
elsif low[length]<lower then
os=1
else
os=os[1]
endif
if os=0 and os[1]<>0 then
mytop=high[length]
else
mytop=0
endif
if os=1 and os[1]<>1 then
mybot=low[length]
else
mybot=0
endif
//---Swing 5
os1=0
upper1=highest[5](high)
lower1=lowest[5](low)
if high[5]>upper1 then
os1=0
elsif low[5]<lower1 then
os1=1
else
os1=os1[1]
endif
if os1=0 and os1[1]<>0 then
itop=high[5]
else
itop=0
endif
if os1=1 and os1[1]<>1 then
ibot=low[5]
else
ibot=0
endif
//--------------------------------------------------------------------------------//
//-----Pivot High-----------------------------------------------------------------//
if mytop then
topcross=1
if showswings then
if mytop>topy then
$phy[z+1]=mytop
$phx[z+1]=n-length
$phtype[z+1]=1
z=z+1
else
$phy[z+1]=mytop
$phx[z+1]=n-length
$phtype[z+1]=-1
z=z+1
endif
endif
topy=mytop
topx=n-length
endif
if itop then
itopcross=1
itopy=itop
itopx=n-5
endif
//--------------------------------------------------------------------------------//
//-----Pivot Low------------------------------------------------------------------//
if mybot then
botcross=1
if showswings then
if mybot<boty then
$ply[k+1]=mybot
$plx[k+1]=n-length
$pltype[k+1]=1
k=k+1
else
$ply[k+1]=mybot
$plx[k+1]=n-length
$pltype[k+1]=-1
k=k+1
endif
endif
boty=mybot
botx=n-length
endif
if ibot then
ibotcross=1
iboty=ibot
ibotx=n-5
endif
//--------------------------------------------------------------------------------//
//-----Pivot High BOS/CHoCH-------------------------------------------------------//
bullConcordant=1
if ifilterConfluence then
bullConcordant=high-max(close,open)>min(close,open-low)
endif
//Detect internal bullish structure
if close crosses over itopy and itopcross and topy<>itopy and bullConcordant then
choch=undefined
if itrend<0 then
choch=1
bullichochalert=1
else
bullibosalert=1
endif
if showinternals then
if showibull=1 or (showibull=2 and not choch) or (showibull=3 and choch) then
$itopx[m+1]=itopx
$itopy[m+1]=itopy
$ichoch[m+1]=choch
$iright[m+1]=barindex
m=m+1
endif
endif
itopcross=0
itrend=1
//Internal order block
if showiOB then
minim=9999999999
maxim=0
idx=1
if obFilter=1 then
obthreshold=atr
else
obthreshold=cmeanRange
endif
for i=1 to (n-itopx)-1 do
if (high[i]-low[i])<obthreshold[i]*2 then
minim=min(low[i],minim)
if minim=low[i] then
maxim=high[i]
idx=i
else
maxim=maxim
idx=idx
endif
endif
next
$itargetTop[t+1]=maxim
$itargetBot[t+1]=minim
$itargetLeft[t+1]=barindex[idx]
$itargetRight[t+1]=n
$itargetType[t+1]=1
t=t+1
endif
endif
//Detect bullish Structure
if close crosses over topy and topcross then
choch=undefined
if trend<0 then
choch=1
endif
if showStructure then
if showbull=1 or (showbull=2 and not choch) or (showbull=3 and choch) then
$topx[g+1]=topx
$topy[g+1]=topy
$topchoch[g+1]=choch
$right[g+1]=barindex
g=g+1
endif
endif
//order block
if showOB then
minim=9999999999
maxim=0
idx=1
if obFilter=1 then
obthreshold=atr
else
obthreshold=cmeanRange
endif
for i=1 to (n-topx)-1 do
if (high[i]-low[i])<obthreshold[i]*2 then
minim=min(low[i],minim)
if minim=low[i] then
maxim=high[i]
idx=i
else
maxim=maxim
idx=idx
endif
endif
next
$targetTop[r+1]=maxim
$targetBot[r+1]=minim
$targetLeft[r+1]=barindex[idx]
$targetRight[r+1]=n
$targetType[r+1]=1
r=r+1
endif
topcross=0
trend=1
endif
//--------------------------------------------------------------------------------//
//-----Pivot Low BOS/CHoCH--------------------------------------------------------//
bearConcordant=1
if ifilterConfluence then
bearConcordant=high-max(close,open)<min(close,open-low)
endif
//Detect internal bearish Structure
if close crosses under iboty and ibotcross and boty<>iboty and bearConcordant then
choch=0
if itrend>0 then
choch=1
bearichochalert=1
else
bearichochalert=1
endif
if showinternals then
if showibear=1 or (showibear=2 and not choch) or (showibear=3 and choch) then
$ibotx[s+1]=ibotx
$iboty[s+1]=iboty
$ibotchoch[s+1]=choch
$ibotright[s+1]=barindex
s=s+1
endif
endif
ibotcross=0
itrend=-1
//Internal order block
if showiOB then
minim=9999999999
maxim=0
idx=1
if obFilter=1 then
obthreshold=atr
else
obthreshold=cmeanRange
endif
for i=1 to (n-ibotx)-1 do
if (high[i]-low[i])<obthreshold[i]*2 then
maxim=max(high[i],maxim)
if maxim=high[i] then
minim=low[i]
idx=i
else
minim=minim
idx=idx
endif
endif
next
$itargetTop[t+1]=maxim
$itargetBot[t+1]=minim
$itargetLeft[t+1]=barindex[idx]
$itargetRight[t+1]=n
$itargetType[t+1]=-1
t=t+1
endif
endif
//Detect Bullish Strcuture
if close crosses under boty and botcross then
choch=undefined
if trend>0 then
choch=1
bearchochalert=1
else
bearbosalert=1
endif
if showStructure then
//if showbear=1 or (showbear=2 and not choch) or (showbear=3 and choch) then
//$botx[w+1]=botx
//$boty[w+1]=boty
//$botchoch[w+1]=choch
//$botright[w+1]=barindex
//w=w+1
//endif
endif
//order block
if showOB then
minim=9999999999
maxim=0
idx=1
if obFilter=1 then
obthreshold=atr
else
obthreshold=cmeanRange
endif
for i=1 to (n-botx)-1 do
if (high[i]-low[i])<obthreshold[i]*2 then
maxim=max(high[i],maxim)
if maxim=high[i] then
minim=low[i]
idx=i
else
minim=minim
idx=idx
endif
endif
next
$targetTop[r+1]=maxim
$targetBot[r+1]=minim
$targetLeft[r+1]=barindex[idx]
$targetRight[r+1]=n
$targetType[r+1]=-1
r=r+1
endif
botcross=0
trend=-1
endif
//-----------------------------------------------------------------------------//
//------Signals Internal Structure---------------------------------------------//
//-----------------------------------------------------------------------------//
mytopsignal=$itopy[m]
mybotsignal=$iboty[s]
if mytopsignal<>mytopsignal[1] and $ichoch[m]=1 then
buy 10 contract at market
set stop %loss 5
set target %profit 5
endif
//-----------------------------------------------------------------------------//
if mybotsignal<>mybotsignal[1] and $ibotchoch[s]=1 then
sellshort 10 contract at market
set stop %loss 5
set target %profit 5
endif
//-----------------------------------------------------------------------------//
Thank you very much
I tried your code at many indices and different timeframes but unfortunately didnt get any usefull results.
Many thanks Iván for this indicator.
Instead of using the internal structure change signals to enter longs and shorts, what would be the code if we like to use the “Strong Low”,”Weak High”,”Weak Low”,”Strong High” as input signals ?