0% found this document useful (0 votes)
2 views

?Signals @fian_trader

Uploaded by

dkrajkumar90
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)
2 views

?Signals @fian_trader

Uploaded by

dkrajkumar90
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/ 28

// © EnigmaWay

// =================================
// PLEASE SUPPORT THE TEAM
// =================================
//
// If this project has been helpful, consider making a donation:
// Biance UID: 263856481
// Telegram: https://t.me/enigmawaytrading
// =================================

//@version=5
strategy('📡Signals @fian_trader', overlay=true, default_qty_type=strategy.cash,
default_qty_value=10000, initial_capital=10000, currency='USD',
commission_type=strategy.commission.percent, commission_value=0.03,
max_bars_back=3000, max_lines_count=100, calc_on_every_tick=false,
max_labels_count=100)

var initialcapital = strategy.equity

//Truncate Function
truncate(number, decimals) =>
factor = math.pow(10, decimals)
int(number * factor) / factor

//
===================================================================================
====
// Trade Time
daysback = input(14, title='Backtest Days, For Defining Best TF, Max: 20 Days')
millisecondinxdays = 1000 * 60 * 60 * 24 * daysback
leftbar = timenow - time < millisecondinxdays
backtest = leftbar
dpa = 4
//
===================================================================================
====
et1 = 'Supertrend'
longside = input.bool(true, title='Long Side', group='Strategy Option')
shortside = input.bool(true, title='Short Side', group='Strategy Option')
filter1 = 'Filter with Atr'
filter2 = 'Filter with RSI'
filter3 = 'Atr or RSI'
filter4 = 'Atr and RSI'
filter5 = 'No Filtering'
filter6 = 'Entry Only in sideways market(By ATR or RSI)'
filter7 = 'Entry Only in sideways market(By ATR and RSI)'
typefilter = input.string(filter5, title='Sideways Filtering Input',
options=[filter1, filter2, filter3, filter4, filter5, filter6, filter7],
group='Strategy Options')
withsl = input.bool(false, title='Use Dynamic SL?', group='Strategy Options')

RSI = truncate(ta.rsi(close, input.int(7, group='RSI Filterring')), 2)


toplimitrsi = input.int(45, title='TOP Limit', group='RSI Filterring')
botlimitrsi = input.int(10, title='BOT Limit', group='RSI Filterring')

