Premium 2
Premium 2
subtitle = 'Papertrade'
symInfoCheck = false
symInfo = syminfo.ticker + ' | ' + timeframe.period + (timeframe.isminutes ? 'M' :
na)
date = str.tostring(dayofmonth(time_close)) + '/' + str.tostring(month(time_close))
+ '/' + str.tostring(year(time_close))
//text positioning
textVPosition = 'middle'
textHPosition = 'center'
//symbol info positioning
symVPosition = 'top'
symHPosition = 'left'
//cell size
width = 0
height = 0
//title settings
c_title = color.new(color.orange, 50)
s_title = 'large'
a_title = 'center'
//subtitle settings
c_subtitle = color.new(color.orange, 50)
s_subtitle = 'normal'
a_subtitle = 'center'
//symbol settings
c_symInfo = color.new(color.black, 50)
s_symInfo = 'normal'
a_symInfo = 'center'
c_bg = color.new(color.blue, 100)
keyValue = input(3, title="Key Value. 'This changes the sensitivity'")
atrPeriod = input(14, title="value signals Period")
useHeikinAshi = input(true, title="activate Signals 90%")
plotSignals = input(true, title="Show Buy/Sell Signals")
//INPUT
src = input(close, title='Source')
modeSwitch = input.string('Hma', title='Hull Variation', options=['Hma', 'Thma',
'Ehma'])
length = input(55, title='Length(180-200 for floating S/R , 55 for swing entry)')
lengthMult= input(1.0, title='Length multiplier (Used to view higher timeframes
with straight band)')
useHtf = input(true, title='Show Hull MA from X timeframe? (good for scalping)')
htf = input.timeframe('1D', title='Higher timeframe')
switchColor = input(true, 'Color Hull according to trend?')
candleCol = input(false, title='Color candles based on Hull\'s Trend?')
visualSwitch = input(true, title='Show as a Band?')
thicknesSwitch = input(1, title='Line Thickness')
transpSwitch = input.int(40, title='Band Transparency', step=5)
//FUNCTIONS
//HMA
HMA(_src, _length) =>
ta.wma(2 * ta.wma(_src, _length / 2) - ta.wma(_src, _length),
math.round(math.sqrt(_length)))
//EHMA
EHMA(_src, _length) =>
ta.ema(2 * ta.ema(_src, _length / 2) - ta.ema(_src, _length),
math.round(math.sqrt(_length)))
//THMA
THMA(_src, _length) =>
ta.wma(ta.wma(_src, _length / 3) * 3 - ta.wma(_src, _length / 2) - ta.wma(_src,
_length), _length)
//SWITCH
Mode(modeSwitch, src, len) =>
modeSwitch == 'Hma' ? HMA(src, len) : modeSwitch == 'Ehma' ? EHMA(src, len) :
modeSwitch == 'Thma' ? THMA(src, len / 2) : na
//OUT
_hull = Mode(modeSwitch, src, int(length * lengthMult))
HULL = useHtf ? request.security(syminfo.ticker, htf, _hull) : _hull
MHULL = HULL[0]
SHULL = HULL[2]
//COLOR
hullColor = switchColor ? HULL > HULL[2] ? #00ff00 : #ff0000 : #ff9800
//PLOT
///< Frame
Fi1 = plot(MHULL, title='MHULL', color=hullColor, linewidth=thicknesSwitch,
transp=50)
Fi2 = plot(visualSwitch ? SHULL : na, title='SHULL', color=hullColor,
linewidth=thicknesSwitch, transp=50)
alertcondition(ta.crossover(MHULL, SHULL), title='Hull trending up.', message='Hull
trending up.')
alertcondition(ta.crossover(SHULL, MHULL), title='Hull trending down.',
message='Hull trending down.')
///< Ending Filler
fill(Fi1, Fi2, title='Band Filler', color=hullColor, transp=transpSwitch)
///BARCOLOR
barcolor(color=candleCol ? switchColor ? hullColor : na : na)
// SuperTrend MTF
supertrend30 = request.security(syminfo.tickerid, "30", supertrend)
direction30 = request.security(syminfo.tickerid, "30", direction)
supertrend60 = request.security(syminfo.tickerid, "60", supertrend)
direction60 = request.security(syminfo.tickerid, "60", direction)
supertrend120 = request.security(syminfo.tickerid, "120", supertrend)
direction120 = request.security(syminfo.tickerid, "120", direction)
supertrend240 = request.security(syminfo.tickerid, "240", supertrend)
direction240 = request.security(syminfo.tickerid, "240", direction)
supertrendD = request.security(syminfo.tickerid, "D", supertrend)
directionD = request.security(syminfo.tickerid, "D", direction)
// Zone to entry
//Strategy
// EMA calculation
emaValue = ta.ema(source, 1)
// Bar color
barColorBuy = source > trailingStop
barColorSell = source < trailingStop
barcolor(buyCondition ? color.green : sellCondition ? color.red : na)
// Strategy
if (buyCondition)
strategy.entry("Long", strategy.long)
if (sellCondition)
strategy.entry("Short", strategy.short)
// Track trades
totalTrades := totalTrades + 1
if (strategy.position_size > 0)
profitableTrades := profitableTrades + 1
// Calculate accuracy
accuracy = totalTrades > 0 ? (profitableTrades / totalTrades) * 100 : 0
// Alert Messages
if (buyCondition)
alert("?? #\nOpen Long | Current price: " + str.tostring(close) + "\nStrategy
type: DCA + SL\n\n? WEEKLY STATS (8 weeks): ?\n????????????????\n\n? ?? OPEN
HERE: ?\nEntry 1: " + str.tostring(buyEntryZone) + " or lower (deposit 2%)\nEntry
2: " + str.tostring(buyEntryZone * 1.3) + " (deposit 2%)\n\n? ?? CLOSE HERE: ?\
nScalp targets:\nTarget 1: " + str.tostring(close * 1.2) + " (Accuracy: " +
str.tostring(accuracy) + " | All-time PNL: " + str.tostring(profitableTrades) + ")\
nTarget 2: " + str.tostring(close * 1.2143) + " (Accuracy: " +
str.tostring(accuracy) + " | All-time PNL: " + str.tostring(profitableTrades) + ")\
nTarget 3: " + str.tostring(close * 1.2287) + " (Accuracy: " +
str.tostring(accuracy) + " | All-time PNL: " + str.tostring(profitableTrades) + ")\
nTarget 4: " + str.tostring(close * 1.2431) + " (Accuracy: " +
str.tostring(accuracy) + " | All-time PNL: " + str.tostring(profitableTrades) + ")\
n\nPrimary target: " + str.tostring(close * 1.3293) + " (Accuracy: " +
str.tostring(accuracy) + " | All-time PNL: " + str.tostring(profitableTrades) + ")\
nOr reverse signal ??\n\n??????? Stop-loss: " + str.tostring(buyEntryZone * 0.985)
+ "\n?? Leverage: 20x cross\nStrategy type: DCA + SL")
if (sellCondition)
alert("?? #\nOpen Short | Current price: " + str.tostring(close) + "\nStrategy
type: DCA + SL\n\n? WEEKLY STATS (8 weeks): ?\n????????????????\n\n? ?? OPEN
HERE: ?\nEntry 1: " + str.tostring(sellEntryZone) + " or higher (deposit 2%)\nEntry
2: " + str.tostring(sellEntryZone * 0.7) + " (deposit 2%)\n\n? ?? CLOSE HERE: ?\
nScalp targets:\nTarget 1: " + str.tostring(close * 0.8) + " (Accuracy: " +
str.tostring(accuracy) + " | All-time PNL: " + str.tostring(profitableTrades) + ")\
nTarget 2: " + str.tostring(close * 0.9) + " (Accuracy: " + str.tostring(accuracy)
+ " | All-time PNL: " + str.tostring(profitableTrades) + ")\nTarget 3: " +
str.tostring(close * 0.95) + " (Accuracy: " + str.tostring(accuracy) + " | All-time
PNL: " + str.tostring(profitableTrades) + ")\nTarget 4: " + str.tostring(close *
0.98) + " (Accuracy: " + str.tostring(accuracy) + " | All-time PNL: " +
str.tostring(profitableTrades) + ")\n\nPrimary target: " + str.tostring(close *
1.07) + " (Accuracy: " + str.tostring(accuracy) + " | All-time PNL: " +
str.tostring(profitableTrades) + ")\nOr reverse signal ??\n\n??????? Stop-loss: " +
str.tostring(sellEntryZone * 1.015) + "\n?? Leverage: 20x cross\nStrategy type: DCA
+ SL")
////////////////////////////////////////////////////////////////////////////////
SETUP EXIT
atr = ta.atr(SL_atrLength)
float stoploss_long_atr_lv = na
stoploss_long_atr_lv := strategy.position_size[1] <= 0 and
(strategy.position_size > 0) ? close - atr * SL_atrMultiplier :
stoploss_long_atr_lv[1]
float stoploss_short_atr_lv = na
stoploss_short_atr_lv := strategy.position_size[1] >= 0 and
(strategy.position_size < 0) ? close + atr * SL_atrMultiplier :
stoploss_short_atr_lv[1]
trailing_sl_long = 0.0
trailing_sl_long := strategy.position_size > 0 ? math.max(low - sl_val,
nz(trailing_sl_long[1])) : na
trailing_sl_short = 0.0
trailing_sl_short := strategy.position_size < 0 and strategy.position_size[1] >=
0 ? high + sl_val :
strategy.position_size < 0 and strategy.position_size[1] < 0 ?
math.min(high + sl_val, nz(trailing_sl_short[1])) : na
// Logic SL TP ----------------------------------------
//
bool status_long_hit_tp1 = na
status_long_hit_tp1 := (strategy.position_size[1] > 0 and strategy.position_size >
0 and strategy.position_size[1] > strategy.position_size) ? true :
strategy.position_size <= 0 ? false : status_long_hit_tp1[1]
bool status_short_hit_tp1 = na
status_short_hit_tp1 := (strategy.position_size[1] < 0 and strategy.position_size <
0 and strategy.position_size[1] < strategy.position_size) ? true :
strategy.position_size >= 0 ? false : status_short_hit_tp1[1]
float STLLong = na
float STLShort = na
//
STLLong := (status_long_hit_tp1 == true and movestoploss == true)
? strategy.position_avg_price : SL_ATR == true ?
stoploss_long_atr_lv : strategy.position_avg_price -
percentTPSL(SL)*syminfo.mintick
// SETUP Auto TP
//TP1
float TP1Long = na
string TP1Longlabel = na
float TP1Short = na
string TP1Shortlabel = na
if TP1AI == true and (supertrend120) < long_tp1_lv + long_tp1_lv*0.01 and
(supertrend120) > long_tp1_lv - long_tp1_lv*0.01
TP1Long :=
((down2h-strategy.position_avg_price)/strategy.position_avg_price)*100
TP1Longlabel := "AutoTP1"
else if TP1AI == true and (supertrend240) < long_tp1_lv + long_tp1_lv*0.01 and
(supertrend240) > long_tp1_lv - long_tp1_lv*0.01
TP1Long :=
((down4h-strategy.position_avg_price)/strategy.position_avg_price)*100
TP1Longlabel := "AutoTP1"
else
TP1Long := TP1
TP1Longlabel := "TP1"
//TP2
float TP2Long = na
string TP2Longlabel = na
float TP2Short = na
string TP2Shortlabel = na
//
float TP3Long = na
string TP3Longlabel = na
if TP3AI == true and (supertrend120) < long_tp3_lv + long_tp3_lv*0.01 and
(supertrend120) > long_tp3_lv - long_tp3_lv*0.01
TP3Long :=
((down2h-strategy.position_avg_price)/strategy.position_avg_price)*100
TP3Longlabel := "AutoTP3"
else if TP3AI == true and (supertrend240) < long_tp3_lv + long_tp3_lv*0.01 and
(supertrend240) > long_tp3_lv - long_tp3_lv*0.01
TP3Long :=
((down4h-strategy.position_avg_price)/strategy.position_avg_price)*100
TP3Longlabel := "AutoTP3"
else if TP3AI == true and (supertrendD) < long_tp3_lv + long_tp3_lv*0.01 and
(supertrendD) > long_tp3_lv - long_tp3_lv*0.01
TP3Long :=
((down1d-strategy.position_avg_price)/strategy.position_avg_price)*100
TP3Longlabel := "AutoTP3"
else
TP3Long := TP3
TP3Longlabel := "TP3"
//
float TP5Long = na
string TP5Longlabel = na
if TP5AI == true and (supertrend120) < long_tp5_lv + long_tp5_lv*0.01 and
(supertrend120) > long_tp5_lv - long_tp5_lv*0.01
TP5Long :=
((down2h-strategy.position_avg_price)/strategy.position_avg_price)*100
TP5Longlabel := "AutoTP5"
else if TP5AI == true and (supertrend240) < long_tp5_lv + long_tp5_lv*0.01 and
(supertrend240) > long_tp5_lv - long_tp5_lv*0.01
TP5Long :=
((down4h-strategy.position_avg_price)/strategy.position_avg_price)*100
TP5Longlabel := "AutoTP5"
else if TP5AI == true and (supertrendD) < long_tp5_lv + long_tp5_lv*0.01 and
(supertrendD) > long_tp5_lv - long_tp5_lv*0.01
TP5Long :=
((down1d-strategy.position_avg_price)/strategy.position_avg_price)*100
TP5Longlabel := "AutoTP5"
////////////////////////////////////////////////////////////////////////////////
SETUP EXIT
if multiprofit == true
strategy.exit("TP1", "Long", qty_percent = qty1, profit =
percentTPSL(TP1Long), comment = "Tp1??")
strategy.exit("TP2", "Long", qty_percent = qty2, profit =
percentTPSL(TP2Long), comment = "Tp2??")
strategy.exit("TP3", "Long", qty_percent = qty3, profit =
percentTPSL(TP3Long), comment = "Tp3??")
strategy.exit("TP4", "Long", qty_percent = qty4, profit = percentTPSL(TP4),
comment = "Tp4??")
strategy.close_all(when = strategy.position_size > 0 and low < long_sl_lv,
comment = "CLOSED")
strategy.exit("TP1", "Short", qty_percent = qty1, profit =
percentTPSL(TP1Short), comment = "Tp1??")
strategy.exit("TP2", "Short", qty_percent = qty2, profit =
percentTPSL(TP2Short), comment = "Tp2??")
strategy.exit("TP3", "Short", qty_percent = qty3, profit = percentTPSL(TP3),
comment = "Tp3??")
strategy.exit("TP4", "Short", qty_percent = qty4, profit = percentTPSL(TP4),
comment = "Tp4??")
strategy.close_all(when = strategy.position_size < 0 and high > short_sl_lv,
comment = "CLOSED")
////////////////////////////////////////////////////////////////////////////////
Plot TP & SL
//Label TP/SL
_x = timenow + math.round(ta.change(time) * 2)
// Table Results
tableBgcolor=#686868
if barstate.islastconfirmedhistory == true
var tbl = table.new(position.bottom_right, 3, 3, bgcolor = tableBgcolor,
frame_width = 2, frame_color = color.black,
border_width=2,border_color=color.black)
table.cell(tbl, 0, 1, "Total trades: " + str.tostring(strategy.closedtrades),
bgcolor=color.gray,text_size=size.small,text_color=color.white,text_valign=text.ali
gn_center)
table.cell(tbl, 0, 2, "Win Rate: " +
str.tostring(math.round(strategy.wintrades / strategy.closedtrades * 100,2)) + "%",
bgcolor=color.gray,text_size=size.small,text_color=color.white,text_valign=text.ali
gn_center)
table.cell(tbl, 0, 0, "Initial capital: " +
str.tostring(strategy.initial_capital),
bgcolor=color.gray,text_size=size.small,text_color=color.white,text_valign=text.ali
gn_center)
table.cell(tbl, 1, 0, "Net profit: " +
str.tostring(math.round(strategy.netprofit,2)) + " ("+
str.tostring(math.round(strategy.netprofit / strategy.initial_capital * 100,2)) +
"%"+ ")", bgcolor=strategy.netprofit>0?
color.teal:color.maroon,text_size=size.small,text_color=color.white,text_valign=tex
t.align_center)
table.cell(tbl, 1, 1, "Current net worth: "+
str.tostring(math.round(strategy.equity,2))+ "", bgcolor=strategy.netprofit>0?
color.teal:color.red,text_size=size.small,text_color=color.white,text_valign=text.a
lign_center)
table.cell(tbl, 1, 2, "Maximum DrawDown: "+
str.tostring(math.round(strategy.max_drawdown))+ " ("+
str.tostring(math.round(strategy.max_drawdown/ strategy.initial_capital * 100,2))+
"%"+ ")",
bgcolor=color.maroon,text_size=size.small,text_color=color.white,text_valign=text.a
lign_center)