
In this indicator i tried to use some indicators together to get more efficient strategy.
I used supertrend, macd and my old strategy codes together. I use this indicator 1 Hour timeframe be careful, but you can try other timeframes and spot market.

What can you change from the settings window ?

1 = You can change how much dollar for per position
2 = Resolution indicator, I use 1H timeframe because of then I use this 1h
3 = Percent of stop value
4 = Percent of take profit value
5,6 = You can paste your code here for algo trading, for example you created bot from 3commas site you got some code for open and close trades you just paste these codes here and set alarm but DONT FORGET !! write this code when you set alarm {{strategy.order.alert_message}}

You can set alarm like that,
I want to show some photos of strategy

> If the price goes below %stop percent of open price, transactions will stop after bar close.
For example here price two times got 5% (stop percent val) under open price then strategy closed open position.

Price just going up, although trend changed, after that our strategy closed open position to dont take more risk.)
The results of the strategy(BTCUSDT - 1H - Spot Market)

Pine script Codes:
(Dont forget copy @version=5 code)*
//@version=5
strategy('Casper', shorttitle='Casper', overlay=true, calc_on_every_tick=false, pyramiding=2)
Start_Date = input.time(defval=timestamp('1 March 2019 13:30 +0000'), title='Start Date')
End_Date = input.time(defval=timestamp('30 March 2023 19:30 +0000'), title='End Date')
// resolution
dolar = input.float(title='$ Per Action', defval=100)
Resolution = input.string(title='Resolution', defval='07 1h', options=['00 Current', '01 1m', '02 3m', '03 5m', '04 15m', '05 30m', '06 45m', '07 1h', '08 2h', '09 3h', '10 4h', '11 1D', '12 1W', '13 1M'])
res(Resolution) =>
if Resolution == '00 Current'
timeframe.period
else
if Resolution == '01 1m'
'1'
else
if Resolution == '02 3m'
'3'
else
if Resolution == '03 5m'
'5'
else
if Resolution == '04 15m'
'15'
else
if Resolution == '05 30m'
'30'
else
if Resolution == '06 45m'
'45'
else
if Resolution == '07 1h'
'60'
else
if Resolution == '08 2h'
'120'
else
if Resolution == '09 3h'
'180'
else
if Resolution == '10 4h'
'240'
else
if Resolution == '11 1D'
'1D'
else
if Resolution == '12 1W'
'1W'
else
if Resolution == '13 1M'
'1M'
var tb = table.new(position.bottom_right, 1, 1, bgcolor = color.new(color.blue, 90))
if barstate.isfirst
table.cell(tb, 0, 0,
'Developed by ilovealgotrading.com'
,text_size = size.normal
,text_color = color.new(#000000, 20))
stop_seviyesi = input.float(title='% Stop ', defval=5)
Kar_al_seviyesi = input.float(title='% Take Prof', defval=4)
// trendci baslangic
AP2 = input.int(defval=8, title='Ema length', minval=1)
Trail1 = ta.ema(close, AP2)
AF2 = input.float(defval=1, title='Percent', minval=0.1) / 100
SL2 = Trail1 * AF2 // Stop Loss
Trail2 = 0.0
iff_1 = Trail1 > nz(Trail2[1], 0) ? Trail1 - SL2 : Trail1 + SL2
iff_2 = Trail1 < nz(Trail2[1], 0) and Trail1[1] < nz(Trail2[1], 0) ? math.min(nz(Trail2[1], 0), Trail1 + SL2) : iff_1
Trail2 := Trail1 > nz(Trail2[1], 0) and Trail1[1] > nz(Trail2[1], 0) ? math.max(nz(Trail2[1], 0), Trail1 - SL2) : iff_2
// Bar color for trade signal //
Green = Trail1 > Trail2 and close > Trail2 and low > Trail2
Blue = Trail1 > Trail2 and close > Trail2 and low < Trail2
Red = Trail2 > Trail1 and close < Trail2 and high < Trail2
Yellow = Trail2 > Trail1 and close < Trail2 and high > Trail2
// Signals //
Bull = ta.barssince(Green) < ta.barssince(Red)
Bear = ta.barssince(Red) < ta.barssince(Green)
//Trail1 ema ortalamasi
Buy = ta.crossover(Trail1, Trail2)
Sell = ta.crossunder(Trail1, Trail2)
iff_3 = Trail2 > Trail1 ? -1 : 0
SR = Trail1 > Trail2 ? 1 : iff_3
TS1 = plot(Trail1, 'ExMov', style=plot.style_line, color=Trail1 > Trail2 ? color.blue : color.yellow, linewidth=2)
TS2 = plot(Trail2, 'Most', style=plot.style_line, color=Trail1 > Trail2 ? color.green : color.red, linewidth=2)
fill(TS1, TS2, Bull ? color.rgb(76, 175, 79, 80) : color.rgb(255, 82, 82, 80))
// alertcondition(Buy, "AL SİNYALİ", "MOST AL")
// alertcondition(Sell, "SAT SİNYALİ", "MOST SAT")
Long_message = input('Long')
Exit_message = input('Exit')
// dipcik baslangic
length = input(60, title='length_Dipcik')
coef = input(0.2)
vcoef = input(2.5, title='Volume Val')
signalLength = input(5)
smoothVFI = true
ma(x, y) =>
sma_1 = ta.sma(x, y)
smoothVFI ? sma_1 : x
typical = hlc3
inter = math.log(typical) - math.log(typical[1])
vinter = ta.stdev(inter, 30)
cutoff = coef * vinter * close
vave = ta.sma(volume, length)[1]
vmax = vave * vcoef
vc = volume < vmax ? volume : vmax //min( volume, vmax )
mf = typical - typical[1]
iff_4 = mf < -cutoff ? -vc : 0
vcp = mf > cutoff ? vc : iff_4
vfi = ma(math.sum(vcp, length) / vave, 3)
vfima = ta.ema(vfi, signalLength)
d = vfi - vfima
Dipcik_sell = vfima[1] > 0 and vfima < vfima[1] and vfima < 0
sum = 0
for i = 1 to 25 by 1
if vfima[i] < 0
sum += i
sum
Dipcik_oncekibarlari_kontrol = false
if sum >= 325 // art arda gelen geriye donuk sayilarin toplami n*(n+1)/2
Dipcik_oncekibarlari_kontrol := true
Dipcik_oncekibarlari_kontrol
else
Dipcik_oncekibarlari_kontrol := false
Dipcik_oncekibarlari_kontrol
Dipcik_buy = vfima[1] < 0 and vfima > vfima[1] and vfima > 0 and not Dipcik_sell[1] and Dipcik_oncekibarlari_kontrol
// MACD
fastLength = input.int(12, minval=1)
slowLength = input.int(26, minval=1)
macdsignalLength = input.int(9, minval=1)
fastMA = ta.ema(close, fastLength)
slowMA = ta.ema(close, slowLength)
macd = fastMA - slowMA
signal = ta.sma(macd, macdsignalLength)
outMacD = request.security(syminfo.tickerid, res(Resolution), macd)
outSignal = request.security(syminfo.tickerid, res(Resolution), signal)
hist = outMacD - outSignal
yuzde_artis = input(3, title='increase % per bar')
yuzde1 = (close - open) / open * 100 > yuzde_artis
// A / D indicator
ema_uzunluk = input(title='Ema_length', defval=14)
ad = ta.cum(close == high and close == low or high == low ? 0 : (2 * close - low - high) / (high - low) * volume)
ad_ema = ta.ema(ad, ema_uzunluk)
ad_control = ad > ad_ema ? true : false
// Strategy
Date_range = time > Start_Date and time < End_Date
bgcolor(Date_range ? color.rgb(255, 235, 59, 90) : na)
if strategy.opentrades == 0 and Date_range and Trail1 > Trail2 and hist > 0 and Dipcik_buy
strategy.entry('Long0', strategy.long, qty=dolar / close)
if strategy.opentrades == 1 and Date_range and close < strategy.position_avg_price * 0.97 and ta.barssince(strategy.opentrades == 0) > 96
strategy.entry('Long_1', strategy.long, qty=dolar / close)
plot(strategy.position_avg_price, color=color.new(color.yellow, 0), linewidth=2, trackprice=true, show_last=1, title='avg_price')
sum2 = 0
for i = 1 to ta.barssince(strategy.opentrades == 0) by 1
if close[i] >= strategy.position_avg_price * 1.02
sum2 += i
sum2
yuzde2_uzerinde = false
if sum2 > 1 // art arda gelen geriye donuk sayilarin toplami n*(n+1)/2
yuzde2_uzerinde := true
yuzde2_uzerinde
else
yuzde2_uzerinde := false
yuzde2_uzerinde
if yuzde2_uzerinde and Trail2 > Trail1
strategy.exit('Long_Exit', stop=close, alert_message=Exit_message, qty_percent=100)
if close < strategy.position_avg_price * ((100 - stop_seviyesi) / 100)
strategy.exit('Long_Exit', limit=strategy.position_avg_price * ((100 + Kar_al_seviyesi) / 100), stop=strategy.position_avg_price * ((100 - stop_seviyesi) / 100), alert_message=Exit_message, qty_percent=100)
if ta.barssince(strategy.opentrades == 0) > 86 and close < strategy.position_avg_price * 1.03 and close > strategy.position_avg_price * 1.02 and close < Trail2 and strategy.opentrades == 1
strategy.exit('Long_Exit', limit=strategy.position_avg_price * 1.04, stop=Trail2, alert_message=Exit_message, qty_percent=100)
if ta.barssince(strategy.opentrades == 0) > 300
strategy.exit('Long_Exit', limit=strategy.position_avg_price, stop=strategy.position_avg_price * ((100 - stop_seviyesi) / 100), alert_message=Exit_message, qty_percent=100)
if strategy.opentrades == 2 and ta.barssince(strategy.opentrades == 1) < 192
strategy.exit('Long_Exit', limit=strategy.position_avg_price * 1.02, stop=strategy.position_avg_price * ((100 - stop_seviyesi) / 100), alert_message=Exit_message, qty_percent=100)
if strategy.opentrades == 2 and ta.barssince(strategy.opentrades == 1) > 192
strategy.exit('Long_Exit', limit=strategy.position_avg_price, stop=strategy.position_avg_price * ((100 - stop_seviyesi) / 100), alert_message=Exit_message, qty_percent=100)
If you have any problem send message from Telegram