// TP SL Option
ex1 = 'TP & SL by Percentage Price'
ex2 = 'TP & SL by atr Value'
et = input.string(ex2, title='TP SL Type', options=[ex1, ex2], group='Strategy
Options')

ST = input.bool(true, title='Show Supertrend?', group='Supertrend Indicator')


period = input.int(15, group='Supertrend Indicator')
mult = input.int(5, group='Supertrend Indicator')
atrLen = input.int(5, minval=1, title='atr Length', group='Sideways Filtering
Input')
atrMaType = input.string('EMA', options=['SMA', 'EMA'], group='Sideways Filtering
Input', title='atr Moving Average Type')
atrMaLen = input.int(5, minval=1, title='atr MA Length', group='Sideways Filtering
Input')
//adxLen = input(5, minval = 1, maxval = 50, title = "ADX SMOOTHing",
group='Sideways Filtering Input')
//diLen = input(14, minval = 1, title = "DI Length", group='Sideways Filtering
Input')
//adxLim = input(22, minval = 1, title = "ADX Limit", group='Sideways Filtering
Input')
//SMOOTH = input(3, minval = 1, maxval = 5, title = "SMOOTHing Factor",
group='Sideways Filtering Input')
//lag = input(8, minval = 0, maxval = 15, title = "Lag", group='Sideways Filtering
Input')

TP1 = input.float(1.5, title='TP1 Atr Multiplier', group='TP/SL by ATR')


TP2 = input.int(3, title='TP2 Atr Multiplier', group='TP/SL by ATR')
TP3 = input.int(5, title='TP3 Atr Multiplier', group='TP/SL by ATR')
TP4 = input.float(title='TP 4', minval=0.0, step=0.1, defval=9, group='TP/SL by
ATR')
SL = input.int(6, title='SL Atr Multiplier', group='TP/SL by ATR')
ptp1 = input.float(2, title='Take Profit 1 (%)', minval=0.0, step=0.1, defval=3,
group='TP/SL Percentage Price') * 0.01
ptp2 = input.float(4, title='Take Profit 2 (%)', minval=0.0, step=0.1, defval=5,
group='TP/SL Percentage Price') * 0.01
ptp3 = input.float(6, title='Take Profit 3 (%)', minval=0.0, step=0.1, defval=7,
group='TP/SL Percentage Price') * 0.01
ptp4 = input.float(12, title='Take Profit 4 (%)', minval=0.0, step=0.1, defval=8,
group='TP/SL Percentage Price') * 0.01
psl = input.float(3, title='StopLoss (%)', minval=0.0, step=0.1, defval=2) * 0.01

qtytp1 = input.int(30, title='QTY TP 1', group='Qty for TP')


qtytp2 = input.int(30, title='QTY TP 2', group='Qty for TP')
qtytp3 = input.int(30, title='QTY TP 3', group='Qty for TP')
qtytp4 = input.int(10, title='QTY TP 4', group='Qty for TP')
Qtytp1 = qtytp1 / 100
Qtytp2 = qtytp2 / 100
Qtytp3 = qtytp3 / 100
Qtytp4 = qtytp4 / 100
///

//===================================================================
//===================================================================
//Timeframe
//Supertrend Indicator

src = hl2
atr2 = ta.sma(ta.tr, period)
atr = request.security(syminfo.ticker, '', ta.atr(period))
up = src - mult * atr
up1 = nz(up[1], up)
up := close[1] > up1 ? math.max(up, up1) : up
dn = src + mult * atr
dn1 = nz(dn[1], dn)
dn := close[1] < dn1 ? math.min(dn, dn1) : dn
trend = 1
trend := nz(trend[1], trend)
trend := trend == -1 and close > dn1 ? 1 : trend == 1 and close < up1 ? -1 : trend
st = trend == 1 ? up : dn

//filtering
atra = request.security(syminfo.tickerid, '', ta.atr(atrLen))
atrMa = atrMaType == 'EM' ? ta.ema(atra, atrMaLen) : ta.sma(atra, atrMaLen)
updm = ta.change(high)
downdm = -ta.change(low)
plusdm = na(updm) ? na : updm > downdm and updm > 0 ? updm : 0
minusdm = na(downdm) ? na : downdm > updm and downdm > 0 ? downdm : 0
//trur = rma(tr, diLen)
//plus = fixnan(100 * rma(plusdm, diLen) / trur)
//minus = fixnan(100 * rma(minusdm, diLen) / trur)
//sum = plus + minus
//adx = 100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), adxLen)

cndSidwayss1 = atra >= atrMa


cndSidwayss2 = RSI > toplimitrsi or RSI < botlimitrsi
cndSidways = cndSidwayss1 or cndSidwayss2
cndSidways1 = cndSidwayss1 and cndSidwayss2
Sidwayss1 = atra <= atrMa
Sidwayss2 = RSI < toplimitrsi and RSI > botlimitrsi
Sidways = Sidwayss1 or Sidwayss2
Sidways1 = Sidwayss1 and Sidwayss2

trendType = typefilter == filter1 ? cndSidwayss1 : typefilter == filter2 ?


cndSidwayss2 : typefilter == filter3 ? cndSidways : typefilter == filter4 ?
cndSidways1 : typefilter == filter5 ? RSI > 0 : typefilter == filter6 ? Sidways :
typefilter == filter7 ? Sidways1 : na

// Entry FIX
buysignal1 = ta.crossover(close, st)
sellsignal1 = ta.crossunder(close, st)

buy = buysignal1 and longside


sell = sellsignal1 and shortside

//Tp & Sl by atr Mult


cb = ta.valuewhen(buy, close, 0)
ratr = ta.valuewhen(buy, ta.atr(14), 0)

tpb1 = cb + ratr * TP1


tpb2 = cb + ratr * TP2
tpb3 = cb + ratr * TP3
tpb4 = cb + ratr * TP4
slb = cb - ratr * SL //withsl?up:valuewhen(buy, up,0)

cs = ta.valuewhen(sell, close, 0)
ratrs = ta.valuewhen(sell, ta.atr(14), 0)
tps1 = cs - ratrs * TP1
tps2 = cs - ratrs * TP2
tps3 = cs - ratrs * TP3
tps4 = cs - ratrs * TP4
sls = cs + ratrs * SL //withsl?dn:valuewhen(sell, dn, 0)

Ptpb1 = cb * (1 + ptp1)
Ptpb2 = cb * (1 + ptp2)
Ptpb3 = cb * (1 + ptp3)
Ptpb4 = et == ex1 ? cb * (1 + ptp4) : tpb4
Pslb = cb * (1 - psl)

Ptps1 = cs * (1 - ptp1)
Ptps2 = cs * (1 - ptp2)
Ptps3 = cs * (1 - ptp3)
Ptps4 = et == ex1 ? cs * (1 - ptp4) : tps4
Psls = cs * (1 + psl)

//Variable Fix TP SL
tpb1t = et == ex1 ? Ptpb1 : tpb1
tpb2t = et == ex1 ? Ptpb2 : tpb2
tpb3t = et == ex1 ? Ptpb3 : tpb3
tpb4t = Ptpb4
slbt = et == ex1 ? Pslb : slb
tps1t = et == ex1 ? Ptps1 : tps1
tps2t = et == ex1 ? Ptps2 : tps2
tps3t = et == ex1 ? Ptps3 : tps3
tps4t = Ptps4
slst = et == ex1 ? Psls : sls

//===================================================================
//Input Zignaly Settings
z1 = 'Copy trading / Profit Sharing'
z2 = 'Signal Providing'
z3 = 'Telegram Notification'
ZZ = input.string(z3, title='BOT Type', options=[z1, z2, z3], group='Zignaly
Settings')

P1 = 'Pair 1'
P2 = 'Pair 2'
P3 = 'Pair 3'
pair = input.string(defval=P1, title='Pair Trade', options=[P1, P2, P3],
group='Zignaly Settings')
apikey = input.string('xxx', title='Api Key', group='Zignaly Settings')
margin = input.int(10, title='Margin % (Use it Only if you use copytrading or
profit sharing)', group='Zignaly Settings')
lev = input.int(30, group='Zignaly Settings')
qty = margin / close

slbm = et == ex1 ? Psls : slb


slsm = et == ex1 ? Psls : sls
slbmessage = '","stopLossPriority":"price","stopLossPrice":"' + str.tostring(slbm)
slsmessage = '","stopLossPriority":"price","stopLossPrice":"' + str.tostring(slsm)

// Zignaly Settings
pair1 = input.string('btcusdt', group='Pair & Signalid, Gunakan Huruf Kecil')
signal1 = input.string('btc', group='Pair & Signalid, Gunakan Huruf Kecil')
pair2 = input.string('ethusdt', group='Pair & Signalid, Gunakan Huruf Kecil')
signal2 = input.string('eth', group='Pair & Signalid, Gunakan Huruf Kecil')
pair3 = input.string('xxxusdt', group='Pair & Signalid, Gunakan Huruf Kecil')
signal3 = input.string('xxx', group='Pair & Signalid, Gunakan Huruf Kecil')

PAIR = pair == P1 ? pair1 : pair == P2 ? pair2 : pair3


signal = pair == P1 ? signal1 : pair == P2 ? signal2 : signal3

//alert command, copytrader/profitsharing


longct = '{"key":"' + str.tostring(apikey) +
'","type":"reverse","exchange":"binance","exchangeAccountType":"futures","pair":"'
+ str.tostring(PAIR) +
'","exitOrderType":"market","entryOrderType":"market","exitSide":"short","entrySide
":"long","entryLeverage":"' + str.tostring(lev) + str.tostring(slbmessage) +
'","takeProfitPriority":"price","takeProfitAmountPercentage1":"' +
str.tostring(qtytp1) + '","takeProfitPrice1":"' + str.tostring(tpb1t) +
'","takeProfitAmountPercentage2":"' + str.tostring(qtytp2) +
'","takeProfitPrice2":"' + str.tostring(tpb2t) +
'","takeProfitAmountPercentage3":"' + str.tostring(qtytp3) +
'","takeProfitPrice3":"' + str.tostring(tpb3t) +
'","takeProfitAmountPercentage4":"' + str.tostring(qtytp4) +
'","takeProfitPrice4":"' + str.tostring(tpb4t) + '","positionSizePercentage":"' +
str.tostring(margin) + '","signalId":"' + str.tostring(signal) + '"}'
shortct = '{"key":"' + str.tostring(apikey) +
'","type":"reverse","exchange":"binance","exchangeAccountType":"futures","pair":"'
+ str.tostring(PAIR) +
'","exitOrderType":"market","entryOrderType":"market","exitSide":"long","entrySide"
:"short","entryLeverage":"' + str.tostring(lev) + str.tostring(slsmessage) +
'","takeProfitPriority":"price","takeProfitAmountPercentage1":"' +
str.tostring(qtytp1) + '","takeProfitPrice1":"' + str.tostring(tps1t) +
'","takeProfitAmountPercentage2":"' + str.tostring(qtytp2) +
'","takeProfitPrice2":"' + str.tostring(tps2t) +
'","takeProfitAmountPercentage3":"' + str.tostring(qtytp3) +
'","takeProfitPrice3":"' + str.tostring(tps3t) +
'","takeProfitAmountPercentage4":"' + str.tostring(qtytp4) +
'","takeProfitPrice4":"' + str.tostring(tps4t) + '","positionSizePercentage":"' +
str.tostring(margin) + '","signalId":"' + str.tostring(signal) + '"}'
slcommand = '{"key":"' + str.tostring(apikey) + '","pair":"' + str.tostring(PAIR) +
'","exchange":"binance","exchangeAccountType":"futures","type":"exit","signalId":"'
+ str.tostring(signal) + '"}'
//signal provider
tpb1tsp = et == ex1 ? ptp1 * 100 : truncate((tpb1 - cb) * 100 / cb, 2)
tpb2tsp = et == ex1 ? ptp2 * 100 : truncate((tpb2 - cb) * 100 / cb, 2)
tpb3tsp = et == ex1 ? ptp3 * 100 : truncate((tpb3 - cb) * 100 / cb, 2)
tpb4tsp = ptp4 * 100
slbtsp = truncate((cb - slb) * 100 / cb, 2)

tps1tsp = et == ex1 ? ptp1 * 100 : truncate((cs - tps1) * 100 / cs, 2)


tps2tsp = et == ex1 ? ptp2 * 100 : truncate((cs - tps2) * 100 / cs, 2)
tps3tsp = et == ex1 ? ptp3 * 100 : truncate((cs - tps3) * 100 / cs, 2)
tps4tsp = ptp4 * 100
slstsp = truncate((sls - cs) * 100 / cs, 2)

slbmsp = et == ex1 ? psl * 100 : slbtsp


slsmsp = et == ex1 ? psl * 100 : slstsp
slbmessagesp = '","stopLossPercentage":"-' + str.tostring(slbmsp)
slsmessagesp = '","stopLossPercentage":"-' + str.tostring(slsmsp)

longsp = '{"key":"' + str.tostring(apikey) +


'","type":"reverse","exchange":"binance","exchangeAccountType":"futures","pair":"'
+ str.tostring(PAIR) +
'","exitOrderType":"market","entryOrderType":"limit","exitSide":"short","entrySide"
:"long","entryLimitPrice":"' + str.tostring(cb) + '","entryLeverage":"\n' +
str.tostring(lev) + str.tostring(slbmessagesp) +
'","takeProfitAmountPercentage1":"' + str.tostring(qtytp1) +
'","takeProfitPercentage1":"' + str.tostring(tpb1tsp) +
'","takeProfitAmountPercentage2":"' + str.tostring(qtytp2) +
'","takeProfitPercentage2":"' + str.tostring(tpb2tsp) +
'","takeProfitAmountPercentage3":"' + str.tostring(qtytp3) +
'","takeProfitPercentage3":"' + str.tostring(tpb3tsp) +
'","takeProfitAmountPercentage4":"' + str.tostring(qtytp4) +
'","takeProfitPercentage4":"' + str.tostring(tpb4tsp) +
'","positionSizePercentage":"' + str.tostring(margin) + '","signalId":"' +
str.tostring(signal) + '"}'
shortsp = '{"key":"' + str.tostring(apikey) +
'","type":"reverse","exchange":"binance","exchangeAccountType":"futures","pair":"'
+ str.tostring(PAIR) +
'","exitOrderType":"market","entryOrderType":"limit","exitSide":"long","entrySide":
"short","entryLimitPrice":"' + str.tostring(cs) + '","entryLeverage":"\n' +
str.tostring(lev) + str.tostring(slsmessagesp) +
'","takeProfitAmountPercentage1":"' + str.tostring(qtytp1) +
'","takeProfitPercentage1":"' + str.tostring(tps1tsp) +
'","takeProfitAmountPercentage2":"' + str.tostring(qtytp2) +
'","takeProfitPercentage2":"' + str.tostring(tps2tsp) +
'","takeProfitAmountPercentage3":"' + str.tostring(qtytp3) +
'","takeProfitPercentage3":"' + str.tostring(tps3tsp) +
'","takeProfitAmountPercentage4":"' + str.tostring(qtytp4) +
'","takeProfitPercentage4":"' + str.tostring(tps4tsp) +
'","positionSizePercentage":"' + str.tostring(margin) + '","signalId":"' +
str.tostring(signal) + '"}'

//===================================================================
//MTF Analysis
//===================================================================
//===================================================================

//Source MTF
tf1 = input.timeframe('15', group='MTF Analysis')
tf2 = input.timeframe('30', group='MTF Analysis')
tf3 = input.timeframe('45', group='MTF Analysis')
tf4 = input.timeframe('60', group='MTF Analysis')

hl2A = request.security(syminfo.tickerid, tf1, hl2)


hl2B = request.security(syminfo.tickerid, tf2, hl2)
hl2C = request.security(syminfo.tickerid, tf3, hl2)
hl2D = request.security(syminfo.tickerid, tf4, hl2)

trA = request.security(syminfo.tickerid, tf1, ta.tr)


trB = request.security(syminfo.tickerid, tf2, ta.tr)
trC = request.security(syminfo.tickerid, tf3, ta.tr)
trD = request.security(syminfo.tickerid, tf4, ta.tr)

highA = request.security(syminfo.tickerid, tf1, high)


highB = request.security(syminfo.tickerid, tf2, high)
highC = request.security(syminfo.tickerid, tf3, high)
highD = request.security(syminfo.tickerid, tf4, high)

lowA = request.security(syminfo.tickerid, tf1, low)


lowB = request.security(syminfo.tickerid, tf2, low)
lowC = request.security(syminfo.tickerid, tf3, low)
lowD = request.security(syminfo.tickerid, tf4, low)

closeA = request.security(syminfo.tickerid, tf1, close)


closeB = request.security(syminfo.tickerid, tf2, close)
closeC = request.security(syminfo.tickerid, tf3, close)
closeD = request.security(syminfo.tickerid, tf4, close)

//===================================================================
//===================================================================
//Timeframe A
//Supertrend Indicator

srcA = hl2A
atr2A = ta.sma(trA, period)
atrA = request.security(syminfo.tickerid, tf1, ta.atr(period))
upA = srcA - mult * atrA
up1A = nz(upA[1], upA)
upA := closeA[1] > up1A ? math.max(upA, up1A) : upA
dnA = srcA + mult * atrA
dn1A = nz(dnA[1], dnA)
dnA := closeA[1] < dn1A ? math.min(dnA, dn1A) : dnA
trendA = 1
trendA := nz(trendA[1], trendA)
trendA := trendA == -1 and closeA > dn1A ? 1 : trendA == 1 and closeA < up1A ? -1 :
trendA
stA = trendA == 1 ? upA : dnA

//filtering
atraA = request.security(syminfo.tickerid, tf1, ta.atr(atrLen))
atrMaA = atrMaType == 'EMA' ? ta.ema(atraA, atrMaLen) : ta.sma(atraA, atrMaLen)
updmA = ta.change(highA)
downdmA = -ta.change(lowA)
plusdmA = na(updmA) ? na : updmA > downdmA and updmA > 0 ? updmA : 0
minusdmA = na(downdmA) ? na : downdmA > updmA and downdmA > 0 ? downdmA : 0
//trurA = rma(trA, diLen)
//plusA = fixnan(100 * rma(plusdmA, diLen) / trurA)
//minusA = fixnan(100 * rma(minusdmA, diLen) / trurA)
//sumA = plusA + minusA
//adxA = 100 * rma(abs(plusA - minusA) / (sumA == 0 ? 1 : sumA), adxLen)

cndSidwayss1A = atraA >= atrMaA


cndSidwayss2A = RSI > toplimitrsi or RSI < botlimitrsi
cndSidwaysA = cndSidwayss1A or cndSidwayss2A
cndSidways1A = cndSidwayss1A and cndSidwayss2A
Sidwayss1A = atraA <= atrMaA
Sidwayss2A = RSI < toplimitrsi and RSI > botlimitrsi
SidwaysA = Sidwayss1A or Sidwayss2A
Sidways1A = Sidwayss1A and Sidwayss2A

trendTypeA = typefilter == filter1 ? cndSidwayss1A : typefilter == filter2 ?


cndSidwayss2A : typefilter == filter3 ? cndSidwaysA : typefilter == filter4 ?
cndSidways1A : typefilter == filter5 ? RSI > 0 : typefilter == filter6 ? SidwaysA :
typefilter == filter7 ? Sidways1A : na

// Entry FIX
buysignal1A = ta.crossover(closeA, stA) and backtest and trendTypeA
sellsignal1A = ta.crossunder(closeA, stA) and backtest and trendTypeA
buyA = buysignal1A and longside
sellA = sellsignal1A and shortside

//Tp & Sl by atr Mult


cbA = ta.valuewhen(buyA, closeA, 0)
ratrA = ta.valuewhen(buyA, request.security(syminfo.tickerid, tf1, ta.atr(14)), 0)

tpb1A = cbA + ratrA * TP1


tpb2A = cbA + ratrA * TP2
tpb3A = cbA + ratrA * TP3
tpb4A = cbA + ratrA * TP4
slbA = cbA - ratrA * SL //withsl?upA:valuewhen(buyA, upA,0)

csA = ta.valuewhen(sellA, closeA, 0)


ratrsA = ta.valuewhen(sellA, request.security(syminfo.tickerid, tf1, ta.atr(14)),
0)
tps1A = csA - ratrsA * TP1
tps2A = csA - ratrsA * TP2
tps3A = csA - ratrsA * TP3
tps4A = csA - ratrsA * TP4
slsA = csA + ratrsA * SL //withsl?dnA:valuewhen(sellA, dnA, 0)

Ptpb1A = cbA * (1 + ptp1)


Ptpb2A = cbA * (1 + ptp2)
Ptpb3A = cbA * (1 + ptp3)
Ptpb4A = et == ex1 ? cbA * (1 + ptp4) : tpb4A
PslbA = cbA * (1 - psl)

Ptps1A = csA * (1 - ptp1)


Ptps2A = csA * (1 - ptp2)
Ptps3A = csA * (1 - ptp3)
Ptps4A = et == ex1 ? csA * (1 - ptp4) : tps4A
PslsA = csA * (1 + psl)

//Variable Fix TP SL
tpb1tA = et == ex1 ? Ptpb1A : tpb1A
tpb2tA = et == ex1 ? Ptpb2A : tpb2A
tpb3tA = et == ex1 ? Ptpb3A : tpb3A
tpb4tA = Ptpb4A
slbtA = et == ex1 ? PslbA : slbA
tps1tA = et == ex1 ? Ptps1A : tps1A
tps2tA = et == ex1 ? Ptps2A : tps2A
tps3tA = et == ex1 ? Ptps3A : tps3A
tps4tA = Ptps4A
slstA = et == ex1 ? PslsA : slsA

sinceentrybA = int(math.max(1, nz(ta.barssince(buyA))))


openedbA = ta.barssince(buyA) >= 0 and trendA[1] == 1 and longside
highestbarbA = ta.highest(sinceentrybA)
lowestbarbA = ta.lowest(sinceentrybA)
stillopenb1A = ta.barssince(buyA) == 1 ? true : highestbarbA[1] < tpb1tA and
lowestbarbA[1] > slbtA
stillopenb2A = ta.barssince(buyA) == 1 ? true : highestbarbA[1] < tpb2tA and
lowestbarbA[1] > slbtA
stillopenb3A = ta.barssince(buyA) == 1 ? true : highestbarbA[1] < tpb3tA and
lowestbarbA[1] > slbtA
stillopenb4A = ta.barssince(buyA) == 1 ? true : highestbarbA[1] < tpb4tA and
lowestbarbA[1] > slbtA

hittpb1A = ta.cross(highA, tpb1tA) and stillopenb1A and openedbA


plotshape(hittpb1A)
hittpb2A = ta.cross(highA, tpb2tA) and stillopenb2A and openedbA
hittpb3A = ta.cross(highA, tpb3tA) and stillopenb3A and openedbA
hittpb4A = ta.cross(highA, tpb4tA) and stillopenb4A and openedbA
hitslbA = lowA < slbtA and stillopenb4A and openedbA
winreversebA = closeA > cbA and backtest and ta.crossunder(closeA, stA) and
stillopenb4A and trendA == -1 and openedbA
losereversebA = closeA < cbA and backtest and ta.crossunder(closeA, stA) and
stillopenb4A and trendA == -1 and openedbA

sinceentrysA = int(math.max(1, nz(ta.barssince(sellA))))


openedsA = ta.barssince(sellA) >= 0 and trendA[1] == -1 and shortside
highestbarsA = ta.highest(sinceentrysA)
lowestbarsA = ta.lowest(sinceentrysA)
stillopens1A = ta.barssince(sellA) == 1 ? true : highestbarsA[1] < slstA and
lowestbarsA[1] > tps1tA
stillopens2A = ta.barssince(sellA) == 1 ? true : highestbarsA[1] < slstA and
lowestbarsA[1] > tps2tA
stillopens3A = ta.barssince(sellA) == 1 ? true : highestbarsA[1] < slstA and
lowestbarsA[1] > tps3tA
stillopens4A = ta.barssince(sellA) == 1 ? true : highestbarsA[1] < slstA and
lowestbarsA[1] > tps4tA

hittps1A = ta.cross(lowA, tps1tA) and stillopens1A and openedsA


hittps2A = ta.cross(lowA, tps2tA) and stillopens2A and openedsA
hittps3A = ta.cross(lowA, tps3tA) and stillopens3A and openedsA
hittps4A = ta.cross(lowA, tps4tA) and stillopens4A and openedsA
hitslsA = highA > slstA and stillopens4A and openedsA
winreversesA = closeA <= csA and backtest and ta.crossover(closeA, stA) and
stillopens4A and trendA == 1 and openedsA
losereversesA = closeA >= csA and backtest and ta.crossover(closeA, stA) and
stillopens4A and trendA == 1 and openedsA

//============================================
cumbuyA = ta.cum(buyA ? 1 : 0)
cumsellA = ta.cum(sellA ? 1 : 0)
cumsignalA = cumbuyA + cumsellA

//net profit
sisaqtybA = stillopenb1A ? 1 : stillopenb2A ? 1 - Qtytp1 : stillopenb3A ? 1 -
(Qtytp1 + Qtytp2) : 1 - (Qtytp1 + Qtytp2 + Qtytp3)
sisaqtysA = stillopens1A ? 1 : stillopens2A ? 1 - Qtytp1 : stillopens3A ? 1 -
(Qtytp1 + Qtytp2) : 1 - (Qtytp1 + Qtytp2 + Qtytp3)

ptpb1A = (tpb1tA - cbA) * 100 / cbA * Qtytp1 //-0.06


ptpb2A = (tpb2tA - cbA) * 100 / cbA * Qtytp2 //-0.06
ptpb3A = (tpb3tA - cbA) * 100 / cbA * Qtytp3 //-0.06
ptpb4A = (tpb4tA - cbA) * 100 / cbA * Qtytp4 //-0.06
pslbA = (closeA - cbA) * 100 / cbA * sisaqtybA //-0.06
prbA = (closeA - cbA) * 100 / cbA * sisaqtybA //-0.06

ptps1A = (csA - tps1tA) * 100 / csA * Qtytp1 //-0.06


ptps2A = (csA - tps2tA) * 100 / csA * Qtytp2 //-0.06
ptps3A = (csA - tps3tA) * 100 / csA * Qtytp3 //-0.06
ptps4A = (csA - tps4tA) * 100 / csA * Qtytp4 //-0.06
pslsA = (csA - closeA) * 100 / csA * sisaqtysA //-0.06
prsA = (csA - closeA) * 100 / csA * sisaqtysA //-0.06

prtpb1A = ta.cum(hittpb1A ? ptpb1A : 0)


prtpb2A = ta.cum(hittpb2A ? ptpb2A : 0)
prtpb3A = ta.cum(hittpb3A ? ptpb3A : 0)
prtpb4A = ta.cum(hittpb4A ? ptpb4A : 0)
prslbA = ta.cum(hitslbA ? pslbA : 0)
prwrbA = ta.cum(winreversebA ? prbA : 0)
prlrbA = ta.cum(losereversebA ? prbA : 0)

prtps1A = ta.cum(hittps1A ? ptps1A : 0)


prtps2A = ta.cum(hittps2A ? ptps2A : 0)
prtps3A = ta.cum(hittps3A ? ptps3A : 0)
prtps4A = ta.cum(hittps4A ? ptps4A : 0)
prslsA = ta.cum(hitslsA ? pslsA : 0)
prwrsA = ta.cum(winreversesA ? prsA : 0)
prlrsA = ta.cum(losereversesA ? prsA : 0)

netcapitalgainA = prtpb1A + prtpb2A + prtpb3A + prtpb4A + prslbA + prtps1A +


prtps2A + prtps3A + prtps4A + prslsA + prwrbA + prlrbA + prwrsA + prlrsA

///winrate
wintpb1A = ta.cum(hittpb1A ? 1 : 0)
wintpb2A = ta.cum(hittpb2A ? 1 : 0)
wintpb3A = ta.cum(hittpb3A ? 1 : 0)
wintpb4A = ta.cum(hittpb4A ? 1 : 0)
wrslbA = ta.cum(hitslbA ? 1 : 0)

wintps1A = ta.cum(hittps1A ? 1 : 0)
wintps2A = ta.cum(hittps2A ? 1 : 0)
wintps3A = ta.cum(hittps3A ? 1 : 0)
wintps4A = ta.cum(hittps4A ? 1 : 0)
wrslsA = ta.cum(hitslsA ? 1 : 0)

cumtp1A = wintpb1A + wintps1A


cumtp2A = wintpb2A + wintps2A
cumtp3A = wintpb3A + wintps3A
cumtp4A = wintpb4A + wintps4A
cumslA = wrslbA + wrslsA
cumpositionA = cumtp1A + cumtp2A + cumtp3A + cumtp4A + cumslA
//+cumwinreverseA//+cumlosereverseA

wrtp1A = truncate(cumtp1A * 100 / cumsignalA, 0)


wrtp2A = truncate(cumtp2A * 100 / cumsignalA, 0)
wrtp3A = truncate(cumtp3A * 100 / cumsignalA, 0)
wrtp4A = truncate(cumtp4A * 100 / cumsignalA, 0)
wrslA = truncate(cumslA * 100 / cumsignalA, 0)

winallA = cumtp1A + cumtp2A + cumtp3A + cumtp4A //+cumwinreverseA


wrallA = winallA * 100 / cumpositionA

//===================================================================
//===================================================================
//===================================================================
//===================================================================
//Timeframe B
//Supertrend Indicator
srcB = hl2B
atr2B = ta.sma(trB, period)
atrB = request.security(syminfo.tickerid, tf2, ta.atr(period))
upB = srcB - mult * atrB
up1B = nz(upB[1], upB)
upB := closeB[1] > up1B ? math.max(upB, up1B) : upB
dnB = srcB + mult * atrB
dn1B = nz(dnB[1], dnB)
dnB := closeB[1] < dn1B ? math.min(dnB, dn1B) : dnB
trendB = 1
trendB := nz(trendB[1], trendB)
trendB := trendB == -1 and closeB > dn1B ? 1 : trendB == 1 and closeB < up1B ? -1 :
trendB
stB = trendB == 1 ? upB : dnB

//filtering
atraB = request.security(syminfo.tickerid, tf2, ta.atr(atrLen))
atrMaB = atrMaType == 'EMB' ? ta.ema(atraB, atrMaLen) : ta.sma(atraB, atrMaLen)
updmB = ta.change(highB)
downdmB = -ta.change(lowB)
plusdmB = na(updmB) ? na : updmB > downdmB and updmB > 0 ? updmB : 0
minusdmB = na(downdmB) ? na : downdmB > updmB and downdmB > 0 ? downdmB : 0
//trurB = rma(trB, diLen)
//plusB = fixnan(100 * rma(plusdmB, diLen) / trurB)
//minusB = fixnan(100 * rma(minusdmB, diLen) / trurB)
//sumB = plusB + minusB
//adxB = 100 * rma(abs(plusB - minusB) / (sumB == 0 ? 1 : sumB), adxLen)

cndSidwayss1B = atraB >= atrMaB


cndSidwayss2B = RSI > toplimitrsi or RSI < botlimitrsi
cndSidwaysB = cndSidwayss1B or cndSidwayss2B
cndSidways1B = cndSidwayss1B and cndSidwayss2B
Sidwayss1B = atraB <= atrMaB
Sidwayss2B = RSI < toplimitrsi and RSI > botlimitrsi
SidwaysB = Sidwayss1B or Sidwayss2B
Sidways1B = Sidwayss1B and Sidwayss2B

trendTypeB = typefilter == filter1 ? cndSidwayss1B : typefilter == filter2 ?


cndSidwayss2B : typefilter == filter3 ? cndSidwaysB : typefilter == filter4 ?
cndSidways1B : typefilter == filter5 ? RSI > 0 : typefilter == filter6 ? SidwaysB :
typefilter == filter7 ? Sidways1B : na

// Entry FIX
buysignal1B = ta.crossover(closeB, stB) and backtest and trendTypeB
sellsignal1B = ta.crossunder(closeB, stB) and backtest and trendTypeB

buyB = buysignal1B and longside


sellB = sellsignal1B and shortside

//Tp & Sl by atr Mult


cbB = ta.valuewhen(buyB, closeB, 0)
ratrB = ta.valuewhen(buyB, request.security(syminfo.tickerid, tf2, ta.atr(14)), 0)

tpb1B = cbB + ratrB * TP1


tpb2B = cbB + ratrB * TP2
tpb3B = cbB + ratrB * TP3
tpb4B = cbB + ratrB * TP4
slbB = cbB - ratrB * SL //withsl?upB:valuewhen(buyB, upB,0)
csB = ta.valuewhen(sellB, closeB, 0)
ratrsB = ta.valuewhen(sellB, request.security(syminfo.tickerid, tf2, ta.atr(14)),
0)
tps1B = csB - ratrsB * TP1
tps2B = csB - ratrsB * TP2
tps3B = csB - ratrsB * TP3
tps4B = csB - ratrsB * TP4
slsB = csB + ratrsB * SL //withsl?dnB:valuewhen(sellB, dnB, 0)

Ptpb1B = cbB * (1 + ptp1)


Ptpb2B = cbB * (1 + ptp2)
Ptpb3B = cbB * (1 + ptp3)
Ptpb4B = et == ex1 ? cbB * (1 + ptp4) : tpb4B
PslbB = cbB * (1 - psl)

Ptps1B = csB * (1 - ptp1)


Ptps2B = csB * (1 - ptp2)
Ptps3B = csB * (1 - ptp3)
Ptps4B = et == ex1 ? csB * (1 - ptp4) : tps4B
PslsB = csB * (1 + psl)

//Variable Fix TP SL
tpb1tB = et == ex1 ? Ptpb1B : tpb1B
tpb2tB = et == ex1 ? Ptpb2B : tpb2B
tpb3tB = et == ex1 ? Ptpb3B : tpb3B
tpb4tB = Ptpb4B
slbtB = et == ex1 ? PslbB : slbB
tps1tB = et == ex1 ? Ptps1B : tps1B
tps2tB = et == ex1 ? Ptps2B : tps2B
tps3tB = et == ex1 ? Ptps3B : tps3B
tps4tB = Ptps4B
slstB = et == ex1 ? PslsB : slsB

sinceentrybB = int(math.max(1, nz(ta.barssince(buyB))))


openedbB = ta.barssince(buyB) >= 0 and trendB[1] == 1 and longside
highestbarbB = ta.highest(sinceentrybB)
lowestbarbB = ta.lowest(sinceentrybB)
stillopenb1B = ta.barssince(buyB) == 1 ? true : highestbarbB[1] < tpb1tB and
lowestbarbB[1] > slbtB
stillopenb2B = ta.barssince(buyB) == 1 ? true : highestbarbB[1] < tpb2tB and
lowestbarbB[1] > slbtB
stillopenb3B = ta.barssince(buyB) == 1 ? true : highestbarbB[1] < tpb3tB and
lowestbarbB[1] > slbtB
stillopenb4B = ta.barssince(buyB) == 1 ? true : highestbarbB[1] < tpb4tB and
lowestbarbB[1] > slbtB

hittpb1B = ta.cross(highB, tpb1tB) and stillopenb1B and openedbB


plotshape(hittpb1B)
hittpb2B = ta.cross(highB, tpb2tB) and stillopenb2B and openedbB
hittpb3B = ta.cross(highB, tpb3tB) and stillopenb3B and openedbB
hittpb4B = ta.cross(highB, tpb4tB) and stillopenb4B and openedbB
hitslbB = lowB < slbtB and stillopenb4B and openedbB
winreversebB = closeB > cbB and backtest and ta.crossunder(closeB, stB) and
stillopenb4B and trendB == -1 and openedbB
losereversebB = closeB < cbB and backtest and ta.crossunder(closeB, stB) and
stillopenb4B and trendB == -1 and openedbB
sinceentrysB = int(math.max(1, nz(ta.barssince(sellB))))
openedsB = ta.barssince(sellB) >= 0 and trendB[1] == -1 and shortside
highestbarsB = ta.highest(sinceentrysB)
lowestbarsB = ta.lowest(sinceentrysB)
stillopens1B = ta.barssince(sellB) == 1 ? true : highestbarsB[1] < slstB and
lowestbarsB[1] > tps1tB
stillopens2B = ta.barssince(sellB) == 1 ? true : highestbarsB[1] < slstB and
lowestbarsB[1] > tps2tB
stillopens3B = ta.barssince(sellB) == 1 ? true : highestbarsB[1] < slstB and
lowestbarsB[1] > tps3tB
stillopens4B = ta.barssince(sellB) == 1 ? true : highestbarsB[1] < slstB and
lowestbarsB[1] > tps4tB

hittps1B = ta.cross(lowB, tps1tB) and stillopens1B and openedsB


hittps2B = ta.cross(lowB, tps2tB) and stillopens2B and openedsB
hittps3B = ta.cross(lowB, tps3tB) and stillopens3B and openedsB
hittps4B = ta.cross(lowB, tps4tB) and stillopens4B and openedsB
hitslsB = highB > slstB and stillopens4B and openedsB
winreversesB = closeB <= csB and backtest and ta.crossover(closeB, stB) and
stillopens4B and trendB == 1 and openedsB
losereversesB = closeB >= csB and backtest and ta.crossover(closeB, stB) and
stillopens4B and trendB == 1 and openedsB

//============================================
cumbuyB = ta.cum(buyB ? 1 : 0)
cumsellB = ta.cum(sellB ? 1 : 0)
cumsignalB = cumbuyB + cumsellB

//net profit
sisaqtybB = stillopenb1B ? 1 : stillopenb2B ? 1 - Qtytp1 : stillopenb3B ? 1 -
(Qtytp1 + Qtytp2) : 1 - (Qtytp1 + Qtytp2 + Qtytp3)
sisaqtysB = stillopens1B ? 1 : stillopens2B ? 1 - Qtytp1 : stillopens3B ? 1 -
(Qtytp1 + Qtytp2) : 1 - (Qtytp1 + Qtytp2 + Qtytp3)

ptpb1B = (tpb1tB - cbB) * 100 / cbB * Qtytp1 //-0.06


ptpb2B = (tpb2tB - cbB) * 100 / cbB * Qtytp2 //-0.06
ptpb3B = (tpb3tB - cbB) * 100 / cbB * Qtytp3 //-0.06
ptpb4B = (tpb4tB - cbB) * 100 / cbB * Qtytp4 //-0.06
pslbB = (closeB - cbB) * 100 / cbB * sisaqtybB //-0.06
prbB = (closeB - cbB) * 100 / cbB * sisaqtybB //-0.06

ptps1B = (csB - tps1tB) * 100 / csB * Qtytp1 //-0.06


ptps2B = (csB - tps2tB) * 100 / csB * Qtytp2 //-0.06
ptps3B = (csB - tps3tB) * 100 / csB * Qtytp3 //-0.06
ptps4B = (csB - tps4tB) * 100 / csB * Qtytp4 //-0.06
pslsB = (csB - close) * 100 / csB * sisaqtysB //-0.06
prsB = (csB - closeB) * 100 / csB * sisaqtysB //-0.06

prtpb1B = ta.cum(hittpb1B ? ptpb1B : 0)


prtpb2B = ta.cum(hittpb2B ? ptpb2B : 0)
prtpb3B = ta.cum(hittpb3B ? ptpb3B : 0)
prtpb4B = ta.cum(hittpb4B ? ptpb4B : 0)
prslbB = ta.cum(hitslbB ? pslbB : 0)
prwrbB = ta.cum(winreversebB ? prbB : 0)
prlrbB = ta.cum(losereversebB ? prbB : 0)

prtps1B = ta.cum(hittps1B ? ptps1B : 0)


prtps2B = ta.cum(hittps2B ? ptps2B : 0)
prtps3B = ta.cum(hittps3B ? ptps3B : 0)
prtps4B = ta.cum(hittps4B ? ptps4B : 0)
prslsB = ta.cum(hitslsB ? pslsB : 0)
prwrsB = ta.cum(winreversesB ? prsB : 0)
prlrsB = ta.cum(losereversesB ? prsB : 0)

netcapitalgainB = prtpb1B + prtpb2B + prtpb3B + prtpb4B + prslbB + prtps1B +


prtps2B + prtps3B + prtps4B + prslsB + prwrbB + prlrbB + prwrsB + prlrsB

///winrate
wintpb1B = ta.cum(hittpb1B ? 1 : 0)
wintpb2B = ta.cum(hittpb2B ? 1 : 0)
wintpb3B = ta.cum(hittpb3B ? 1 : 0)
wintpb4B = ta.cum(hittpb4B ? 1 : 0)
wrslbB = ta.cum(hitslbB ? 1 : 0)

wintps1B = ta.cum(hittps1B ? 1 : 0)
wintps2B = ta.cum(hittps2B ? 1 : 0)
wintps3B = ta.cum(hittps3B ? 1 : 0)
wintps4B = ta.cum(hittps4B ? 1 : 0)
wrslsB = ta.cum(hitslsB ? 1 : 0)

cumtp1B = wintpb1B + wintps1B


cumtp2B = wintpb2B + wintps2B
cumtp3B = wintpb3B + wintps3B
cumtp4B = wintpb4B + wintps4B
cumslB = wrslbB + wrslsB
cumpositionB = cumtp1B + cumtp2B + cumtp3B + cumtp4B + cumslB
//+cumwinreverseB//+cumlosereverseB

wrtp1B = truncate(cumtp1B * 100 / cumsignalB, 0)


wrtp2B = truncate(cumtp2B * 100 / cumsignalB, 0)
wrtp3B = truncate(cumtp3B * 100 / cumsignalB, 0)
wrtp4B = truncate(cumtp4B * 100 / cumsignalB, 0)
wrslB = truncate(cumslB * 100 / cumsignalB, 0)

winallB = cumtp1B + cumtp2B + cumtp3B + cumtp4B //+cumwinreverseB


wrallB = winallB * 100 / cumpositionB

//===================================================================
//===================================================================
//===================================================================
//===================================================================
//Timeframe C
//Supertrend Indicator

srcC = hl2C
atr2C = ta.sma(trC, period)
atrC = request.security(syminfo.tickerid, tf3, ta.atr(period))
upC = srcC - mult * atrC
up1C = nz(upC[1], upC)
upC := closeC[1] > up1C ? math.max(upC, up1C) : upC
dnC = srcC + mult * atrC
dn1C = nz(dnC[1], dnC)
dnC := closeC[1] < dn1C ? math.min(dnC, dn1C) : dnC
trendC = 1
trendC := nz(trendC[1], trendC)
trendC := trendC == -1 and closeC > dn1C ? 1 : trendC == 1 and closeC < up1C ? -1 :
trendC
stC = trendC == 1 ? upC : dnC

//filtering
atraC = request.security(syminfo.tickerid, tf3, ta.atr(atrLen))
atrMaC = atrMaType == 'EMC' ? ta.ema(atraC, atrMaLen) : ta.sma(atraC, atrMaLen)
updmC = ta.change(highC)
downdmC = -ta.change(lowC)
plusdmC = na(updmC) ? na : updmC > downdmC and updmC > 0 ? updmC : 0
minusdmC = na(downdmC) ? na : downdmC > updmC and downdmC > 0 ? downdmC : 0
//trurC = rma(trC, diLen)
//plusC = fixnan(100 * rma(plusdmC, diLen) / trurC)
//minusC = fixnan(100 * rma(minusdmC, diLen) / trurC)
//sumC = plusC + minusC
//adxC = 100 * rma(abs(plusC - minusC) / (sumC == 0 ? 1 : sumC), adxLen)

cndSidwayss1C = atraC >= atrMaC


cndSidwayss2C = RSI > toplimitrsi or RSI < botlimitrsi
cndSidwaysC = cndSidwayss1C or cndSidwayss2C
cndSidways1C = cndSidwayss1C and cndSidwayss2C
Sidwayss1C = atraC <= atrMaC
Sidwayss2C = RSI < toplimitrsi and RSI > botlimitrsi
SidwaysC = Sidwayss1C or Sidwayss2C
Sidways1C = Sidwayss1C and Sidwayss2C

trendTypeC = typefilter == filter1 ? cndSidwayss1C : typefilter == filter2 ?


cndSidwayss2C : typefilter == filter3 ? cndSidwaysC : typefilter == filter4 ?
cndSidways1C : typefilter == filter5 ? RSI > 0 : typefilter == filter6 ? SidwaysC :
typefilter == filter7 ? Sidways1C : na

// Entry FIX
buysignal1C = ta.crossover(closeC, stC) and backtest and trendTypeC
sellsignal1C = ta.crossunder(closeC, stC) and backtest and trendTypeC

buyC = buysignal1C and longside


sellC = sellsignal1C and shortside

//Tp & Sl by atr Mult


cbC = ta.valuewhen(buyC, closeC, 0)
ratrC = ta.valuewhen(buyC, request.security(syminfo.tickerid, tf3, ta.atr(14)), 0)

tpb1C = cbC + ratrC * TP1


tpb2C = cbC + ratrC * TP2
tpb3C = cbC + ratrC * TP3
tpb4C = cbC + ratrC * TP4
slbC = cbC - ratrC * SL //withsl?upC:valuewhen(buyC, upC,0)

csC = ta.valuewhen(sellC, closeC, 0)


ratrsC = ta.valuewhen(sellC, request.security(syminfo.tickerid, tf3, ta.atr(14)),
0)
tps1C = csC - ratrsC * TP1
tps2C = csC - ratrsC * TP2
tps3C = csC - ratrsC * TP3
tps4C = csC - ratrsC * TP4
slsC = csC + ratrsC * SL //withsl?dnC:valuewhen(sellC, dnC, 0)

Ptpb1C = cbC * (1 + ptp1)


Ptpb2C = cbC * (1 + ptp2)
Ptpb3C = cbC * (1 + ptp3)
Ptpb4C = et == ex1 ? cbC * (1 + ptp4) : tpb4C
PslbC = cbC * (1 - psl)

Ptps1C = csC * (1 - ptp1)


Ptps2C = csC * (1 - ptp2)
Ptps3C = csC * (1 - ptp3)
Ptps4C = et == ex1 ? csC * (1 - ptp4) : tps4C
PslsC = csC * (1 + psl)

//Variable Fix TP SL
tpb1tC = et == ex1 ? Ptpb1C : tpb1C
tpb2tC = et == ex1 ? Ptpb2C : tpb2C
tpb3tC = et == ex1 ? Ptpb3C : tpb3C
tpb4tC = Ptpb4C
slbtC = et == ex1 ? PslbC : slbC
tps1tC = et == ex1 ? Ptps1C : tps1C
tps2tC = et == ex1 ? Ptps2C : tps2C
tps3tC = et == ex1 ? Ptps3C : tps3C
tps4tC = Ptps4C
slstC = et == ex1 ? PslsC : slsC

sinceentrybC = int(math.max(1, nz(ta.barssince(buyC))))


openedbC = ta.barssince(buyC) >= 0 and trendC[1] == 1 and longside
highestbarbC = ta.highest(sinceentrybC)
lowestbarbC = ta.lowest(sinceentrybC)
stillopenb1C = ta.barssince(buyC) == 1 ? true : highestbarbC[1] < tpb1tC and
lowestbarbC[1] > slbtC
stillopenb2C = ta.barssince(buyC) == 1 ? true : highestbarbC[1] < tpb2tC and
lowestbarbC[1] > slbtC
stillopenb3C = ta.barssince(buyC) == 1 ? true : highestbarbC[1] < tpb3tC and
lowestbarbC[1] > slbtC
stillopenb4C = ta.barssince(buyC) == 1 ? true : highestbarbC[1] < tpb4tC and
lowestbarbC[1] > slbtC

hittpb1C = ta.cross(highC, tpb1tC) and stillopenb1C and openedbC


plotshape(hittpb1C)
hittpb2C = ta.cross(highC, tpb2tC) and stillopenb2C and openedbC
hittpb3C = ta.cross(highC, tpb3tC) and stillopenb3C and openedbC
hittpb4C = ta.cross(highC, tpb4tC) and stillopenb4C and openedbC
hitslbC = lowC < slbtC and stillopenb4C and openedbC
winreversebC = closeC > cbC and backtest and ta.crossunder(closeC, stC) and
stillopenb4C and trendC == -1 and openedbC
losereversebC = closeC < cbC and backtest and ta.crossunder(closeC, stC) and
stillopenb4C and trendC == -1 and openedbC

sinceentrysC = int(math.max(1, nz(ta.barssince(sellC))))


openedsC = ta.barssince(sellC) >= 0 and trendC[1] == -1 and shortside
highestbarsC = ta.highest(sinceentrysC)
lowestbarsC = ta.lowest(sinceentrysC)
stillopens1C = ta.barssince(sellC) == 1 ? true : highestbarsC[1] < slstC and
lowestbarsC[1] > tps1tC
stillopens2C = ta.barssince(sellC) == 1 ? true : highestbarsC[1] < slstC and
lowestbarsC[1] > tps2tC
stillopens3C = ta.barssince(sellC) == 1 ? true : highestbarsC[1] < slstC and
lowestbarsC[1] > tps3tC
stillopens4C = ta.barssince(sellC) == 1 ? true : highestbarsC[1] < slstC and
lowestbarsC[1] > tps4tC
hittps1C = ta.cross(lowC, tps1tC) and stillopens1C and openedsC
hittps2C = ta.cross(lowC, tps2tC) and stillopens2C and openedsC
hittps3C = ta.cross(lowC, tps3tC) and stillopens3C and openedsC
hittps4C = ta.cross(lowC, tps4tC) and stillopens4C and openedsC
hitslsC = highC > slstC and stillopens4C and openedsC
winreversesC = closeC <= csC and backtest and ta.crossover(closeC, stC) and
stillopens4C and trendC == 1 and openedsC
losereversesC = closeC >= csC and backtest and ta.crossover(closeC, stC) and
stillopens4C and trendC == 1 and openedsC

//============================================
cumbuyC = ta.cum(buyC ? 1 : 0)
cumsellC = ta.cum(sellC ? 1 : 0)
cumsignalC = cumbuyC + cumsellC

//net profit
sisaqtybC = stillopenb1C ? 1 : stillopenb2C ? 1 - Qtytp1 : stillopenb3C ? 1 -
(Qtytp1 + Qtytp2) : 1 - (Qtytp1 + Qtytp2 + Qtytp3)
sisaqtysC = stillopens1C ? 1 : stillopens2C ? 1 - Qtytp1 : stillopens3C ? 1 -
(Qtytp1 + Qtytp2) : 1 - (Qtytp1 + Qtytp2 + Qtytp3)

ptpb1C = (tpb1tC - cbC) * 100 / cbC * Qtytp1 //-0.06


ptpb2C = (tpb2tC - cbC) * 100 / cbC * Qtytp2 //-0.06
ptpb3C = (tpb3tC - cbC) * 100 / cbC * Qtytp3 //-0.06
ptpb4C = (tpb4tC - cbC) * 100 / cbC * Qtytp4 //-0.06
pslbC = (closeC - cbC) * 100 / cbC * sisaqtybC //-0.06
prbC = (closeC - cbC) * 100 / cbC * sisaqtybC //-0.06

ptps1C = (csC - tps1tC) * 100 / csC * Qtytp1 //-0.06


ptps2C = (csC - tps2tC) * 100 / csC * Qtytp2 //-0.06
ptps3C = (csC - tps3tC) * 100 / csC * Qtytp3 //-0.06
ptps4C = (csC - tps4tC) * 100 / csC * Qtytp4 //-0.06
pslsC = (csC - closeC) * 100 / csC * sisaqtysC //-0.06
prsC = (csC - closeC) * 100 / csC * sisaqtysC //-0.06

prtpb1C = ta.cum(hittpb1C ? ptpb1C : 0)


prtpb2C = ta.cum(hittpb2C ? ptpb2C : 0)
prtpb3C = ta.cum(hittpb3C ? ptpb3C : 0)
prtpb4C = ta.cum(hittpb4C ? ptpb4C : 0)
prslbC = ta.cum(hitslbC ? pslbC : 0)
prwrbC = ta.cum(winreversebC ? prbC : 0)
prlrbC = ta.cum(losereversebC ? prbC : 0)

prtps1C = ta.cum(hittps1C ? ptps1C : 0)


prtps2C = ta.cum(hittps2C ? ptps2C : 0)
prtps3C = ta.cum(hittps3C ? ptps3C : 0)
prtps4C = ta.cum(hittps4C ? ptps4C : 0)
prslsC = ta.cum(hitslsC ? pslsC : 0)
prwrsC = ta.cum(winreversesC ? prsC : 0)
prlrsC = ta.cum(losereversesC ? prsC : 0)

netcapitalgainC = prtpb1C + prtpb2C + prtpb3C + prtpb4C + prslbC + prtps1C +


prtps2C + prtps3C + prtps4C + prslsC + prwrbC + prlrbC + prwrsC + prlrsC

///winrate
wintpb1C = ta.cum(hittpb1C ? 1 : 0)
wintpb2C = ta.cum(hittpb2C ? 1 : 0)
wintpb3C = ta.cum(hittpb3C ? 1 : 0)
wintpb4C = ta.cum(hittpb4C ? 1 : 0)
wrslbC = ta.cum(hitslbC ? 1 : 0)

wintps1C = ta.cum(hittps1C ? 1 : 0)
wintps2C = ta.cum(hittps2C ? 1 : 0)
wintps3C = ta.cum(hittps3C ? 1 : 0)
wintps4C = ta.cum(hittps4C ? 1 : 0)
wrslsC = ta.cum(hitslsC ? 1 : 0)

cumtp1C = wintpb1C + wintps1C


cumtp2C = wintpb2C + wintps2C
cumtp3C = wintpb3C + wintps3C
cumtp4C = wintpb4C + wintps4C
cumslC = wrslbC + wrslsC
cumpositionC = cumtp1C + cumtp2C + cumtp3C + cumtp4C + cumslC
//+cumwinreverseC//+cumlosereverseC

wrtp1C = truncate(cumtp1C * 100 / cumsignalC, 0)


wrtp2C = truncate(cumtp2C * 100 / cumsignalC, 0)
wrtp3C = truncate(cumtp3C * 100 / cumsignalC, 0)
wrtp4C = truncate(cumtp4C * 100 / cumsignalC, 0)
wrslC = truncate(cumslC * 100 / cumsignalC, 0)

winallC = cumtp1C + cumtp2C + cumtp3C + cumtp4C //+cumwinreverseC


wrallC = winallC * 100 / cumpositionC

//===================================================================
//===================================================================
//===================================================================
//===================================================================
//Timeframe D
//Supertrend Indicator

srcD = hl2D
atr2D = ta.sma(trD, period)
atrD = request.security(syminfo.tickerid, tf4, ta.atr(period))
upD = srcD - mult * atrD
up1D = nz(upD[1], upD)
upD := closeD[1] > up1D ? math.max(upD, up1D) : upD
dnD = srcD + mult * atrD
dn1D = nz(dnD[1], dnD)
dnD := closeD[1] < dn1D ? math.min(dnD, dn1D) : dnD
trendD = 1
trendD := nz(trendD[1], trendD)
trendD := trendD == -1 and closeD > dn1D ? 1 : trendD == 1 and closeD < up1D ? -1 :
trendD
stD = trendD == 1 ? upD : dnD

//filtering
atraD = request.security(syminfo.tickerid, tf4, ta.atr(atrLen))
atrMaD = atrMaType == 'EMD' ? ta.ema(atraD, atrMaLen) : ta.sma(atraD, atrMaLen)
updmD = ta.change(highD)
downdmD = -ta.change(lowD)
plusdmD = na(updmD) ? na : updmD > downdmD and updmD > 0 ? updmD : 0
minusdmD = na(downdmD) ? na : downdmD > updmD and downdmD > 0 ? downdmD : 0
//trurD = rma(trD, diLen)
//plusD = fixnan(100 * rma(plusdmD, diLen) / trurD)
//minusD = fixnan(100 * rma(minusdmD, diLen) / trurD)
//sumD = plusD + minusD
//adxD = 100 * rma(abs(plusD - minusD) / (sumD == 0 ? 1 : sumD), adxLen)

cndSidwayss1D = atraD >= atrMaD


cndSidwayss2D = RSI > toplimitrsi or RSI < botlimitrsi
cndSidwaysD = cndSidwayss1D or cndSidwayss2D
cndSidways1D = cndSidwayss1D and cndSidwayss2D
Sidwayss1D = atraD <= atrMaD
Sidwayss2D = RSI < toplimitrsi and RSI > botlimitrsi
SidwaysD = Sidwayss1D or Sidwayss2D
Sidways1D = Sidwayss1D and Sidwayss2D

trendTypeD = typefilter == filter1 ? cndSidwayss1D : typefilter == filter2 ?


cndSidwayss2D : typefilter == filter3 ? cndSidwaysD : typefilter == filter4 ?
cndSidways1D : typefilter == filter5 ? RSI > 0 : typefilter == filter6 ? SidwaysD :
typefilter == filter7 ? Sidways1D : na

// Entry FIX
buysignal1D = ta.crossover(closeD, stD) and backtest and trendTypeD
sellsignal1D = ta.crossunder(closeD, stD) and backtest and trendTypeD

buyD = buysignal1D and longside


sellD = sellsignal1D and shortside

//Tp & Sl by atr Mult


cbD = ta.valuewhen(buyD, closeD, 0)
ratrD = ta.valuewhen(buyD, request.security(syminfo.tickerid, tf4, ta.atr(14)), 0)

tpb1D = cbD + ratrD * TP1


tpb2D = cbD + ratrD * TP2
tpb3D = cbD + ratrD * TP3
tpb4D = cbD + ratrD * TP4
slbD = cbD - ratrD * SL //withsl?upD:valuewhen(buyD, upD,0)

csD = ta.valuewhen(sellD, closeD, 0)


ratrsD = ta.valuewhen(sellD, request.security(syminfo.tickerid, tf4, ta.atr(14)),
0)
tps1D = csD - ratrsD * TP1
tps2D = csD - ratrsD * TP2
tps3D = csD - ratrsD * TP3
tps4D = csD - ratrsD * TP4
slsD = csD + ratrsD * SL //withsl?dnD:valuewhen(sellD, dnD, 0)

Ptpb1D = cbD * (1 + ptp1)


Ptpb2D = cbD * (1 + ptp2)
Ptpb3D = cbD * (1 + ptp3)
Ptpb4D = et == ex1 ? cbD * (1 + ptp4) : tpb4D
PslbD = cbD * (1 - psl)

Ptps1D = csD * (1 - ptp1)


Ptps2D = csD * (1 - ptp2)
Ptps3D = csD * (1 - ptp3)
Ptps4D = et == ex1 ? csD * (1 - ptp4) : tps4D
PslsD = csD * (1 + psl)

//Variable Fix TP SL
tpb1tD = et == ex1 ? Ptpb1D : tpb1D
tpb2tD = et == ex1 ? Ptpb2D : tpb2D
tpb3tD = et == ex1 ? Ptpb3D : tpb3D
tpb4tD = Ptpb4D
slbtD = et == ex1 ? PslbD : slbD
tps1tD = et == ex1 ? Ptps1D : tps1D
tps2tD = et == ex1 ? Ptps2D : tps2D
tps3tD = et == ex1 ? Ptps3D : tps3D
tps4tD = Ptps4D
slstD = et == ex1 ? PslsD : slsD

sinceentrybD = int(math.max(1, nz(ta.barssince(buyD))))


openedbD = ta.barssince(buyD) >= 0 and trendD[1] == 1 and longside
highestbarbD = ta.highest(sinceentrybD)
lowestbarbD = ta.lowest(sinceentrybD)
stillopenb1D = ta.barssince(buyD) == 1 ? true : highestbarbD[1] < tpb1tD and
lowestbarbD[1] > slbtD
stillopenb2D = ta.barssince(buyD) == 1 ? true : highestbarbD[1] < tpb2tD and
lowestbarbD[1] > slbtD
stillopenb3D = ta.barssince(buyD) == 1 ? true : highestbarbD[1] < tpb3tD and
lowestbarbD[1] > slbtD
stillopenb4D = ta.barssince(buyD) == 1 ? true : highestbarbD[1] < tpb4tD and
lowestbarbD[1] > slbtD

hittpb1D = ta.cross(highD, tpb1tD) and stillopenb1D and openedbD


plotshape(hittpb1D)
hittpb2D = ta.cross(highD, tpb2tD) and stillopenb2D and openedbD
hittpb3D = ta.cross(highD, tpb3tD) and stillopenb3D and openedbD
hittpb4D = ta.cross(highD, tpb4tD) and stillopenb4D and openedbD
hitslbD = lowD < slbtD and stillopenb4D and openedbD
winreversebD = closeD > cbD and backtest and ta.crossunder(closeD, stD) and
stillopenb4D and trendD == -1 and openedbD
losereversebD = closeD < cbD and backtest and ta.crossunder(closeD, stD) and
stillopenb4D and trendD == -1 and openedbD

sinceentrysD = int(math.max(1, nz(ta.barssince(sellD))))


openedsD = ta.barssince(sellD) >= 0 and trendD[1] == -1 and shortside
highestbarsD = ta.highest(sinceentrysD)
lowestbarsD = ta.lowest(sinceentrysD)
stillopens1D = ta.barssince(sellD) == 1 ? true : highestbarsD[1] < slstD and
lowestbarsD[1] > tps1tD
stillopens2D = ta.barssince(sellD) == 1 ? true : highestbarsD[1] < slstD and
lowestbarsD[1] > tps2tD
stillopens3D = ta.barssince(sellD) == 1 ? true : highestbarsD[1] < slstD and
lowestbarsD[1] > tps3tD
stillopens4D = ta.barssince(sellD) == 1 ? true : highestbarsD[1] < slstD and
lowestbarsD[1] > tps4tD

hittps1D = ta.cross(lowD, tps1tD) and stillopens1D and openedsD


hittps2D = ta.cross(lowD, tps2tD) and stillopens2D and openedsD
hittps3D = ta.cross(lowD, tps3tD) and stillopens3D and openedsD
hittps4D = ta.cross(lowD, tps4tD) and stillopens4D and openedsD
hitslsD = highD > slstD and stillopens4D and openedsD
winreversesD = closeD <= csD and backtest and ta.crossover(closeD, stD) and
stillopens4D and trendD == 1 and openedsD
losereversesD = closeD >= csD and backtest and ta.crossover(closeD, stD) and
stillopens4D and trendD == 1 and openedsD

//============================================
cumbuyD = ta.cum(buyD ? 1 : 0)
cumsellD = ta.cum(sellD ? 1 : 0)
cumsignalD = cumbuyD + cumsellD

//net profit
sisaqtybD = stillopenb1D ? 1 : stillopenb2D ? 1 - Qtytp1 : stillopenb3D ? 1 -
(Qtytp1 + Qtytp2) : 1 - (Qtytp1 + Qtytp2 + Qtytp3)
sisaqtysD = stillopens1D ? 1 : stillopens2D ? 1 - Qtytp1 : stillopens3D ? 1 -
(Qtytp1 + Qtytp2) : 1 - (Qtytp1 + Qtytp2 + Qtytp3)

ptpb1D = (tpb1tD - cbD) * 100 / cbD * Qtytp1 //-0.06


ptpb2D = (tpb2tD - cbD) * 100 / cbD * Qtytp2 //-0.06
ptpb3D = (tpb3tD - cbD) * 100 / cbD * Qtytp3 //-0.06
ptpb4D = (tpb4tD - cbD) * 100 / cbD * Qtytp4 //-0.06
pslbD = (closeD - cbD) * 100 / cbD * sisaqtybD //-0.06
prbD = (closeD - cbD) * 100 / cbD * sisaqtybD //-0.06

ptps1D = (csD - tps1tD) * 100 / csD * Qtytp1 //-0.06


ptps2D = (csD - tps2tD) * 100 / csD * Qtytp2 //-0.06
ptps3D = (csD - tps3tD) * 100 / csD * Qtytp3 //-0.06
ptps4D = (csD - tps4tD) * 100 / csD * Qtytp4 //-0.06
pslsD = (csD - closeD) * 100 / csD * sisaqtysD //-0.06
prsD = (csD - closeD) * 100 / csD * sisaqtysD //-0.06

prtpb1D = ta.cum(hittpb1D ? ptpb1D : 0)


prtpb2D = ta.cum(hittpb2D ? ptpb2D : 0)
prtpb3D = ta.cum(hittpb3D ? ptpb3D : 0)
prtpb4D = ta.cum(hittpb4D ? ptpb4D : 0)
prslbD = ta.cum(hitslbD ? pslbD : 0)
prwrbD = ta.cum(winreversebD ? prbD : 0)
prlrbD = ta.cum(losereversebD ? prbD : 0)

prtps1D = ta.cum(hittps1D ? ptps1D : 0)


prtps2D = ta.cum(hittps2D ? ptps2D : 0)
prtps3D = ta.cum(hittps3D ? ptps3D : 0)
prtps4D = ta.cum(hittps4D ? ptps4D : 0)
prslsD = ta.cum(hitslsD ? pslsD : 0)
prwrsD = ta.cum(winreversesD ? prsD : 0)
prlrsD = ta.cum(losereversesD ? prsD : 0)

netcapitalgainD = prtpb1D + prtpb2D + prtpb3D + prtpb4D + prslbD + prtps1D +


prtps2D + prtps3D + prtps4D + prslsD + prwrbD + prlrbD + prwrsD + prlrsD

///winrate
wintpb1D = ta.cum(hittpb1D ? 1 : 0)
wintpb2D = ta.cum(hittpb2D ? 1 : 0)
wintpb3D = ta.cum(hittpb3D ? 1 : 0)
wintpb4D = ta.cum(hittpb4D ? 1 : 0)
wrslbD = ta.cum(hitslbD ? 1 : 0)

wintps1D = ta.cum(hittps1D ? 1 : 0)
wintps2D = ta.cum(hittps2D ? 1 : 0)
wintps3D = ta.cum(hittps3D ? 1 : 0)
wintps4D = ta.cum(hittps4D ? 1 : 0)
wrslsD = ta.cum(hitslsD ? 1 : 0)

cumtp1D = wintpb1D + wintps1D


cumtp2D = wintpb2D + wintps2D
cumtp3D = wintpb3D + wintps3D
cumtp4D = wintpb4D + wintps4D
cumslD = wrslbD + wrslsD
cumpositionD = cumtp1D + cumtp2D + cumtp3D + cumtp4D + cumslD
//+cumwinreverseD//+cumlosereverseD

wrtp1D = truncate(cumtp1D * 100 / cumsignalD, 0)


wrtp2D = truncate(cumtp2D * 100 / cumsignalD, 0)
wrtp3D = truncate(cumtp3D * 100 / cumsignalD, 0)
wrtp4D = truncate(cumtp4D * 100 / cumsignalD, 0)
wrslD = truncate(cumslD * 100 / cumsignalD, 0)

winallD = cumtp1D + cumtp2D + cumtp3D + cumtp4D //+cumwinreverseD


wrallD = winallD * 100 / cumpositionD

//===================================================================
//===================================================================

//
===================================================================================
====
//Trend Panel

smoothKsrsi = input.int(3, 'K', minval=1)


smoothDsrsi = input.int(3, 'D', minval=1)
lengthRSIsrsi = input.int(14, 'RSI Length', minval=1)
lengthStochsrsi = input.int(14, 'Stochastic Length', minval=1)
srcsrsi = input(close, title='RSI Source')
rsi1srsi = ta.rsi(srcsrsi, lengthRSIsrsi)
ksrsi = truncate(ta.sma(ta.stoch(rsi1srsi, rsi1srsi, rsi1srsi, lengthStochsrsi),
smoothKsrsi), dpa)
dsrsi = ta.sma(ksrsi, smoothDsrsi)

fast_lengthm = input(title='Fast Length', defval=12)


slow_lengthm = input(title='Slow Length', defval=26)
srcm = input(title='Source', defval=close)
signal_lengthm = input.int(title='Signal Smoothing', minval=1, maxval=50, defval=9)
sma_sourcem = input.string(title='Oscillator MA Type', defval='EMA',
options=['SMA', 'EMA'])
sma_signalm = input.string(title='Signal Line MA Type', defval='EMA',
options=['SMA', 'EMA'])

fast_mam = sma_sourcem == 'SMA' ? ta.sma(srcm, fast_lengthm) : ta.ema(srcm,


fast_lengthm)
slow_mam = sma_sourcem == 'SMA' ? ta.sma(srcm, slow_lengthm) : ta.ema(srcm,
slow_lengthm)
macd = fast_mam - slow_mam
signalm = sma_signalm == 'SMA' ? ta.sma(macd, signal_lengthm) : ta.ema(macd,
signal_lengthm)
histm = macd - signalm

trenddir = RSI > 55 ? 'Bullish' : RSI < 45 ? 'Bearish' : 'Sideways'

//Tele Notif
ep = trend == 1 ? cb : cs
winrate = truncate(strategy.wintrades / strategy.closedtrades * 100, 0)
capitalgain = 100 * strategy.netprofit / initialcapital
closedtrades = strategy.closedtrades
//Gathers User Inputs
//Dashboard
sideentry = strategy.position_size > 0 ? 'LONG' : strategy.position_size < 0 ?
'SHORT' : 'No Position'
epp = strategy.position_size > 0 ? cb : strategy.position_size < 0 ? cs : na
tp1p = truncate(strategy.position_size > 0 ? tpb1t : strategy.position_size < 0 ?
tps1t : na, dpa)
tp2p = truncate(strategy.position_size > 0 ? tpb2t : strategy.position_size < 0 ?
tps2t : na, dpa)
tp3p = truncate(strategy.position_size > 0 ? tpb3t : strategy.position_size < 0 ?
tps3t : na, dpa)
tp4p = truncate(strategy.position_size > 0 ? tpb4t : strategy.position_size < 0 ?
tps4t : na, dpa)
slp = truncate(strategy.position_size > 0 ? slbt : strategy.position_size < 0 ?
slst : na, dpa)
dashDist = input.int(5, 'Dashboard Distance', group='Dashboard Settings')
dashColor = input.color(color.new(#000000, 0), 'Dashboard Color', inline='Dash
Line', group='Dashboard Settings')
dashTextColor = input.color(color.new(#ffffff, 0), 'Text Color', inline='Dash
Line', group='Dashboard Settings')

sinceentryb = int(math.max(1, nz(ta.barssince(buy and backtest and trendType))))


highestbarb = ta.highest(high[1], sinceentryb)
lowestbarb = ta.lowest(low[1], sinceentryb)
sinceentrys = int(math.max(1, nz(ta.barssince(sell and backtest and trendType))))
highestbars = ta.highest(high[1], sinceentrys)
lowestbars = ta.lowest(low[1], sinceentrys)

hittp1 = strategy.position_size > 0 ? highestbars > tpb1t : strategy.position_size


< 0 ? lowestbars < tps1t : na
hittp1t = hittp1 ? ' ✅' : na
hittp2 = strategy.position_size > 0 ? highestbars > tpb2t : strategy.position_size
< 0 ? lowestbars < tps2t : na
hittp2t = hittp2 ? ' ✅' : na
hittp3 = strategy.position_size > 0 ? highestbars > tpb3t : strategy.position_size
< 0 ? lowestbars < tps3t : na
hittp3t = hittp3 ? ' ✅' : na
hittp4 = strategy.position_size > 0 ? highestbars > tpb4t : strategy.position_size
< 0 ? lowestbars < tps4t : na
hittp4t = hittp4 ? ' ✅' : na

longnotif = '_____________________________' + '\n ' +


'\n📡📡Signals 💯Max🤖Profit💸 📡📡' + '\n_____________________________' + '\n
' + '\nCoin : ' + syminfo.ticker + '\nPosition : 🔺 LONG' + '\
nOpen Price : ' + str.tostring(truncate(ep, dpa)) + '\nTake Profit 1 : ' +
str.tostring(truncate(tpb1t, dpa)) + '\nTake Profit 2 : ' +
str.tostring(truncate(tpb2t, dpa)) + '\nTake Profit 3 : ' +
str.tostring(truncate(tpb3t, dpa)) + '\nTake Profit 4 : ' +
str.tostring(truncate(tpb4t, dpa)) + '\nStoploss : ' +
str.tostring(truncate(slbt, dpa)) + '\n_____________________________' + '\n
' + '\n Backtest Days ' + 'On ' + str.tostring(truncate(daysback, 2)) + ' Days 💰' +
'\n_____________________________' + '\n ' + '\n🌟 💯Max🤖
Profit💸 Winrate : ' + str.tostring(winrate) + ' % 🌟' + '\n💰 Net Profits : ' +
str.tostring(truncate(capitalgain, 2)) + '% 💰' + '\n📌 Total Trades : ' +
str.tostring(closedtrades) + ' 📌' + '\n_____________________________'
//+ '\n\n🎯 TAKE PROFITS RATINGS (%) 🎯'
//+ '\n_____________________________'
//+ '\n\nTake Profits 1 : '+tostring(wrtp1A)+' %'
//+ '\nTake Profits 2 : ' +tostring(wrtp2A)+' %'
//+ '\nTake Profits 3 : ' +tostring(wrtp3A)+' %'
//+ '\nTake Profits 4 : ' +tostring(wrtp4A)+' %'
//+ '\n_______________________________'
//+ '\n '
//+ '\n🧾Panel 💯Max🤖Profit💸'
//+ '\n_______________________________'
//+ '\n '
//+ '\nRSI : ' + tostring(RSI)
//+ '\nSRSI : ' + tostring(ksrsi)
//+ '\nCurrent Sentiment = ' + tostring(trenddir)
//+ '\n_____________________________'
//+ '\n '
//+ '\n🚨 Notes 🚨'
//+ '\n• Disclaimer On !'
//+ '\n• Future USD-M Coin Mode.'
//+ '\n• Trade with high risk.'
//+ '\n• Stay wise & disciplined.'
//+ '\n• Risk Management.'
//+ '\n• Use 1-3% of the total Wallet Future.\n'
//+ '\n_____________________________'
//+ '\n '
//+ '\n 🎉 Happy Profit 🎉'
//+ '\n_____________________________'

shortnotif = '_______________________________' + '\n '


+ '\n📡📡Signals 💯Max🤖Profit💸 📡📡' + '\n_____________________________' + '\n
' + '\nCoin : ' + syminfo.ticker + '\nPosition : 🔻 SHORT' + '\
nOpen Price : ' + str.tostring(truncate(ep, dpa)) + '\nTake Profit 1 : ' +
str.tostring(truncate(tps1t, dpa)) + '\nTake Profit 2 : ' +
str.tostring(truncate(tps2t, dpa)) + '\nTake Profit 3 : ' +
str.tostring(truncate(tps3t, dpa)) + '\nTake Profit 4 : ' +
str.tostring(truncate(tps4t, dpa)) + '\nStoploss : ' +
str.tostring(truncate(slst, dpa)) + '\n_____________________________' + '\n
' + '\n Backtest Days ' + 'On ' + str.tostring(truncate(daysback, 2)) + ' Days 💰' +
'\n_____________________________' + '\n ' + '\n🌟 💯Max🤖
Profit💸 Winrate : ' + str.tostring(winrate) + ' % 🌟' + '\n💰 Net Profits : ' +
str.tostring(truncate(capitalgain, 2)) + '% 💰' + '\n📌 Total Trades : ' +
str.tostring(closedtrades) + ' 📌' + '\n_____________________________'
//+ '\n\n🎯 TAKE PROFITS RATINGS (%) 🎯'
//+ '\n_____________________________'
//+ '\n\nTake Profits 1 : '+tostring(wrtp1A)+' %'
//+ '\nTake Profits 2 : ' +tostring(wrtp2A)+' %'
//+ '\nTake Profits 3 : ' +tostring(wrtp3A)+' %'
//+ '\nTake Profits 4 : ' +tostring(wrtp4A)+' %'
//+ '\n_______________________________'
//+ '\n '
//+ '\n🧾Panel 💯Max🤖Profit💸'
//+ '\n_______________________________'
//+ '\n '
//+ '\nRSI : ' + tostring(RSI)
//+ '\nSRSI : ' + tostring(ksrsi)
//+ '\nCurrent Sentiment = ' + tostring(trenddir)
//+ '\n_____________________________'
//+ '\n '
//+ '\n🚨 Notes 🚨'
//+ '\n• Disclaimer On !'
//+ '\n• Future USD-M Coin Mode.'
//+ '\n• Trade with high risk.'
//+ '\n• Stay wise & disciplined.'
//+ '\n• Risk Management.'
//+ '\n• Use 1-3% Wallet Future.\n'
//+ '\n_____________________________'
//+ '\n '
// + '\n🎉 Happy Profit 🎉'
// + '\n_____________________________'

exitziglong1 = '⚠Position Status⚠\n\nTake Profit 1 ✅ From 🔺 Long Signal\n' + 'at


Price : ' + str.tostring(tpb1t) + ' in ' + syminfo.ticker // +
tostring(exitpricelong1)
exitzigshort1 = '⚠Position Status⚠\n\nTake Profit 1 ✅ From 🔻 Short Signal\n' + 'at
Price : ' + str.tostring(tps1t) + ' in ' + syminfo.ticker //+
tostring(exitpriceshort1)
exitziglong2 = '⚠Position Status⚠\n\nTake Profit 2 ✅ From 🔺 Long Signal\n' + 'at
Price : ' + str.tostring(tpb2t) + ' in ' + syminfo.ticker // +
tostring(exitpricelong2)
exitzigshort2 = '⚠Position Status⚠\n\nTake Profit 2 ✅ From 🔻 Short Signal\n' + 'at
Price : ' + str.tostring(tps2t) + ' in ' + syminfo.ticker // +
tostring(exitpriceshort2)
exitziglong3 = '⚠Position Status⚠\n\nTake Profit 3 ✅ From 🔺 Long Signal\n' + 'at
Price : ' + str.tostring(tpb3t) + ' in ' + syminfo.ticker // +
tostring(exitpricelong3)
exitzigshort3 = '⚠Position Status⚠\n\nTake Profit 3 ✅ From 🔻 Short Signal\n' + 'at
Price : ' + str.tostring(tps3t) + ' in ' + syminfo.ticker // +
tostring(exitpriceshort3)
exitziglong4 = '⚠Position Status⚠\n\nTake Profit 4 ✅ From 🔺 Long Signal\n' + 'at
Price : ' + str.tostring(tpb4t) + ' in ' + syminfo.ticker // +
tostring(exitpricelong3)
exitzigshort4 = '⚠Position Status⚠\n\nTake Profit 4 ✅ From 🔻 Short Signal\n' + 'at
Price : ' + str.tostring(tps4t) + ' in ' + syminfo.ticker // +
tostring(exitpriceshort3)

sllong = '⚠Position Status⚠\n\nHit SL 💋 From 🔺 Long Signal\n' + ' Price : ' +


str.tostring(slbt) + ' in ' + syminfo.ticker // + tostring(exitpricelong4)
slshort = '⚠Position Status⚠\n\nHit SL 💋 From 🔻 Short Signal\n' + ' Price : ' +
str.tostring(slst) + ' in ' + syminfo.ticker // + tostring(exitpriceshort4)

longbotcommand = ZZ == z1 ? longct : ZZ == z2 ? longsp : longnotif


shortbotcommand = ZZ == z1 ? shortct : ZZ == z2 ? shortsp : shortnotif
exitbotcommandl1 = ZZ == z3 ? exitziglong1 : na
exitbotcommands1 = ZZ == z3 ? exitzigshort1 : na
exitbotcommandl2 = ZZ == z3 ? exitziglong2 : na
exitbotcommands2 = ZZ == z3 ? exitzigshort2 : na
exitbotcommandl3 = ZZ == z3 ? exitziglong3 : na
exitbotcommands3 = ZZ == z3 ? exitzigshort3 : na
exitbotcommandl4 = ZZ == z3 ? exitziglong4 : na
exitbotcommands4 = ZZ == z3 ? exitzigshort4 : na
sllongcommand = ZZ == z3 ? sllong : slcommand
slshortcommand = ZZ == z3 ? slshort : slcommand

//
if buy and backtest and trendType and longside
strategy.entry('Buy', direction=strategy.long, comment='LONG',
alert_message=longbotcommand)

if sell and backtest and trendType and shortside


strategy.entry('Sell', direction=strategy.short, comment='SHORT',
alert_message=shortbotcommand)

strategy.exit('TP 1', 'Buy', qty_percent=qtytp1, limit=tpb1t,


alert_message=exitbotcommandl1)
strategy.exit('TP 2', 'Buy', qty_percent=qtytp2, limit=tpb2t,
alert_message=exitbotcommandl2)
strategy.exit('TP 3', 'Buy', qty_percent=qtytp3, limit=tpb3t,
alert_message=exitbotcommandl3)
strategy.exit('TP 4', 'Buy', qty_percent=qtytp4, limit=tpb4t,
alert_message=exitbotcommandl4)

slbclose = sellsignal1 or low < slbt


strategy.close('Buy', when=slbclose, comment='SL', alert_message=sllongcommand)

strategy.exit('TP 1', 'Sell', qty_percent=qtytp1, limit=tps1t,


alert_message=exitbotcommands1)
strategy.exit('TP 2', 'Sell', qty_percent=qtytp2, limit=tps2t,
alert_message=exitbotcommands1)
strategy.exit('TP 3', 'Sell', qty_percent=qtytp3, limit=tps3t,
alert_message=exitbotcommands1)
strategy.exit('TP 4', 'Sell', qty_percent=qtytp4, limit=tps4t,
alert_message=exitbotcommands1)

slsclose = buysignal1 or high > slst


strategy.close('Sell', when=slsclose, comment='SL', alert_message=slshortcommand)

plot(strategy.position_size <= 0 ? na : tpb1t, color=color.new(color.blue, 0),


style=plot.style_linebr, linewidth=2, title='TP 1 Buy')
plot(strategy.position_size <= 0 ? na : tpb2t, color=color.new(color.blue, 0),
style=plot.style_linebr, linewidth=2, title='TP 2 Buy')
plot(strategy.position_size <= 0 ? na : tpb3t, color=color.new(color.blue, 0),
style=plot.style_linebr, linewidth=2, title='TP 3 Buy')
plot(strategy.position_size >= 0 ? na : tps1t, color=color.new(color.blue, 0),
style=plot.style_linebr, linewidth=2, title='TP 1 Sell')
plot(strategy.position_size >= 0 ? na : tps2t, color=color.new(color.blue, 0),
style=plot.style_linebr, linewidth=2, title='TP 2 Sell')
plot(strategy.position_size >= 0 ? na : tps3t, color=color.new(color.blue, 0),
style=plot.style_linebr, linewidth=2, title='TP 3 Sell')
plot(strategy.position_size >= 0 ? na : tps4t, color=color.new(color.blue, 0),
style=plot.style_linebr, linewidth=2, title='TP 4 Sell')
plot(strategy.position_size <= 0 ? na : tpb4t, color=color.new(color.blue, 0),
style=plot.style_linebr, linewidth=2, title='TP 4 Sell')

plot(strategy.position_size >= 0 ? na : slst, color=color.new(color.red, 0),


style=plot.style_linebr, linewidth=2, title='TP 4 Sell')
plot(strategy.position_size <= 0 ? na : slbt, color=color.new(color.red, 0),
style=plot.style_linebr, linewidth=2, title='TP 4 Sell')

//
besttf = math.max(netcapitalgainA, netcapitalgainB, netcapitalgainC,
netcapitalgainD)
besttft = besttf == netcapitalgainA ? tf1 : besttf == netcapitalgainB ? tf2 :
besttf == netcapitalgainC ? tf3 : besttf == netcapitalgainD ? tf4 : na
accesstf = timeframe.period
wrtp1 = accesstf == str.tostring(3) ? besttf == netcapitalgainA ? wrtp1A : besttf
== netcapitalgainB ? wrtp1B : besttf == netcapitalgainC ? wrtp1C : besttf ==
netcapitalgainD ? wrtp1D : na : na
wrtp2 = accesstf == str.tostring(3) ? besttf == netcapitalgainA ? wrtp2A : besttf
== netcapitalgainB ? wrtp2B : besttf == netcapitalgainC ? wrtp2C : besttf ==
netcapitalgainD ? wrtp2D : na : na
wrtp3 = accesstf == str.tostring(3) ? besttf == netcapitalgainA ? wrtp3A : besttf
== netcapitalgainB ? wrtp3B : besttf == netcapitalgainC ? wrtp3C : besttf ==
netcapitalgainD ? wrtp3D : na : na
wrtp4 = accesstf == str.tostring(3) ? besttf == netcapitalgainA ? wrtp4A : besttf
== netcapitalgainB ? wrtp4B : besttf == netcapitalgainC ? wrtp4C : besttf ==
netcapitalgainD ? wrtp4D : na : na
wrsl = accesstf == str.tostring(3) ? besttf == netcapitalgainA ? wrslA : besttf ==
netcapitalgainB ? wrslB : besttf == netcapitalgainC ? wrslC : besttf ==
netcapitalgainD ? wrslD : na : na
Besttf = accesstf == str.tostring(3) ? besttft : 'NaN'

mtfanalysis = accesstf == str.tostring(3) ? str.tostring(Besttf) : 'NaN'

dashboardtext = '_______________________________' + '\n


' + '\nSignals @fian_trader' + '\n_______________________________' + '\n
' + '\nCoin : ' + syminfo.ticker + '\nLaverage : 10x-20X' + '\nExchanges : Binance
Futures' + '\nPosition : ' + str.tostring(sideentry) + '\nEntry Target : ' +
str.tostring(truncate(epp, dpa)) + '\nTake Profit 1 : ' +
str.tostring(truncate(tp1p, dpa)) + str.tostring(hittp1t) + '\nTake Profit 2 : ' +
str.tostring(truncate(tp2p, dpa)) + str.tostring(hittp2t) + '\nTake Profit 3 : ' +
str.tostring(truncate(tp3p, dpa)) + str.tostring(hittp3t) + '\nTake Profit 4 : ' +
str.tostring(truncate(tp4p, dpa)) + str.tostring(hittp4t) + '\nStop Target : ' +
str.tostring(truncate(slp, dpa)) + '\n_______________________________' + '\n\nMulti
TF Analysis' + '\nBuka akses TF 3m untuk melihat Best TF ' + '\n\n Best TimeFrame :
' + mtfanalysis + '\n_______________________________' + '\n
' + '\nWinrate : ' + str.tostring(winrate) + ' %' + '\nNet Profits : ' +
str.tostring(truncate(capitalgain, 2)) + ' % On ' + str.tostring(daysback) + '
Days' + '\nTotal Trades : ' + str.tostring(closedtrades) + '\
n_____________________________' + '\n\n🎯 TAKE PROFITS RATINGS (%) 🎯' + '\
n_____________________________' + '\n\nTake Profits 1 : ' + str.tostring(wrtp1A) +
' %' + '\nTake Profits 2 : ' + str.tostring(wrtp2A) + ' %' + '\nTake Profits 3 : '
+ str.tostring(wrtp3A) + ' %' + '\nTake Profits 4 : ' + str.tostring(wrtp4A) + ' %'
// + '\n_______________________________'
// + '\n\n🧾Panel 💯Max🤖Profit💸'
// + '\n_______________________________'
// + '\n '
// + '\nRSI = ' + tostring(RSI)
// + '\nCurrent Sentiment = ' + tostring(trenddir)
// + '\n_______________________________'
// + '\n '
// + '\n🎉 Happy Profit 🎉'
// + '\n_______________________________'

// + '\n' + tostring(netcapitalgainA)
// + '\n' + tostring(netcapitalgainB)
// + '\n' + tostring(netcapitalgainC)
// + '\n' + tostring(netcapitalgainD)

//if strategy.position_size>0?strategy.position_size>0:strategy.position_size<0
label lemonLabel = label.new(time, close, text=dashboardtext, color=dashColor,
xloc=xloc.bar_time, style=label.style_label_left, textcolor=dashTextColor,
textalign=text.align_center)
label.set_x(lemonLabel, label.get_x(lemonLabel) + math.round(ta.change(time) *
dashDist))
label.delete(lemonLabel[1])

//PLOTTING
bodyMiddle = plot(ST ? (open + close) / 2 : na, display=display.none)
uptrend = plot(ST ? trend < 0 ? na : up : na, 'Up trend',
color=color.new(color.green, 0), style=plot.style_linebr, linewidth=2)
downtrend = plot(ST ? trend < 0 ? dn : na : na, 'Down trend',
color=color.new(color.red, 0), style=plot.style_linebr, linewidth=2)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy