0% found this document useful (0 votes)
4 views9 pages

ahmed 00000000000000000000000

The document is a Pine Script strategy for trading, allowing users to set parameters for date ranges, stop losses, and take profits. It includes features for Dollar Cost Averaging (DCA) and signals for long and short trades based on various technical indicators. The script is designed to be used on trading platforms that support Pine Script, with customizable options for user preferences.

Uploaded by

h.ermenkov
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)
4 views9 pages

ahmed 00000000000000000000000

The document is a Pine Script strategy for trading, allowing users to set parameters for date ranges, stop losses, and take profits. It includes features for Dollar Cost Averaging (DCA) and signals for long and short trades based on various technical indicators. The script is designed to be used on trading platforms that support Pine Script, with customizable options for user preferences.

Uploaded by

h.ermenkov
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/ 9

//@version=5

strategy("ahmed 00000000000000000000000000000strategy", overlay = true,


calc_on_every_tick=true, default_qty_value=100, initial_capital=1000,
calc_on_order_fills=true, pyramiding = 20)
start_year = input.int(title='Start Date', defval=2000, minval=1800, maxval=3000,
group='Strategy: Date Range', inline='1')
start_month = input.int(title='', defval=1, group='Strategy: Date Range',
inline='1', options = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])
start_date = input.int(title='', defval=1, group='Strategy: Date Range',
inline='1', options = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31])
end_year = input.int(title='End Date', defval=2023, minval=1800, maxval=3000,
group='Strategy: Date Range', inline='2')
end_month = input.int(title='', defval=1, group='Strategy: Date Range', inline='2',
options = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])
end_date = input.int(title='', defval=1, group='Strategy: Date Range', inline='2',
options = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31])
in_date_range = time >= timestamp(syminfo.timezone, start_year, start_month,
start_date, 0, 0) and time < timestamp(syminfo.timezone, end_year, end_month,
end_date, 0, 0)
TA = (true)
instructions1 = input.bool (false,title ="🚦instructions
_____________________________________________________________ set all alerts to 1hr
_____________________________________________________________ make sure to enable:
once per bar close _____________________________________________________________
any changes made to this should be carried over to other corresponding settings in
other ape.x indicators")
showbearvsbull = input.bool(false, title = "====>🤑 show dca trading strategy and
assist _____________________________________________________________ ENABLED
signals ✅ _____________________________________________________________ DCA = DCA
ENTRY /COLOR🟦/ _____________________________________________________________ dTP1 =
DCA TAKE PROFIT 1 /COLOR🟦/
_____________________________________________________________ dTP2 = DCA TAKE
PROFIT 2 /COLOR🟦/ _____________________________________________________________
dTP3 = DCA TAKE PROFIT 3 /COLOR🟦/
_____________________________________________________________ D❌ = DCA STOP LOSS
/COLOR📰/")
instructions3 = input.bool (false,title ="🚦instructions
_____________________________________________________________ edit take profits and
stop loss for dca ")
stopPerDCA1 = input.float(10, title='DCA Stop Loss: %(not working in strategy)') *
0.01
takePerDCA1 = input.float(6, title='DCA Take Profit 1') * 0.01
takePerDCA2 = input.float(8, title='DCA Take Profit 2') * 0.01
takePerDCA3 = input.float(15, title='DCATake Profit 3') * 0.01
showpredictions = input.bool(true, title = "====>🤑 show Long/Short trading strategy
and assist _____________________________________________________________ ENABLED
signals ✅ _____________________________________________________________ L = LONG
ENTRY /COLOR🟩/ _____________________________________________________________ S =
SHORT ENTRY /COLOR🟥/ _____________________________________________________________
LTP1 = LONG TAKE PROFIT 1 /COLOR🟪/
_____________________________________________________________ LTP2 = LONG TAKE
PROFIT 2 /COLOR🟪/ _____________________________________________________________
LTP3 = LONG TAKE PROFIT 3 /COLOR🟪/
_____________________________________________________________ STP1 = SHORT TAKE
PROFIT 1 /COLOR🟨/ _____________________________________________________________
STP2 = SHORT TAKE PROFIT 2 /COLOR🟨/
_____________________________________________________________ STP3 = SHORT TAKE
PROFIT 3 /COLOR🟨/ _____________________________________________________________ S❌
= SHORT STOP LOSS /COLOR📰/
_____________________________________________________________ L❌ = LONG STOP
LOSS /COLOR📰/ _____________________________________________________________")
instructions2 = input.bool (false,title ="🚦instructions
_____________________________________________________________ edit take profits and
stop losses for long/ short ")
stopPerHR1 = input.float(10, title='APE.X Strategy Stop Loss: % (not working in
strategy)') * 0.01
takePerHR1 = input.float(7, title='APE.X Strategy Take Profit 1') * 0.01
takePerHR2 = input.float(13, title='APE.X Strategy Take Profit 2') * 0.01
takePerHR3 = input.float(24, title='APE.X Strategy Take Profit 3') * 0.01
instructions4 = input.bool (false,title ="🚦instructions
_____________________________________________________________ below you can edit
long/short through gods trend and bull vs bear strategies
_____________________________________________________________ below you can aslo
edit dca strategy")
GPbearvsbull = '===== edit bull versus bear strategy====='
GP1thegods = '===== edit the gods trend strategy====='
GPDOLLARCOSTAVERAGE = '===== Dollar Cost Average ====='
on_symb = (true)
A6 = (true)
min_level = input.int(defval=36, title='Dollar cost average', minval=-100,
group=GPDOLLARCOSTAVERAGE)
length = input(10, group=GPDOLLARCOSTAVERAGE)
mult =input(40, group=GPDOLLARCOSTAVERAGE)
maj_qual = (6)
maj_len = (30)
min_qual = (5)
min_len = (5)
maj = true
min = true
buy_4 = 0.0
upper_s = math.sum(volume * (ta.change(hlc3) <= 0 ? 0 : hlc3), 14)
lower_s = math.sum(volume * (ta.change(hlc3) >= 0 ? 0 : hlc3), 14)
xmf = 100.0 - 100.0 / (1.0 + upper_s / lower_s)
basis = ta.sma(ohlc4, 25)
dev = mult * ta.stdev(ohlc4, 25)
upper = basis + dev
lower = basis - dev
OB1 = (upper + lower) / 2.0
OB2 = upper - lower
BollOsc = (ohlc4 - OB1) / OB2 * 100
xrsi = ta.rsi(ohlc4, 14)
calc_stoch(src38, length, smoothFastD) =>
ll3 = ta.lowest(low, length)
hh = ta.highest(high, length)
k = 100 * (src38 - ll3) / (hh - ll3)
ta.sma(k, smoothFastD)
stoc = calc_stoch(ohlc4, 21, 3)
trend23 = (xrsi + xmf + BollOsc + stoc / 3) / 2
x = bar_index
y = trend23
x_ = ta.ema(x, length)
y_ = ta.ema(y, length)
mx = ta.stdev(x, length)
my = ta.stdev(y, length)
c23 = ta.correlation(x, y, length)
slope = c23 * (my / mx)
inter = y_ - slope * x_
reg_trend23 = x * slope + inter
lele(qual, len) =>
bindex = 0.0
sindex = 0.0
bindex := nz(bindex[1], 0)
sindex := nz(sindex[1], 0)
ret = 0
if close > close[4]
bindex += 1
bindex
if close < close[4]
sindex += 1
sindex
if bindex > qual and close < open and high >= ta.highest(high, len)
bindex := 0
ret := -1
ret
if sindex > qual and close > open and low <= ta.lowest(low, len)
sindex := 0
ret := 1
ret
return_1 = ret
return_1
major = lele(maj_qual, maj_len)
minor = lele(min_qual, min_len)
a = 1
cc = 10
xATR = ta.atr(cc)
nLoss = a * xATR
src38 = close
xATRTrailingStop = 0.0
iff_2 = src38 > nz(xATRTrailingStop[1], 0) ? src38 - nLoss : src38 + nLoss
iff_3 = src38 < nz(xATRTrailingStop[1], 0) and src38[1] < nz(xATRTrailingStop[1],
0) ? math.min(nz(xATRTrailingStop[1]), src38 + nLoss) : iff_2
xATRTrailingStop := src38 > nz(xATRTrailingStop[1], 0) and src38[1] >
nz(xATRTrailingStop[1], 0) ? math.max(nz(xATRTrailingStop[1]), src38 - nLoss) :
iff_3
pos = 0
iff_4 = src38[1] > nz(xATRTrailingStop[1], 0) and src38 < nz(xATRTrailingStop[1],
0) ? -1 : nz(pos[1], 0)
pos := src38[1] < nz(xATRTrailingStop[1], 0) and src38 > nz(xATRTrailingStop[1], 0)
? 1 : iff_4
xcolor = pos == -1 ? color.red : pos == 1 ? color.green : color.blue
ema = ta.ema(src38, 1)
above = ta.crossover(ema, xATRTrailingStop)
below = ta.crossover(xATRTrailingStop, ema)
buy_a = src38 > xATRTrailingStop and above
if ta.crossunder(reg_trend23, trend23) and reg_trend23 <= min_level and trend23 <=
min_level and A6
buy_4 := 1
buy_4
res5 = input.timeframe('2D', title = 'adjust bull vs bear calls', group=
GPbearvsbull )
o = request.security(syminfo.tickerid, res5, open, barmerge.gaps_off,
barmerge.lookahead_on)
c = request.security(syminfo.tickerid, res5, close, barmerge.gaps_off,
barmerge.lookahead_on)
hz = request.security(syminfo.tickerid, res5, high, barmerge.gaps_off,
barmerge.lookahead_on)
l = request.security(syminfo.tickerid, res5, low, barmerge.gaps_off,
barmerge.lookahead_on)
st_mult = input.float(0,title = 'adjust multiplier', group= GPbearvsbull)
st_period = input.int(500,title = 'adjust intervals', group= GPbearvsbull)
up_lev = l - st_mult * ta.atr(st_period)
dn_lev = hz + st_mult * ta.atr(st_period)
up_trend = 0.0
up_trend := c[1] > up_trend[1] ? math.max(up_lev, up_trend[1]) : up_lev
down_trend = 0.0
down_trend := c[1] < down_trend[1] ? math.min(dn_lev, down_trend[1]) : dn_lev
trend = 0
trend := c > down_trend[1] ? 1 : c < up_trend[1] ? -1 : nz(trend[1], 1)
st_line = trend == 1 ? up_trend : down_trend
buy44 = ta.crossover(c, st_line)
sell44 = ta.crossunder(c, st_line)
bull_ht = buy44
sell_ht = sell44
src5 = (close)
tf = input(1440, title = 'adjust the gods numbers', group=GP1thegods)
len5 = timeframe.isintraday and timeframe.multiplier >= 1 ? tf /
timeframe.multiplier * 7 : timeframe.isintraday and timeframe.multiplier < 60 ?
60 / timeframe.multiplier * 24 * 7 : 7
ma32 = ta.ema(src5 * volume, len5) / ta.ema(volume, len5)
src1 = ma32
p(src1, len5) =>
n = 0.0
s = 0.0
for i = 0 to len5 - 1 by 1
w = (len5 - i) * len5
n += w
s += src5[i] * w
s
s / n
hm = 2.0 * p(src1, math.floor(len5 / 2)) - p(src1, len5)
vhma = p(hm, math.floor(math.sqrt(len5)))
lineColor = vhma > vhma[1] ? color.lime : color.purple
b2 = timeframe.isintraday and timeframe.multiplier >= 1 ? 60 / timeframe.multiplier
* 7 : timeframe.isintraday and timeframe.multiplier < 60 ? 60 /
timeframe.multiplier * 24 * 7 : 7
res55 = input.timeframe('D', title = 'adjust the gods time frame',
group=GP1thegods)
oo = request.security(syminfo.tickerid, res55, open, barmerge.gaps_off,
barmerge.lookahead_on)
cc3 = request.security(syminfo.tickerid, res55, close, barmerge.gaps_off,
barmerge.lookahead_on)
hzz = request.security(syminfo.tickerid, res55, high, barmerge.gaps_off,
barmerge.lookahead_on)
ll = request.security(syminfo.tickerid, res55, low, barmerge.gaps_off,
barmerge.lookahead_on)
st_mult3 = input.float(0.05, title='edit division', minval=0.05, maxval=4,
step=0.01 , group=GP1thegods)
st_period4 = input.int(4, title='edit multitude factor', minval=1,
group=GP1thegods)
up_lev5 = ll - st_mult3 * ta.atr(st_period4)
dn_lev5 = hzz + st_mult3 * ta.atr(st_period4)
up_trend5 = 0.0
up_trend5 := cc3[1] > up_trend5[1] ? math.max(up_lev5, up_trend5[1]) : up_lev5
down_trend5 = 0.0
down_trend5 := cc3[1] < down_trend5[1] ? math.min(dn_lev5, down_trend5[1]) :
dn_lev5
trend5 = 0
trend5 := cc3 > down_trend5[1] ? 1 : cc3 < up_trend5[1] ? -1 : nz(trend5[1], 1)
st_line5 = trend5 == 1 ? up_trend5 : down_trend5
thegodsbuy = ta.crossover(cc3, st_line5)
thegodssell = ta.crossunder(cc3, st_line5)
long = bull_ht or thegodsbuy
short = sell_ht or thegodssell
dcainput=buy_4
plotshape(showpredictions ? long : na, style=shape.labelup,
location=location.belowbar, color=color.new(color.green, 0), size=size.tiny,
title='Long Entry', text='L', textcolor=color.new(color.white, 0))
plotshape(showpredictions ? short : na, style=shape.labeldown,
location=location.abovebar, color=color.new(color.red, 0), size=size.tiny,
title='Short Entry', text='S', textcolor=color.new(color.white, 0))
long_shortHR1 = 0
long_lastHR1 = long and (nz(long_shortHR1[1]) == 0 or nz(long_shortHR1[1]) == -1)
short_lastHR1 = short and (nz(long_shortHR1[1]) == 0 or nz(long_shortHR1[1]) == 1)
long_shortHR1 := long_lastHR1 ? 1 : short_lastHR1 ? -1 : long_shortHR1[1]
longPriceHR1 = ta.valuewhen(long_lastHR1, close, 0)
shortPriceHR1 = ta.valuewhen(short_lastHR1, close, 0)
longStop_STOPLOSS_HR1 = longPriceHR1 * (1 - stopPerHR1)
shortStop_STOPLOSS_HR1 = shortPriceHR1 * (1 + stopPerHR1)
longTake_TP1_HR1 = longPriceHR1 * (1 + takePerHR1)
shortTake_TP1_HR1 = shortPriceHR1 * (1 - takePerHR1)
longBar1HR1 = ta.barssince(long_lastHR1)
longBar2HR1 = longBar1HR1 >= 1 ? true : false
shortBar1HR1 = ta.barssince(short_lastHR1)
shortBar2HR1 = shortBar1HR1 >= 1 ? true : false
longSLhitHR1 = long_shortHR1 == 1 and longBar2HR1 and low < longStop_STOPLOSS_HR1
shortSLhitHR1 = long_shortHR1 == -1 and shortBar2HR1 and high >
shortStop_STOPLOSS_HR1
longTPhitHR1 = long_shortHR1 == 1 and longBar2HR1 and high > longTake_TP1_HR1
shortTPhitHR1 = long_shortHR1 == -1 and shortBar2HR1 and low < shortTake_TP1_HR1
long_shortHR1 := (long_shortHR1 == 1 or long_shortHR1 == 0) and longBar2HR1 and
(longSLhitHR1 or longTPhitHR1) ? 0 : (long_shortHR1 == -1 or long_shortHR1 == 0)
and shortBar2HR1 and (shortSLhitHR1 or shortTPhitHR1) ? 0 : long_shortHR1
long_shortHR2 = 0
long_lastHR2 = long and (nz(long_shortHR2[1]) == 0 or nz(long_shortHR2[1]) == -1)
short_lastHR2 = short and (nz(long_shortHR2[1]) == 0 or nz(long_shortHR2[1]) == 1)
long_shortHR2 := long_lastHR2 ? 1 : short_lastHR2 ? -1 : long_shortHR2[1]
longPriceHR2 = ta.valuewhen(long_lastHR2, close, 0)
shortPriceHR2 = ta.valuewhen(short_lastHR2, close, 0)
longStop_STOPLOSS_HR2 = longPriceHR2 * (1 - stopPerHR1)
shortStop_STOPLOSS_HR2 = shortPriceHR2 * (1 + stopPerHR1)
longTake_TP2_HR2 = longPriceHR2 * (1 + takePerHR2)
shortTake_TP2_HR2 = shortPriceHR2 * (1 - takePerHR2)
longBar1HR2 = ta.barssince(long_lastHR2)
longBar2HR2 = longBar1HR2 >= 1 ? true : false
shortBar1HR2 = ta.barssince(short_lastHR2)
shortBar2HR2 = shortBar1HR2 >= 1 ? true : false
longSLhitHR2 = long_shortHR2 == 1 and longBar2HR2 and low < longStop_STOPLOSS_HR2
longTPhitHR2 = long_shortHR2 == 1 and longBar2HR2 and high > longTake_TP2_HR2
shortTPhitHR2 = long_shortHR2 == -1 and shortBar2HR2 and low < shortTake_TP2_HR2
long_shortHR2 := (long_shortHR2 == 1 or long_shortHR2 == 0) and longBar2HR2 and
(longSLhitHR2 or longTPhitHR2) ? 0 : (long_shortHR2 == -1 or long_shortHR2 == 0)
and shortBar2HR2 and (shortTPhitHR2) ? 0 : long_shortHR2
long_shortHR3 = 0
long_lastHR3 = long and (nz(long_shortHR3[1]) == 0 or nz(long_shortHR3[1]) == -1)
short_lastHR3 = short and (nz(long_shortHR3[1]) == 0 or nz(long_shortHR3[1]) == 1)
long_shortHR3 := long_lastHR3 ? 1 : short_lastHR3 ? -1 : long_shortHR3[1]
longPriceHR3 = ta.valuewhen(long_lastHR3, close, 0)
shortPriceHR3 = ta.valuewhen(short_lastHR3, close, 0)
longStop_STOPLOSS_HR3 = longPriceHR3 * (1 - stopPerHR1)
shortStop_STOPLOSS_HR3 = shortPriceHR3 * (1 + stopPerHR1)
longTake_TP2_HR3 = longPriceHR3 * (1 + takePerHR3)
shortTake_TP3_HR3 = shortPriceHR3 * (1 - takePerHR3)
longBar1HR3 = ta.barssince(long_lastHR3)
longBar2HR3 = longBar1HR3 >= 1 ? true : false
shortBar1HR3 = ta.barssince(short_lastHR3)
shortBar2HR3 = shortBar1HR3 >= 1 ? true : false
longSLhitHR3 = long_shortHR3 == 1 and longBar2HR3 and low < longStop_STOPLOSS_HR3
longTPhitHR3 = long_shortHR3 == 1 and longBar2HR3 and high > longTake_TP2_HR3
shortTPhitHR3 = long_shortHR3 == -1 and shortBar2HR3 and low < shortTake_TP3_HR3
long_shortHR3 := (long_shortHR3 == 1 or long_shortHR3 == 0) and longBar2HR3 and
(longSLhitHR3 or longTPhitHR3) ? 0 : (long_shortHR3 == -1 or long_shortHR3 == 0)
and shortBar2HR3 and (shortTPhitHR3) ? 0 : long_shortHR3
long_shortDCA1 = 0
long_lastDCA1 = dcainput and (nz(long_shortDCA1[1]) == 0 or nz(long_shortDCA1[1])
== -1)
short_lastDCA1 = short and (nz(long_shortDCA1[1]) == 0 or nz(long_shortDCA1[1]) ==
1)
long_shortDCA1 := long_lastDCA1 ? 1 : short_lastDCA1 ? -1 : long_shortDCA1[1]
longPriceDCA1 = ta.valuewhen(long_lastDCA1, close, 0)
shortPriceDCA1 = ta.valuewhen(short_lastDCA1, close, 0)
longStop_STOPLOSS_DCA1 = longPriceDCA1 * (1 - stopPerDCA1)
shortStop_STOPLOSS_DCA1 = shortPriceDCA1 * (1 + stopPerDCA1)
longTake_TP1_DCA1 = longPriceDCA1 * (1 + takePerDCA1)
shortTake_TP1_DCA1 = shortPriceDCA1 * (1 - takePerDCA1)
longBar1DCA1 = ta.barssince(long_lastDCA1)
longBar2DCA1 = longBar1DCA1 >= 1 ? true : false
shortBar1DCA1 = ta.barssince(short_lastDCA1)
shortBar2DCA1 = shortBar1DCA1 >= 1 ? true : false
longSLhitDCA1 = long_shortDCA1 == 1 and longBar2DCA1 and low <
longStop_STOPLOSS_DCA1
longTPhitDCA1 = long_shortDCA1 == 1 and longBar2DCA1 and high > longTake_TP1_DCA1
long_shortDCA1 := (long_shortDCA1 == 1 or long_shortDCA1 == 0) and longBar2DCA1 and
(longSLhitDCA1 or longTPhitDCA1) ? 0 : (long_shortDCA1 == -1 or long_shortDCA1 ==
0) and shortBar2DCA1 ? 0 : long_shortDCA1
long_shortDCA2 = 0
long_lastDCA2 = dcainput and (nz(long_shortDCA2[1]) == 0 or nz(long_shortDCA2[1])
== -1)
short_lastDCA2 = short and (nz(long_shortDCA2[1]) == 0 or nz(long_shortDCA2[1]) ==
1)
long_shortDCA2 := long_lastDCA2 ? 1 : short_lastDCA2 ? -1 : long_shortDCA2[1]
longPriceDCA2 = ta.valuewhen(long_lastDCA2, close, 0)
shortPriceDCA2 = ta.valuewhen(short_lastDCA2, close, 0)
longStop_STOPLOSS_DCA2 = longPriceDCA2 * (1 - stopPerDCA1)
shortStop_STOPLOSS_DCA2 = shortPriceDCA2 * (1 + stopPerDCA1)
longTake_TP2_DCA2 = longPriceDCA2 * (1 + takePerDCA2)
longBar1DCA2 = ta.barssince(long_lastDCA2)
longBar2DCA2 = longBar1DCA2 >= 1 ? true : false
shortBar1DCA2 = ta.barssince(short_lastDCA2)
shortBar2DCA2 = shortBar1DCA2 >= 1 ? true : false
longSLhitDCA2 = long_shortDCA2 == 1 and longBar2DCA2 and low <
longStop_STOPLOSS_DCA2
longTPhitDCA2 = long_shortDCA2 == 1 and longBar2DCA2 and high > longTake_TP2_DCA2
long_shortDCA2 := (long_shortDCA2 == 1 or long_shortDCA2 == 0) and longBar2DCA2 and
(longSLhitDCA2 or longTPhitDCA2) ? 0 : (long_shortDCA2 == -1 or long_shortDCA2 ==
0) and shortBar2DCA2 ? 0 : long_shortDCA2
long_shortDCA3 = 0
long_lastDCA3 = dcainput and (nz(long_shortDCA3[1]) == 0 or nz(long_shortDCA3[1])
== -1)
short_lastDCA3 = short and (nz(long_shortDCA3[1]) == 0 or nz(long_shortDCA3[1]) ==
1)
long_shortDCA3 := long_lastDCA3 ? 1 : short_lastDCA3 ? -1 : long_shortDCA3[1]
longPriceDCA3 = ta.valuewhen(long_lastDCA3, close, 0)
longStop_STOPLOSS_DCA3 = longPriceDCA3 * (1 - stopPerDCA1)
longTake_TP2_DCA3 = longPriceDCA3 * (1 + takePerDCA3)
longBar1DCA3 = ta.barssince(long_lastDCA3)
longBar2DCA3 = longBar1DCA3 >= 1 ? true : false
shortBar1DCA3 = ta.barssince(short_lastDCA3)
shortBar2DCA3 = shortBar1DCA3 >= 1 ? true : false
longSLhitDCA3 = long_shortDCA3 == 1 and longBar2DCA3 and low <
longStop_STOPLOSS_DCA3
longTPhitDCA3 = long_shortDCA3 == 1 and longBar2DCA3 and high > longTake_TP2_DCA3
long_shortDCA3 := (long_shortDCA3 == 1 or long_shortDCA3 == 0) and longBar2DCA3 and
(longSLhitDCA3 or longTPhitDCA3) ? 0 : (long_shortDCA3 == -1 or long_shortDCA3 ==
0) and shortBar2DCA3 ? 0 : long_shortDCA3
plotshape(showpredictions ? longSLhitHR1 : na, style=shape.labelup,
location=location.belowbar, color=color.new(color.gray, 0), size=size.tiny,
title='L.SL', text=' L❌', textcolor=color.new(color.white, 0))
plotshape(showpredictions ? shortSLhitHR1 : na, style=shape.labeldown,
location=location.abovebar, color=color.new(color.gray, 0), size=size.tiny,
title='S.SL', text=' S❌', textcolor=color.new(color.white, 0))
plotshape(showpredictions ? longTPhitHR1 : na, style=shape.labeldown,
location=location.abovebar, color=color.new(color.purple, 0), size=size.tiny,
title='L.TP1', text='LTP1', textcolor=color.new(color.white, 0))
plotshape(showpredictions ? longTPhitHR2 : na, style=shape.labeldown,
location=location.abovebar, color=color.new(color.purple, 0), size=size.tiny,
title='L.TP2', text='LTP2', textcolor=color.new(color.white, 0))
plotshape(showpredictions ? longTPhitHR3 : na, style=shape.labeldown,
location=location.abovebar, color=color.new(color.purple, 0), size=size.tiny,
title='L.TP3', text='LTP3', textcolor=color.new(color.white, 0))
plotshape(showpredictions ? shortTPhitHR1 : na, style=shape.labelup,
location=location.belowbar, color=color.new(color.yellow, 0), size=size.tiny,
title='S.TP1', text='STP1', textcolor=color.new(color.white, 0))
plotshape(showpredictions ? shortTPhitHR2 : na, style=shape.labelup,
location=location.belowbar, color=color.new(color.yellow, 0), size=size.tiny,
title='S.TP2', text='STP2', textcolor=color.new(color.white, 0))
plotshape(showpredictions ? shortTPhitHR3 : na, style=shape.labelup,
location=location.belowbar, color=color.new(color.yellow, 0), size=size.tiny,
title='S.TP3', text='STP3', textcolor=color.new(color.white, 0))
plot(long_shortHR1 == 1 ? longStop_STOPLOSS_HR1 : na, style=plot.style_circles,join
= true, color=color.new(color.gray, 0), linewidth=3, title='LongSL', display =
display.none, editable=true)
plot(long_shortHR1 == 1 ? longTake_TP1_HR1 : na, style=plot.style_circles,join =
true, color=color.new(color.purple, 0), linewidth=1, title='LongTP1', display =
display.none, editable=true)
plot(long_shortHR2 == 1 ? longTake_TP2_HR2 : na, style=plot.style_circles,join =
true, color=color.new(color.purple, 0), linewidth=1, title='LongTP2', display =
display.none, editable=true)
plot(long_shortHR3 == 1 ? longTake_TP2_HR3 : na, style=plot.style_circles,join =
true, color=color.new(color.purple, 0), linewidth=1, title='LongTP3', display =
display.none, editable=true)
plot(long_shortHR1 == -1 ? shortStop_STOPLOSS_HR1 : na,
style=plot.style_circles,join = true, color=color.new(color.gray, 0), linewidth=3,
title='ShortSL', display = display.none, editable=true)
plot(long_shortHR1 == -1 ? shortTake_TP1_HR1 : na, style=plot.style_circles,join =
true, color=color.new(color.yellow, 0), linewidth=1, title='ShortTP1', display =
display.none, editable=true)
plot(long_shortHR2 == -1 ? shortTake_TP2_HR2 : na, style=plot.style_circles,join =
true, color=color.new(color.yellow, 0), linewidth=1, title='ShortTP2', display =
display.none, editable=true)
plot(long_shortHR3 == -1 ? shortTake_TP3_HR3 : na, style=plot.style_circles,join =
true, color=color.new(color.yellow, 0), linewidth=1, title='ShortTP3', display =
display.none, editable=true)
plotshape(showbearvsbull ? longSLhitDCA1 : na, style=shape.labelup,
location=location.belowbar, color=color.new(color.gray, 0), size=size.tiny,
title='DCAL.SL', text='d❌', textcolor=color.new(color.white, 0))
plotshape(showbearvsbull ? longTPhitDCA1 : na, style=shape.labeldown,
location=location.abovebar, color=color.new(color.blue, 0), size=size.tiny,
title='DCAL.TP1', text='dTP1', textcolor=color.new(color.white, 0))
plotshape(showbearvsbull ? longTPhitDCA2 : na, style=shape.labeldown,
location=location.abovebar, color=color.new(color.blue, 0), size=size.tiny,
title='DCAL.TP2', text='dTP2', textcolor=color.new(color.white, 0))
plotshape(showbearvsbull ? longTPhitDCA3 : na, style=shape.labeldown,
location=location.abovebar, color=color.new(color.blue, 0), size=size.tiny,
title='DCAL.TP3', text='dTP3', textcolor=color.new(color.white, 0))
plotshape(showbearvsbull ? dcainput : na, style=shape.labelup,
location=location.belowbar, color=color.new(color.aqua, 0), size=size.tiny,
title='DCA Entry', text='DCA', textcolor=color.new(color.white, 0))
plot(long_shortDCA1 == 1 ? longStop_STOPLOSS_DCA1 : na,
style=plot.style_circles,join = true, color=color.new(color.red, 0), linewidth=3,
title='LongSLDCA', display = display.none, editable=true)
plot(long_shortDCA1 == 1 ? longTake_TP1_DCA1 : na, style=plot.style_circles,join =
true, color=color.new(color.blue, 0), linewidth=1, title='LongTP1 DCA', display =
display.none, editable=true)
plot(long_shortDCA2 == 1 ? longTake_TP2_DCA2 : na, style=plot.style_circles,join =
true, color=color.new(color.blue, 0), linewidth=1, title='LongTP2 DCA', display =
display.none, editable=true)
plot(long_shortDCA3 == 1 ? longTake_TP2_DCA3 : na, style=plot.style_circles,join =
true, color=color.new(color.blue, 0), linewidth=1, title='LongTP3 DCA', display =
display.none, editable=true)
CALLSONCRACK = long or dcainput
longTPhitHR1input = strategy.position_avg_price * (1 + takePerHR1)
longTPhitHR2input = strategy.position_avg_price * (1 + takePerHR2)
longTPhitHR3input = strategy.position_avg_price * (1 + takePerHR3)
longTPhitDCA1input = strategy.position_avg_price * (1 + takePerDCA1)
longTPhitDCA2input = strategy.position_avg_price * (1 + takePerDCA2)
longTPhitDCA3input = strategy.position_avg_price * (1 + takePerDCA3)
shortTPhitHR1input = strategy.position_avg_price * (1 - takePerHR1)
shortTPhitHR2input = strategy.position_avg_price * (1 - takePerHR2)
shortTPhitHR3input = strategy.position_avg_price * (1 - takePerHR3)
longSLhitHR1input = strategy.position_avg_price * (1 - stopPerDCA1)
shortSLhitHR1input = strategy.position_avg_price * (1 - stopPerHR1)
longSLhitDCA1input = strategy.position_avg_price * (1 - stopPerDCA1)
longCondition = long and showpredictions == true
if (longCondition)
strategy.entry('Long', strategy.long)
shortCondition = short and showpredictions == true
if (shortCondition)
strategy.entry('SHORT', strategy.short)
DCACondition = dcainput and showbearvsbull == true
if (DCACondition)
strategy.entry('DCA', strategy.long)
if (strategy.position_size > 0)
strategy.exit(id="lTP1", limit=longTPhitHR1input, from_entry='Long',
qty_percent=10)
if (strategy.position_size > 0)
strategy.exit(id="lTP2", limit=longTPhitHR2input, from_entry='Long',
qty_percent=10)
if (strategy.position_size > 0)
strategy.exit(id="lTP3", limit=longTPhitHR3input, from_entry='Long')
if (strategy.position_size < 0)
strategy.exit(id="sTP1", limit=shortTPhitHR1input, from_entry='SHORT',
qty_percent=10)
if (strategy.position_size < 0)
strategy.exit(id="sTP2", limit=shortTPhitHR2input, from_entry='SHORT',
qty_percent=10)
if (strategy.position_size < 0)
strategy.exit(id="sTP3", limit=shortTPhitHR3input, from_entry='SHORT')
if (strategy.position_size > 0)
strategy.exit(id="d.TP1", limit=longTPhitDCA1input, from_entry='DCA',
qty_percent=10)
if (strategy.position_size > 0)
strategy.exit(id="d.TP2", limit=longTPhitDCA2input, from_entry='DCA',
qty_percent=10)
if (strategy.position_size > 0)
strategy.exit(id="d.TP3", limit=longTPhitDCA3input, from_entry='DCA')
//if (strategy.position_size < 0)
//strategy.exit(id="lSL", limit=longSLhitHR1input, from_entry='Long')
//if (strategy.position_size < 0)
//strategy.exit(id="sSL", limit=shortSLhitHR1input, from_entry='SHORT')
//if (strategy.position_size < 0)
//strategy.exit(id="dSL", limit=longSLhitDCA1input, from_entry='DCA')

You might also like