Skip to content

Instantly share code, notes, and snippets.

@mohdhazwan
Created September 16, 2020 00:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mohdhazwan/b06359623b6f9aade13653658e713161 to your computer and use it in GitHub Desktop.
Save mohdhazwan/b06359623b6f9aade13653658e713161 to your computer and use it in GitHub Desktop.
bursaman
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © cartaman
//@version=4
strategy("BURSAMAN", shorttitle= '💰', initial_capital = 1000)
// Backtest
backtest = false
tutup = close
buka = open
lo = low
hi = high
mid = 0.00
up = tutup > buka
do = buka > tutup
// Period
startTest = timestamp(2019,1,1,0,0)
endTest = timestamp(9999,12,30,23,59)
timeRange = time > startTest and time < endTest ? true : false
// Hammer ===============================================================================================================
hshadow1 = 0.00
hshadow2 = 0.00
hheight = 0.00
if(do)
hshadow1 := hi - buka
hshadow2 := tutup - lo
hheight := buka - tutup
if(up)
hshadow1 := hi - tutup
hshadow2 := buka - lo
hheight := tutup - buka
hdiff = hi == tutup or hi == buka
// H = hdiff and (hshadow2-hheight)/hshadow2*100 > 50 and buka[1] > tutup[1]
H = hdiff and hshadow2/hheight*100 >= 200 and lo[1] >= buka and lo != buka and tutup[1] > buka
plotshape(H, 'H', style=shape.circle, location=location.belowbar, color=color.yellow, transp=0, text='H', textcolor=color.yellow, size=size.tiny)
// Morning Star ==========================================================================================================
mshadow1 = 0.00
mshadow2 = 0.00
mheight = 0.00
if(do) // bear
mshadow1 := hi[1] - buka[1]
mshadow2 := tutup[1] - lo[1]
mheight := buka[1] - tutup[1]
if(up) // bull
mshadow1 := hi[1] - tutup[1]
mshadow2 := buka[1] - lo[1]
mheight := tutup[1] - buka[1]
mdiff = lo[1] != tutup[1] and lo[1] != buka[1] and hi[1] != buka[1] and hi[1] != tutup[1] and buka > hi[1]
MS = buka[2] > tutup[2] and lo[2] >= buka[1] and lo[2] >= tutup[1] and mheight < mshadow1 and mheight < mshadow2 and tutup > buka and buka > tutup[1] and mdiff
plotshape(MS, 'MS', style=shape.circle, location=location.belowbar, color=color.yellow, transp=0, text='MS', textcolor=color.yellow, size=size.tiny, offset = -1)
// ENGULFING ==========================================================================================================
buer = buka < tutup and tutup > buka[1] and buka < tutup[1]
buel = buka[1] > tutup[1] and buka[1] < tutup and tutup[1] > buka
hbuer = tutup - buka
hbuel = buka[1] - tutup[1]
BE = buer and buel and buka[2] > tutup[2] and hbuel/hbuer*100 > 50.00
plotshape(BE, 'BE', style=shape.circle, location=location.belowbar, color=color.yellow, transp=0, text='BE', textcolor=color.yellow, size=size.tiny)
ber = tutup < buka and tutup < buka[1] and buka > tutup[1]
bel = tutup[1] > buka[1] and tutup[1] < buka and buka[1] > tutup
hber = buka - tutup
hbel = tutup[1] - buka[1]
BE1 = bel and ber and tutup[2] > buka[2] and hi[2] < tutup[1] and hbel/hber*100 > 50.0 and lo[1] > tutup
plotshape(BE1, 'BE', style=shape.circle, location=location.abovebar, color=color.yellow, transp=0, text='BE', textcolor=color.yellow, size=size.tiny)
// Harami ================================================================================================================
bhr = tutup > buka and buka > tutup[1] and tutup < buka[1]
bhl = buka[1] > tutup[1] and buka[1] > hi and tutup[1] < buka
hbhr = tutup - buka
hbhl = buka[1] - tutup[1]
BH = bhr and bhl and lo[3] > lo[2] and hbhr/hbhl*100 > 50.00
plotshape(BH, 'BH', style=shape.circle, location=location.belowbar, color=color.yellow, transp=0, text='BH', textcolor=color.yellow, size=size.tiny)
// Piercing Line ==========================================================================================================
pheight = 0.00
if(buka[1] > tutup[1])
pheight := buka[1]-((buka[1] - tutup[1])/2)
PL = tutup > buka and tutup[1] < buka[1] and lo[1] > buka and tutup < buka[1] and tutup > tutup[1] and tutup > pheight and lo[2] > tutup[1] and tutup < buka[1]
plotshape(PL, 'PL', style=shape.circle, location=location.belowbar, color=color.orange, transp=0, text='PL', textcolor=color.orange, size=size.tiny)
// Dark Cloud Cover ==========================================================================================================
dpercent = 0.00
dhr = 0.00
dhl = 0.00
if(buka > tutup)
dhr := buka-((buka - tutup)/2)
if(tutup[1] > buka[1])
dhl := tutup[1] - ((tutup[1]-buka[1])/2)
DCC = buka > tutup and tutup[1] > buka[1] and tutup[1] >= dhr and tutup[1] < buka and buka[1] < tutup and tutup[2] > buka[2] and tutup < dhl and tutup[3] > buka[3]
plotshape(DCC, 'DCC', style=shape.circle, location=location.abovebar, color=color.orange, transp=0, text='DCC', textcolor=color.orange, size=size.tiny)
// Doji ===================================================================================================================
percent = 0.0
height = 0.0
shadow = 0.0
shadow2 = 0.0
if(tutup > buka)
height := tutup - buka
shadow := buka - lo
percent := ((shadow-height)/shadow)* 100
shadow2 := hi - tutup
if(buka > tutup)
height := buka - tutup
shadow := hi - buka
percent := ((shadow-height)/shadow)* 100
shadow2 := tutup - lo
dfh = tutup > buka and percent > 50 and shadow > shadow2 and height > shadow2
gs = buka > tutup and percent > 50 and shadow > shadow2 and height > shadow2
// plotshape(dfh, 'DF/H', style=shape.circle, location=location.belowbar, color=color.orange, text='DF/H', textcolor=color.orange, size=size.tiny)
// plotshape(gs, 'GS', style=shape.circle, location=location.abovebar, color=color.orange, text='GS', textcolor=color.orange, size=size.tiny)
// MA ======================================================================================================================
sma1 = sma(close,20)
sma2 = sma(close,50)
buy = crossover(sma1, sma2)
sell = crossover(sma2, sma1)
plotshape(buy, 'BULL', style=shape.triangleup, location=location.belowbar, color=color.green, text='BMA', textcolor=color.green)
plotshape(sell, 'SELL', style=shape.triangledown, location=location.abovebar, color=color.red, text='SMA', textcolor=color.red)
// SRSI =====================================================================================================================
K = input(3, minval=1)
D = input(3, minval=1)
RSI = input(14, minval=1)
Stoch = input(14, minval=1)
rsi = rsi(tutup, RSI)
k = sma(stoch(rsi, rsi, rsi, Stoch), K)
d = sma(k, D)
bull = crossover(k,d) and d <= 20
bear = crossover(d,k) and d >= 80
plotshape(bull, 'BULL', style=shape.triangleup, location=location.belowbar, color=color.green, text='B', textcolor=color.white)
plotshape(bear, 'SELL', style=shape.triangledown, location=location.abovebar, color=color.red, text='S', textcolor=color.white)
TOP = crossunder(d,80)
BOT = crossover(d,20)
plotshape(TOP, 'TOP', style=shape.triangledown, location=location.abovebar, color=color.red)
plotshape(BOT, 'BOT', style=shape.triangleup, location=location.belowbar, color=color.green)
TOPM = crossover(k,d) and k > 20 and k < 80 and d > 20 and d < 80
BOTM = crossunder(k,d) and k > 20 and k < 80 and d > 20 and d < 80
plotshape(TOPM, 'TOPM', style=shape.triangleup, location=location.belowbar, color=color.green)
plotshape(BOTM, 'BOTM', style=shape.triangledown, location=location.abovebar, color=color.red)
// GO =====================================================================================================================
if buy and backtest
strategy.entry("long", strategy.long, 100, when = timeRange)
if sell and backtest
strategy.close("long", when = timeRange)
if bull and backtest
strategy.entry("long", strategy.long, 100, when = timeRange)
if bear and backtest
strategy.close("long", when = timeRange)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment