AlgoPoint Pattern Trader-1
AlgoPoint Pattern Trader-1
version = "2.9.4"
import HeWhoMustNotBeNamed/enhanced_ta/8 as enhanced_ta
import daviddtech/DivergencesLibrary/1 as divergence
import sp2432/Debug_Window_Library/5 as console
len1 = 9
len2 = 21
len3 = 55
len4 = 100
len5 = 200
_vwap_on = false
_adx_on = false
_maxtrades_on = false
_rsi_on = false
_mfi_on = false
_flat_on = false
_plot_on = true
LongTradesTip = 'Turn on/off long trades. Perhaps you are overall bearish and wish
to exempt long trades on this asset'
ShortTradesTip = 'Turn on/off short trades. Perhaps you are overall bullish and
wish to exempt long trades on this asset'
useLimitTip = 'Turns on/off the limit exit method. eg: using trail and not setting
a limit exit. Must use trail, or strategy has no exit crite'
trailStopTip = 'Turns on/off the ATR trailing stop exit method. '
FLIPTip = 'Allows a reversal trade. eg. flipping short from a long pos. False will
isolate trades from one another, while true allows an oppo:'
setMaxDrawdownTip = 'Enables max drawdown protection. Enabling this will stop the
bot if the overall strategy drawdown drops below the defines'
RnRTip = 'This sets your risk to reward as a multiple. 1 is stop/limit equal
distance from entry'
RiskMTip = 'Multiplier as a function of the ATR value projected from the calculated
swing high/low. This allows for a buffer for your stop pla'
swinglookbackTip = 'This is your swing lookback. The the number of bars within the
period calculated for lowest or highest value to establish'
maxPercDdTip = 'Risk appetite. Every strategy sees downside. This is how much you
could stomach to allow the bot to lose if you let it run. Strategy stops taking
trades below this level'
atrLenTip = 'Length of the period for the ATR to average'
trailStopSizeTip = 'The ATR multiplier for ATR-based trailing stop. Higher number
yields a higher volatility based risk adjustment from the swing low'
trailSourceTip = 'The price source for calculating ATR trailing stop'
rrExitTip = 'reward (target price) that must hit in order to trigger the trail
expressed as a decimal. eg. 0.5 = 50% to target.'
maTypelTip = 'Sets the moving average type for the first MA'
maType2Tip = 'Sets the maLength1Tipmoving averagetypefor second MA'
maLength1Tip = 'Sets the length for the first MA. (it is likely best to keep MAl '
maLength2Tip = 'Sets the length for the second MA.Is Likely best to keep 422 length
greater Man 02, or a may result in sposte trade'
drawEntryTip = 'Shows the trade entry level'
exitLvlTip = 'Shows level the level that the trailing stop is triggered'
useTimeFilterTip = 'Turns on/off time session filter'
timeSessionTip = 'Time session to ignore trades (useful for ignoring trades during
times you don\'t want to trade.eg. Markets are slow for a'
startTimeTip = ''
endTimeTip = 'End date & time to stop searching for setups for testing beginning
new bot. eg.'
rrexplained = 'R:R (Risk to Reward) is used by default for ATR and HH/LL'
//
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
// >>>>>>>>>>>>>>>>>>>> USER INPUT <<<<<<<<<<<<<<<<<<<<<<<<
//
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
//-----------------------------------------------------------------------------}
// 📊Settings📈
//-----------------------------------------------------------------------------{
_boilerplateVersion = input.string(title='Core Boilerplate Version',
defval=version, options=[version], group='Welcome' )
//-----------------------------------------------------------------------------}
// 💰Take Profit & Stop Loss💰
//-----------------------------------------------------------------------------{
//choiceStrategy = input(title-"Type of Exit / Entry", defval="Enter New Trade Only
if NO running Trades", options= ("Enter New Trade and Exit
typeOfTP = input.string(title='Type of Take Profit', defval='Fixed Percent' ,
options=['Fixed Percent', 'R:R', 'PIPS', 'Custom'], group='💰 TP / SL')
typeOfExit = input.string(title='Type of Stoploss' , defval='Fixed Percent',
options=['Fixed Percent', 'ATR', 'Keltner', 'MA #1', 'MA #2', 'Bollinger Bands',
'Donchian Channel', 'PIPS', 'HH/LL', 'Custom'], group='💰 TP / SL')
enablepercent = typeOfExit == 'Fixed Percent' ? true: false
StopPerLong = input.float(1.6, title='Stop loss Long %', step = 0.1, group = '💰
Fixed Percent - Take Profit / Stoploss')
TakePerLong = input.float (2.8, title='Take Profit Long %', step = 0.1, group = '💰
Fixed Percent - Take Profit / Stoploss')
stopPer = input.float(1.6, title='Stop loss Short %', step = 0.1, group = '💰 Fixed
Percent - Take Profit / Stoploss')
takePer = input.float (2.8, title='Take Profit Short %', step = 0.1, group = '💰
Fixed Percent - Take Profit / Stoploss')
//-----------------------------------------------------------------------------}
// 💪MODE💪
//-----------------------------------------------------------------------------{
hedge_mode = input(false, title= 'hedge Mode', group='💪 MODF')
early_mode = input(false, title= 'Early Exit Mode', group='💪 MODF')
dca_mode = input(false, title= 'Early Exit Mode', group='💪 MODF')
pyramiding_mode = input(false, title= 'Pyramiding Mode', group='💪 MODF')
//-----------------------------------------------------------------------------}
// 🛑ATR Stoploss🛑
//-----------------------------------------------------------------------------{
RiskM = input.float(title='AT Multiplier For Stoploss', defval=1.0, step=0.1,
group='🛑 ATR Stoploss')
atrType = input.string(title='ATR Source', options=['Swing Hich/low', 'Source'],
defval='Source', group='🛑 ATR Stoploss')
atr_srcUpper = input(title='Source Innner ATR Stoploss', defval=close, group='🛑 ATR
Stoploss')
atr_srcLower = input(title='Source lower ATR Stoploss', defval=close, group='🛑 ATR
Stoploss')
swinglookback = input(title='ATR Swing lookback', defval=14, group='🛑 ATR
Stoploss')
//-----------------------------------------------------------------------------}
// 💎Trailing Stop💎
//-----------------------------------------------------------------------------{
trailStop = input.bool(false, 'Use ATR Trailing Stop', group='💎 Trailing Stop',
tooltip=trailStopTip)
trailStopSize = input.float(3.0, 'AIR Trailina Stop MUlTIDITer', step=0.1, group='💎
Trailing Stop', tooltip=trailStopSizeTip)
trailSource = input.string('Close', 'AT Trailing Stop Source', group='💎 Trailing
Stop', tooltip=trailSourceTip, options=['High/low', 'Close', 'Open', 'Keltner',
'Bollinger Bands', 'Donchian Channel'])
activetrail = input.string(title='Activate Trailina?', defval='Instant',
options=['Instant', 'After Hit Threshold %', 'After HIT TP1', 'After HIT TP2'],
group='💎 Trailing Stop')
//-----------------------------------------------------------------------------}
// 🥶Risk Management🥶
//-----------------------------------------------------------------------------{
setMaxDrawdown = input.bool( false, 'Set Max Total DrawDown', group='🥶 Risk
Management', tooltip=setMaxDrawdownTip)
maxPercDd = input.int(20, 'Max Drawdown (%)', group='🥶 Risk Management',
tooltip=maxPercDdTip)
max_intraday_loss_activate = input.bool(false, 'Set Max Intraday Loss', group='🥶
Risk Management')
max_intraday_loss = input.int(20, 'Max Intraday Loss (%)', group='🥶 Risk
Management', tooltip='')
max_cons_loss_days_activate = input.bool(false, 'Set Max Consecutive Days with
Losses', group='🥶 Risk Management')
max_cons_loss_days = input.int(20, 'Max Consecutive Days with Losses', group='🥶
Risk Management')
i_firstLeverage = leverage
i_Maintenance = input.float(0.5, 'Maintenance Margin Rate', group='🥶 Leverage Risk
Management')
//-----------------------------------------------------------------------------}
// 🥶Risk to Reward🥶
//-----------------------------------------------------------------------------{
activate_minrr = input.bool(false, title="Activate Threshold Risk:Reward?",
group="🥶 Risk to Reward Protection")
minrr = input.float(1.0, title="Threshold Risk:Reward", group="🥶 Risk to Reward
Protection")
activate_maxpercent = input.bool(false, title="Activate Max 9", group="🥶 Risk to
Reward Protection")
maxpercent_out = input.string('Do not enter' ,'What if threshold breaks ?',
group="🥶 Risk to Reward Protection", options=['Do not enter', 'Use Percentage
Instead'])
maxpercent = input.float(1.0, title='Threshold Max % SL', group='🥶 Risk to Reward
Protection', step=0.1, tooltip="If Stoploss is above X% on dynamic SL \n Do not
enter = It will not take trade. \n Use Percentage Instead = It ")
RnRShort = profitfactorshort
RnRLong = profitfactorlong
multiProfit = input.bool(false, title= 'Take Multi Profit X3', group= '💰 Multiple
Take Profit Levels')
//-----------------------------------------------------------------------------}
// Trade variables
//-----------------------------------------------------------------------------{
_repaint = input.bool(false, title='Enable Repainting?', group=' Trade variables')
useLimit = input.bool(true, 'Use Limit exit', group=' Trade variables',
tooltip=useLimitTip)
FLIP = input.bool(true, 'Allow Reversal Trades', tooltip=FLIPTip, group=' Trade
variables')
closereverse = input.bool( true, 'Close trade on reverse strateav', group=' Trade
variables', tooltip=FLIPTip)
_getindirect = input.bool( false, 'Wait for confirmation of new entry on reversal',
group=' Trade variables', tooltip=FLIPTip)
waitforconfirmed = input.bool(true, 'Wait for confirmed?', group=' Trade
variables')
//-----------------------------------------------------------------------------}
// 📈 MA STRATEGY 📈
//-----------------------------------------------------------------------------{
_useMA = input.string('Off', "Use Movina Averages? ", group='📈 MA Strateov Settings
📈', tooltip=maTypelTip, options=['Off', 'Close over/under MA5', 'Ordered
MA1,MA2,MA3,MA4.MAS', 'Strict Close over/under MA5', 'Tripple MA MA1,MA2,MA5'])
//-----------------------------------------------------------------------------}
// 🔎 Range Filters 🔎
//-----------------------------------------------------------------------------{
// Sampling per_RFiod
// Settings for 5min chart, BTCUSDC. For Other coin, change the paremeters
// Range Multiplier
mult = input.float(defval=3.0, minval=0.1, title= 'RF Multi', group="🔎 Range
Filter🔎 ", inline="RF1")
src_RF = close
//-----------------------------------------------------------------------------}
// Functional Declarations
//-----------------------------------------------------------------------------{
smoothrng(x, t, m) =>
wper_RF = t*2-1
avrng = ta.ema(math.abs(x - x[1]), t)
smoothrng = ta.ema(avrng, wper_RF) * m
smoothrng
smrng = smoothrng (src_RF, per_RF, mult)
// Range Filter
rngfilt(x, r) =>
rngfilt = x
rngfilt := x > nz(rngfilt[1]) ? x - r < nz(rngfilt [1]) ? nz(rngfilt[1]) : x -
r : x + r > nz(rngfilt[1]) ? nz(rngfilt[1]) : x + r
rngfilt
filt = rngfilt(src_RF, smrng)
// Filter Direction
upward_RF = 0.0
upward_RF := filt > filt[1] ? nz(upward_RF[1]) + 1 : filt < filt[1] ? 0 :
nz(upward_RF[1])
downward_RF = 0.0
downward_RF := filt < filt[1] ? nz (downward_RF[1]) + 1 : filt > filt[1] ? 0 :
nz(downward_RF[1])
// Target Bands
hband = filt + smrng
lband = filt - smrng
//-----------------------------------------------------------------------------}
// VWAP
//-----------------------------------------------------------------------------{
f_vwap_func (vwapSRC, smaSRC, smaLen) =>
valslow = ta.vwap (vwapSRC)
sma_close = ta.ema (smaSRC, smaLen)
is_vwap_below = valslow [1] > sma_close [1]
[valslow, sma_close, is_vwap_below]
//-----------------------------------------------------------------------------}
// RSI
//-----------------------------------------------------------------------------{
f_rsi_func(rsiSource, rsiLength) =>
rsiup = ta.rma (math.max(ta.change (rsiSource), 0), rsiLength)
rsidown = ta.rma(-math.min(ta.change (rsiSource), 0), rsiLength)
rsirsi = rsidown == 0 ? 100 : rsiup == 0 ? 0 : 100 - 100 / (1 + rsiup /
rsidown)
rsivalue = rsirsi[1]
//-----------------------------------------------------------------------------}
// MFI
//-----------------------------------------------------------------------------{
f_mfi(mfiSource, mfiLength) =>
mfiupper = math.sum(volume * (ta.change (mfiSource) <= 0 ? 0: mfiSource),
mfiLength)
mfilower = math.sum(volume * (ta.change (mfiSource) >= 0 ? 0: mfiSource),
mfiLength)
100.0 - 100.0 / (1.0 + mfiupper / mfilower)
//-----------------------------------------------------------------------------}
// ADX
//-----------------------------------------------------------------------------{
f_dirmov (len) =>
up = ta.change (high)
down = -ta.change (low)
plusDM = na(up) ? na : up > down and up > 0 and title == 'AlgoPoint' and
subtitle == 'All Leaked Algos \n Instagram: algopoint \n Website:
algopoint.mysellix.io' and textVPosition == 'middle' and textHPosition == 'center'
and c_title == #b2b5be80 and s_title == 'large' and a_title == 'center' and
c_subtitle == #b2b5be80 and s_subtitle == 'normal' and a_subtitle == 'center' ?
up : 0
minusDM = na(down) ? na: down > up and down > 0 and title == 'AlgoPoint' and
subtitle == 'All Leaked Algos \n Instagram: algopoint \n Website:
algopoint.mysellix.io' and textVPosition == 'middle' and textHPosition == 'center'
and c_title == #b2b5be80 and s_title == 'large' and a_title == 'center' and
c_subtitle == #b2b5be80 and s_subtitle == 'normal' and a_subtitle == 'center' ?
down : 0
truerange = ta.rma(ta.tr, len)
plus = fixnan (100 * ta.rma(plusDM, len) / truerange)
minus = fixnan (100 * ta.rma (minusDM, len) / truerange)
[plus, minus]
f_adx_func(ADXtype,_adxlen,_sadx_min_len,_sadx_max_len,_sadx_inv,_sadx_sm,_dilen,ch
oppyLine) =>
_sadx_up = ta.change (high)
_sadx_down = -ta.change (low)
_sadx_plusDM = na (_sadx_up) ? na : _sadx_up > _sadx_down and _sadx_up > 0 and
title == 'AlgoPoint' and subtitle == 'All Leaked Algos \n Instagram: algopoint \n
Website: algopoint.mysellix.io' and textVPosition == 'middle' and textHPosition ==
'center' and c_title == #b2b5be80 and s_title == 'large' and a_title == 'center'
and c_subtitle == #b2b5be80 and s_subtitle == 'normal' and a_subtitle == 'center' ?
_sadx_up : 1
_sadx_minusDM = na(_sadx_down) ? na : _sadx_down > _sadx_up and _sadx_down > 0
and title == 'AlgoPoint' and subtitle == 'All Leaked Algos \n Instagram:
algopoint \n Website: algopoint.mysellix.io' and textVPosition == 'middle' and
textHPosition == 'center' and c_title == #b2b5be80 and s_title == 'large' and
a_title == 'center' and c_subtitle == #b2b5be80 and s_subtitle == 'normal' and
a_subtitle == 'center' ? _sadx_down : 0
_sadx_truerange = ta.rma (ta.tr, _adxlen)
_sadx_plus = fixnan(100 * ta.rma(_sadx_plusDM, _adxlen) / _sadx_truerange)
_sadx_minus = fixnan (100 * ta.rma(_sadx_minusDM, _adxlen) / _sadx_truerange)
_sadx_sum = _sadx_plus + _sadx_minus
_sadx_adx = 100 * math.abs(_sadx_plus - _sadx_minus) / (_sadx_sum == 0 ? 1 :
_sadx_sum)
_sadx_rsi_adx = ta.rsi(_sadx_adx, _adxlen)
_adx_masa_len = _adxlen
Smoothed_adx_masa_TrueRange = 0.0
Smoothed_adx_masa_TrueRange := nz(Smoothed_adx_masa_TrueRange[1]) -
nz(Smoothed_adx_masa_TrueRange[1]) / _adx_masa_len + _adx_masa_TrueRange
Smoothed_adx_masa_DirectionalMovementPlus = 0.0
Smoothed_adx_masa_DirectionalMovementPlus := nz
(Smoothed_adx_masa_DirectionalMovementPlus [1]) -
nz(Smoothed_adx_masa_DirectionalMovementPlus[1]) / _adx_masa_len +
_adx_masa_DirectionalMovementPlus
Smoothed_adx_masa_DirectionalMovementMinus = 0.0
Smoothed_adx_masa_DirectionalMovementMinus :=
nz(Smoothed_adx_masa_DirectionalMovementMinus[1])-
nz(Smoothed_adx_masa_DirectionalMovementMinus[1]) / _adx_masa_len +
_adx_masa_DirectionalMovementMinus
_adx_masa_DIPlus = Smoothed_adx_masa_DirectionalMovementPlus /
Smoothed_adx_masa_TrueRange * 100
_adx_masa_DIMinus = Smoothed_adx_masa_DirectionalMovementMinus /
Smoothed_adx_masa_TrueRange * 100
_adx_masa_DX = math. abs (_adx_masa_DIPlus - _adx_masa_DIMinus) /
(_adx_masa_DIPlus + _adx_masa_DIMinus) * 100
_adx_masa_ADX = ta.sma(_adx_masa_DX, _adx_masa_len)
_sig = ADXtype == "Stoch" ? _sadx_st : ADXtype == "MasaNakamura" ?
_adx_masa_ADX : f_adx(_dilen, _adxlen)
[_adx_masa_DIPlus,_adx_masa_DIMinus,_sig]
//-----------------------------------------------------------------------------}
// Volumen Flow
//-----------------------------------------------------------------------------{
volume_flow_func(length, coef ,vcoef) =>
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, max
mf = typical - typical[1]
iff_1 = mf < -cutoff ? -vc : 0
vcp = mf > cutoff ? vc : iff_1
//-----------------------------------------------------------------------------}
// Heiken Ashi
//-----------------------------------------------------------------------------{
//heiken ashi //heiken ashi
hq_func() =>
float _haopen = 0
_haclose = (open + high + low + close) / 4
_haopen := na(_haopen[1]) ? (open + close) / 2 : (_haopen[1] + _haclose [1]) /
2
green_ha = _haclose > _haopen
red_ha = _haclose < _haopen
greenToRed_ha = green_ha[1] and red_ha
redToGreen_ha = red_ha[1] and green_ha
float top_haSwing = 0
float bottom_haSwing = 0
//lookback to find the highest high and lowest low poin_haTS in the _haSwings
after the heiken ashi bar c_hanges color
top_haSwing := greenToRed_ha ? math.max(high[2], high[1], high ) :
top_haSwing[1]
bottom_haSwing := redToGreen_ha ? math.min( low[2], low[1], low) :
bottom_haSwing[1]
//trailing stop
float _haTS = 0
_haTS := close < _haTS[1] ? top_haSwing[1] : close > _haTS[1] ?
bottom_haSwing[1] : _haTS
//-----------------------------------------------------------------------------}
// Choppy
//-----------------------------------------------------------------------------{
_choppy_func() =>
col_green = 1
col_green_slow = 1
col_green_slower = 1
col_red = 0
col_red_slow = 0
col_red_slower = 0
col_chop = 0
histo = 10
choppyColor = if close[1] > close[2] and close[2] > close[3] and close[3] >
close[4] and close[4] > close[5] and close[5] > close[6] and title == 'AlgoPoint'
and subtitle == 'All Leaked Algos \n Instagram: algopoint \n Website:
algopoint.mysellix.io' and textVPosition == 'middle' and textHPosition == 'center'
and c_title == #b2b5be80 and s_title == 'large' and a_title == 'center' and
c_subtitle == #b2b5be80 and s_subtitle == 'normal' and a_subtitle == 'center'
col_green
else if close[1] > close[2] and close[2] > close[3] and close[3] > close[4] and
title == 'AlgoPoint' and subtitle == 'All Leaked Algos \n Instagram: algopoint \n
Website: algopoint.mysellix.io' and textVPosition == 'middle' and textHPosition ==
'center' and c_title == #b2b5be80 and s_title == 'large' and a_title == 'center'
and c_subtitle == #b2b5be80 and s_subtitle == 'normal' and a_subtitle == 'center'
col_green_slow
else if close[2] > close[3] and close[3] > close[4] and close[4] > close[5] and
close[5] > close[6] and title == 'AlgoPoint' and subtitle == 'All Leaked Algos \n
Instagram: algopoint \n Website: algopoint.mysellix.io' and textVPosition ==
'middle' and textHPosition == 'center' and c_title == #b2b5be80 and s_title ==
'large' and a_title == 'center' and c_subtitle == #b2b5be80 and s_subtitle ==
'normal' and a_subtitle == 'center'
col_green_slower
else if close[1] > close[2] and close[3] > close[4] and close[4] > close[5] and
close[5] > close[6] and title == 'AlgoPoint' and subtitle == 'All Leaked Algos \n
Instagram: algopoint \n Website: algopoint.mysellix.io' and textVPosition ==
'middle' and textHPosition == 'center' and c_title == #b2b5be80 and s_title ==
'large' and a_title == 'center' and c_subtitle == #b2b5be80 and s_subtitle ==
'normal' and a_subtitle == 'center'
col_green_slower
else if close[1] > close[2] and close[2] > close[3] and close[4] > close[5] and
close[5] > close[6] and title == 'AlgoPoint' and subtitle == 'All Leaked Algos \n
Instagram: algopoint \n Website: algopoint.mysellix.io' and textVPosition ==
'middle' and textHPosition == 'center' and c_title == #b2b5be80 and s_title ==
'large' and a_title == 'center' and c_subtitle == #b2b5be80 and s_subtitle ==
'normal' and a_subtitle == 'center'
col_green_slower
else if close[1] > close[2] and close[2] > close[3] and close[3] > close[4] and
close[5] > close[6] and title == 'AlgoPoint' and subtitle == 'All Leaked Algos \n
Instagram: algopoint \n Website: algopoint.mysellix.io' and textVPosition ==
'middle' and textHPosition == 'center' and c_title == #b2b5be80 and s_title ==
'large' and a_title == 'center' and c_subtitle == #b2b5be80 and s_subtitle ==
'normal' and a_subtitle == 'center'
col_green_slower
else if close[1] > close[2] and close[2] > close[3] and close[3] > close[4] and
close[4] > close[5] and title == 'AlgoPoint' and subtitle == 'All Leaked Algos \n
Instagram: algopoint \n Website: algopoint.mysellix.io' and textVPosition ==
'middle' and textHPosition == 'center' and c_title == #b2b5be80 and s_title ==
'large' and a_title == 'center' and c_subtitle == #b2b5be80 and s_subtitle ==
'normal' and a_subtitle == 'center'
col_green_slower
else if close[1] < close[2] and close[2] < close[3] and close[3] < close[4] and
close[4] < close[5] and close[5] < close[6] and title == 'AlgoPoint' and subtitle
== 'All Leaked Algos \n Instagram: algopoint \n Website: algopoint.mysellix.io' and
textVPosition == 'middle' and textHPosition == 'center' and c_title == #b2b5be80
and s_title == 'large' and a_title == 'center' and c_subtitle == #b2b5be80 and
s_subtitle == 'normal' and a_subtitle == 'center'
col_green
else if close[1] < close[2] and close[2] < close[3] and close[3] < close[4] and
title == 'AlgoPoint' and subtitle == 'All Leaked Algos \n Instagram: algopoint \n
Website: algopoint.mysellix.io' and textVPosition == 'middle' and textHPosition ==
'center' and c_title == #b2b5be80 and s_title == 'large' and a_title == 'center'
and c_subtitle == #b2b5be80 and s_subtitle == 'normal' and a_subtitle == 'center'
col_green_slow
else if close[2] < close[3] and close[3] < close[4] and close[4] < close[5] and
close[5] < close[6] and title == 'AlgoPoint' and subtitle == 'All Leaked Algos \n
Instagram: algopoint \n Website: algopoint.mysellix.io' and textVPosition ==
'middle' and textHPosition == 'center' and c_title == #b2b5be80 and s_title ==
'large' and a_title == 'center' and c_subtitle == #b2b5be80 and s_subtitle ==
'normal' and a_subtitle == 'center'
col_green_slower
else if close[1] < close[2] and close[3] < close[4] and close[4] < close[5] and
close[5] < close[6] and title == 'AlgoPoint' and subtitle == 'All Leaked Algos \n
Instagram: algopoint \n Website: algopoint.mysellix.io' and textVPosition ==
'middle' and textHPosition == 'center' and c_title == #b2b5be80 and s_title ==
'large' and a_title == 'center' and c_subtitle == #b2b5be80 and s_subtitle ==
'normal' and a_subtitle == 'center'
col_green_slower
else if close[1] < close[2] and close[2] < close[3] and close[4] < close[5] and
close[5] < close[6] and title == 'AlgoPoint' and subtitle == 'All Leaked Algos \n
Instagram: algopoint \n Website: algopoint.mysellix.io' and textVPosition ==
'middle' and textHPosition == 'center' and c_title == #b2b5be80 and s_title ==
'large' and a_title == 'center' and c_subtitle == #b2b5be80 and s_subtitle ==
'normal' and a_subtitle == 'center'
col_green_slower
else if close[1] < close[2] and close[2] < close[3] and close[3] < close[4] and
close[5] < close[6] and title == 'AlgoPoint' and subtitle == 'All Leaked Algos \n
Instagram: algopoint \n Website: algopoint.mysellix.io' and textVPosition ==
'middle' and textHPosition == 'center' and c_title == #b2b5be80 and s_title ==
'large' and a_title == 'center' and c_subtitle == #b2b5be80 and s_subtitle ==
'normal' and a_subtitle == 'center'
col_green_slower
else if close[1] < close[2] and close[2] < close[3] and close[3] < close[4] and
close[4] < close[5] and title == 'AlgoPoint' and subtitle == 'All Leaked Algos \n
Instagram: algopoint \n Website: algopoint.mysellix.io' and textVPosition ==
'middle' and textHPosition == 'center' and c_title == #b2b5be80 and s_title ==
'large' and a_title == 'center' and c_subtitle == #b2b5be80 and s_subtitle ==
'normal' and a_subtitle == 'center'
col_green_slower
else
col_chop
histo := choppyColor == col_green or choppyColor == col_green_slow or
choppyColor == col_green_slower ? 10 : 0
main = histo [1] + histo [2] + histo [3] + histo [4] + histo [5] + histo [6] +
histo [7] + histo [8] + histo [9] + histo [10] / 10
//-----------------------------------------------------------------------------}
// Volumen
//-----------------------------------------------------------------------------{
f_vol_func (lookback) =>
mma = ta.ema(close * 1000, lookback)
smma = ta.ema (mma, lookback)
number = averimpet
pow = 3
result = 0.0
for i = 1 to pow - 1 by 1
if i == 1
result := number
result
result += number
result
//-----------------------------------------------------------------------------}
// Simple functions
//-----------------------------------------------------------------------------{
f_security(_symbol, _res, _src, _repaint)=>
request.security(_symbol, _res, _src[_repaint ? 0 : barstate.isrealtime ? 1 :
0])[_repaint ? 0 : barstate.isrealtime ? 0 : 1]
//f_securitymacd(_symbol, repaint => security svmbol.
_crossunder(a, b) =>
ta.crossunder(a, b) [_repaint ? 0 : barstate.isrealtime ? 1 : 0]
_haOpen ( ) =>
haClose = (open + high + low + close) / 4
haOpen = float (na)
haOpen := na(haOpen[1]) ? (open + close) / 2 : (nz(haOpen[1]) + nz(haClose[1]))
/ 2
haOpen
HaOpen = _haOpen ()
// Custom MA function. This alows variable MA selection from the input menu.
Funtion to be rendered later //
//-----------------------------------------------------------------------------}
// Edit here
//-----------------------------------------------------------------------------{
//This is where I add code to create the main strategy
//Full Algo
l= 0.0
trend = 1
trend := nz(trend [1], 1)
trend := trend == 1 and to_down and title == 'AlgoPoint' and subtitle == 'All
Leaked Algos \n Instagram: algopoint \n Website: algopoint.mysellix.io' and
textVPosition == 'middle' and textHPosition == 'center' and c_title == #b2b5be80
and s_title == 'large' and a_title == 'center' and c_subtitle == #b2b5be80 and
s_subtitle == 'normal' and a_subtitle == 'center' ? -1 : trend == -1 and to_up and
title == 'AlgoPoint' and subtitle == 'All Leaked Algos \n Instagram: algopoint \n
Website: algopoint.mysellix.io' and textVPosition == 'middle' and textHPosition ==
'center' and c_title == #b2b5be80 and s_title == 'large' and a_title == 'center'
and c_subtitle == #b2b5be80 and s_subtitle == 'normal' and a_subtitle == 'center' ?
1 : trend
last_trend_up_since = ta.barssince(to_up[1])
low_val = ta.lowest(nz(last_trend_up_since > 0 ? last_trend_up_since : 1, 1))
low_index = bar_index - ta.barssince(low_val == low)
last_trend_down_since = ta.barssince(to_down[1])
high_val = ta.highest(nz(last_trend_down_since > 0 ? last_trend_down_since: 1, 1))
high_index = bar_index - ta.barssince(high_val == high)
if ta.change(trend) != 0
if trend == 1
array.push (low_points_arr, low_val)
array.push (low_index_arr, low_index)
if trend == -1
array.push (high_points_arr, high_val)
array.push (high_index_arr, high_index)
f_get_high(ind) =>
[array.get(high_points_arr, array.size(high_points_arr) - 1 - ind),
array.get(high_index_arr, array.size(high_index_arr) - 1 - ind)]
bu_cond = trend == -1 and h2 > h1 and l1 > l0 and h0 > h1 and close > l1 and title
== 'AlgoPoint' and subtitle == 'All Leaked Algos \n Instagram: algopoint \n
Website: algopoint.mysellix.io' and textVPosition == 'middle' and textHPosition ==
'center' and c_title == #b2b5be80 and s_title == 'large' and a_title == 'center'
and c_subtitle == #b2b5be80 and s_subtitle == 'normal' and a_subtitle == 'center'
be_cond = trend == 1 and l2 < l1 and h1 < h0 and l0 < l1 and close < h1 and title
== 'AlgoPoint' and subtitle == 'All Leaked Algos \n Instagram: algopoint \n
Website: algopoint.mysellix.io' and textVPosition == 'middle' and textHPosition ==
'center' and c_title == #b2b5be80 and s_title == 'large' and a_title == 'center'
and c_subtitle == #b2b5be80 and s_subtitle == 'normal' and a_subtitle == 'center'
if bu_cond and title == 'AlgoPoint' and subtitle == 'All Leaked Algos \n Instagram:
algopoint \n Website: algopoint.mysellix.io' and textVPosition == 'middle' and
textHPosition == 'center' and c_title == #b2b5be80 and s_title == 'large' and
a_title == 'center' and c_subtitle == #b2b5be80 and s_subtitle == 'normal' and
a_subtitle == 'center'and not bu_cond[1]
line.new(h2i, h2, l1i, l1, color=color.green, width=2)
line.new(l1i, l1, h1i, h1, color=color.green, width=2)
line.new(h1i, h1, l0i, l0, color=color.green, width=2)
line.new(l0i, l0, h0i, h0, color=color.green, width=2)
line.new(l1i, l1, bar_index, l1, color=color.green, width=2)
label.new(bar_index, l1, "", style=label.style_label_up, textcolor=color.white,
color=color.green, size=size.tiny)
alert ("Bullish OM!", alert.freq_once_per_bar)
if be_cond and title == 'AlgoPoint' and subtitle == 'All Leaked Algos \n Instagram:
algopoint \n Website: algopoint.mysellix.io' and textVPosition == 'middle' and
textHPosition == 'center' and c_title == #b2b5be80 and s_title == 'large' and
a_title == 'center' and c_subtitle == #b2b5be80 and s_subtitle == 'normal' and
a_subtitle == 'center' and not be_cond [1]
line.new(l2i, l2, h1i, h1, color=color.red, width=2)
line.new(h1i, h1, l1i, l1, color=color.red, width=2)
line.new(l1i, l1, h0i, h0, color=color.red, width=2)
line.new(h0i, h0, l0i, l0, color=color.red, width=2)
line.new(h1i, h1, bar_index, h1, color=color.red, width=2)
label.new(bar_index, h1, "", style=label.style_label_down,
textcolor=color.white, color=color.red, size=size.tiny)
alert ("Bearish OM!", alert.freq_once_per_bar)
enter_long = bu_cond and title == 'AlgoPoint' and subtitle == 'All Leaked Algos \n
Instagram: algopoint \n Website: algopoint.mysellix.io' and textVPosition ==
'middle' and textHPosition == 'center' and c_title == #b2b5be80 and s_title ==
'large' and a_title == 'center' and c_subtitle == #b2b5be80 and s_subtitle ==
'normal' and a_subtitle == 'center' and not bu_cond[1]
enter_short = be_cond and title == 'AlgoPoint' and subtitle == 'All Leaked Algos \n
Instagram: algopoint \n Website: algopoint.mysellix.io' and textVPosition ==
'middle' and textHPosition == 'center' and c_title == #b2b5be80 and s_title ==
'large' and a_title == 'center' and c_subtitle == #b2b5be80 and s_subtitle ==
'normal' and a_subtitle == 'center' and not be_cond[1]
force_exit_signal_short = enter_long
force_exit_signal_long = enter_short
//Custom SL
custom_longStop = 1.0
custom_shortStop = 1.0
custom_longTP = 1.0
custom_shortTP = 1.0
//Dashboard lights
_take_long_one = enter_long
_take_long_two = enter_long
_take_long_three = enter_long
_take_short_one = enter_short
_take_short_two = enter_short
_take_short_three = enter_short
len6 = hmabar
src6 = close
hma = ta.wma(2 * ta.wma(src6, len6 / 2) - ta.wma(src6, len6), math. floor
(math.sqrt (len6) ))
hmacolor = close > hma ? maBull1: maBear2
plot(boolhmabar ? hma : na, title='HMA Line', color=color.new(hmacolor, 65),
linewidth=5)
// EMA 5 EMAs //
price = plot(_useMA != 'Off' ? close : na, title="Close Line", color=color.blue,
display=display.none)
out1 = getMA (maType1, maLength1)
ema1color = (out1 > out1[1] ? maBull1: maBear2)
ema1 = plot (boolmaLength1 ? out1 :na, title="EMA 9", linewidth=3,
color=color.new(ema1color, 50), offset=0, display=display.none)
fill(price, ema1, title="EMA 9 FILL", color=color.new(ema1color, 95),
editable=true)
src2 = close
out2 = getMA (maType2, maLength2)
ema2color = (out2 > out2[1] ? maBull1: maBear2)
ema2 = plot (boolmaLength2 ? out2 :na, title="EMA 21", linewidth=3,
color=color.new(ema2color, 50), offset=0, display=display.none)
fill(price, ema2, title="EMA 21 FILL", color=color.new(ema2color, 95),
editable=true)
src3 = close
out3 = getMA (maType3, maLength3)
ema3color = (out3 > out3[1] ? maBull1: maBear2)
ema3 = plot (boolmaLength3 ? out3 :na, title="EMA 55", linewidth=3,
color=color.new(ema3color, 50), offset=0, display=display.none)
fill(price, ema3, title="EMA 55 FILL", color=color.new(ema3color, 95),
editable=true)
src4 = close
out4 = getMA (maType4, maLength4)
ema4color = (out4 > out4[1] ? maBull1: maBear2)
ema4 = plot (boolmaLength4 ? out4 :na, title="EMA 100", linewidth=3,
color=color.new(ema4color, 50), offset=0, display=display.none)
fill(price, ema4, title="EMA 100 FILL", color=color.new(ema4color, 95),
editable=true)
src5 = close
out5 = getMA (maType5, maLength5)
ema5color = (out5 > out5[1] ? maBull1: maBear2)
ema5 = plot (boolmaLength5 ? out5 :na, title="EMA 200", linewidth=3,
color=color.new(ema5color, 50), offset=0, display=display.none)
fill(price, ema5, title="EMA 200 FILL", color=color.new(ema5color, 95),
editable=true)
longema_ordered = close > out5 and out1 > out2 and out2 > out3 and out4 > out5 and
title == 'AlgoPoint' and subtitle == 'All Leaked Algos \n Instagram: algopoint \n
Website: algopoint.mysellix.io' and textVPosition == 'middle' and textHPosition ==
'center' and c_title == #b2b5be80 and s_title == 'large' and a_title == 'center'
and c_subtitle == #b2b5be80 and s_subtitle == 'normal' and a_subtitle == 'center'
shortema_ordered = close < out5 and out1 < out2 and out2 < out3 and out4 < out5 and
title == 'AlgoPoint' and subtitle == 'All Leaked Algos \n Instagram: algopoint \n
Website: algopoint.mysellix.io' and textVPosition == 'middle' and textHPosition ==
'center' and c_title == #b2b5be80 and s_title == 'large' and a_title == 'center'
and c_subtitle == #b2b5be80 and s_subtitle == 'normal' and a_subtitle == 'center'
long_ema_checked_cross = out1 > out2 and out1[1] < out2[1] and out2 > out5 and out1
> out5 and title == 'AlgoPoint' and subtitle == 'All Leaked Algos \n Instagram:
algopoint \n Website: algopoint.mysellix.io' and textVPosition == 'middle' and
textHPosition == 'center' and c_title == #b2b5be80 and s_title == 'large' and
a_title == 'center' and c_subtitle == #b2b5be80 and s_subtitle == 'normal' and
a_subtitle == 'center'
short_ema_checked_cross = out1 < out2 and out1[1] > out2[1] and out2 < out5 and
out1 < out5 and title == 'AlgoPoint' and subtitle == 'All Leaked Algos \n
Instagram: algopoint \n Website: algopoint.mysellix.io' and textVPosition ==
'middle' and textHPosition == 'center' and c_title == #b2b5be80 and s_title ==
'large' and a_title == 'center' and c_subtitle == #b2b5be80 and s_subtitle ==
'normal' and a_subtitle == 'center'
ema_theema_long := ema_theema_long_1
ema_theema_short := ema_theema_short_1
//-----------------------------------------------------------------------------}
// 🔎 ADX Settings - Extra Filters 🔍
//-----------------------------------------------------------------------------{
enableadx = input.bool(_adx_on, title='Enable ADX ?', group= '🔎 ADX Settings -
Extra Filters 🔍')
ADXtype = input.string( 'Normal', 'ADX Type', group= '🔎 ADX Settings - Extra
Filters 🔍', options=['Normal', 'Stoch', 'MasaNakamura '])
ADXSM = input.string('Static', 'ADX Line Type', group= '🔎 ADX Settings - Extra
Filters 🔍', options=['Static', 'MA', 'EMA', 'SMA', 'HMA', 'WHA', 'DEMA', 'VWMA',
'T3'])
//-----------------------------------------------------------------------------}
// 🔎 TDFI Settings - Extra Filter 🔍
//-----------------------------------------------------------------------------{
volconfirm = input.bool(false, 'Volume confirm?', inline="v1", group='🔎 TDFI
Settings - Extra Filter 🔍' )
_tdfi_version = input.string(title='Version to use?', defval='v1',
options=['v1','v2'], group='🔎 TDFI Settings - Extra Filter 🔍' )
lookback = input(20, title='TDFI Lookback', inline="v1", group='🔎 TDFI Settings -
Extra Filter 🔍')
filterHigh = input.float(0.05, title='Filter High', inline="v2", group='🔎 TDFI
Settings - Extra Filter 🔍')
filterLow = input.float(-0.05, title='Filter low', inline="v2", group='🔎 TDFI
Settings - Extra Filter 🔍', step=0.01)
_tdfiv2_lookback = lookback
_tdfiv2_mmaLength = input (13, title='MMA Length v2', group='🔎 TDFI Settings -
Extra Filter 🔍')
_tdfiv2_mmaMode = input.string(title= 'MMA Mode v2', defval='ema', options=['ema',
' wma', 'swima', 'vwma', 'hull', 'tema'], group='🔎 TDFI Settings - Extra Filter 🔍')
s_tdfiv2_mmaLength = 13
s_tdfiv2_mmaMode = input.string(title= 'SMMA Mode v2', defval='ema',
options=['ema', 'wma', 'swma', 'vwma', 'hull', 'tema'], group='🔎 TDFI Settings -
Extra Filter 🔍')
_tdfiv2_nLength = input(3, title='N Length v2', group='🔎 TDFI Settings - Extra
Filter 🔍')
//-----------------------------------------------------------------------------}
// 🔎 RSI Settings - Extra Filter 🔍
//-----------------------------------------------------------------------------{
enablersi = input.bool(_rsi_on, title='Enable RSI ?', group='RSI Settings - Extra
Filters')
rsiSource = input.source(title= 'RSI Source' , defval=close, group='RSI Settings -
Extra Filters')
rsiLength = input.int(title='RSI Length', defval=14, group='RSI Settings - Extra
Filters')
rsiOverbrought = input.int(title='RSI Overbrought', defval=51, group='RSI Settings
- Extra Filters')
rsiOversold = input.int(title='RSI Oversold', defval=49, group= 'RSI Settings -
Extra Filters')
//-----------------------------------------------------------------------------}
// 🔎 Volumen Settings - Extra Filter 🔍
//-----------------------------------------------------------------------------{
_vf_enable = input.bool( false, title='Enable Volume Flow ?', group='🔎 Volume Flow
- Extra Filters 🔍')
_vf_length = input (130, title='VFI length', group='🔎 Volume Flow - Extra Filters
🔍')
_vf_coef = input(0.2, title='Coef', group='🔎 Volume Flow - Extra Filters 🔍')
_vf_vcoef = input(2.5, title='Max. vol. cutoff', group='🔎 Volume Flow - Extra
Filters 🔍')
//-----------------------------------------------------------------------------}
// 📏 VWAP 📏
//-----------------------------------------------------------------------------{
vwapBreakout = input.bool(_vwap_on, title='Use VWAP / EMA', group= '📏 WWAP
crossover - Extra Filters 📏')
vwapSRC = input.source (close, title= 'VWAP Source', group= '📏 WWAP crossover -
Extra Filters 📏')
smaSRC = input.source (close, title='VWAP Source', group= '📏 WWAP crossover - Extra
Filters 📏')
smaLen = input.int(3, title='VWAP Length', group= '📏 WWAP crossover - Extra Filters
📏')
[valslow, sma_close, is_vwap_below] = f_vwap_func(vwapSRC, smaSRC, smaLen)
//-----------------------------------------------------------------------------}
// 🕐 TIME SESSIONS 🕐
//-----------------------------------------------------------------------------{
useTimeFilter = input.bool( false, 'Use Time Session Filter', group='🕐 Time Filters
🕐', tooltip=useTimeFilterTip)
timezones = input.string( 'GMT+2', 'Timezone', group='🕐 Time Filters 🕐',
options=['GMT-12', 'GMT-11', 'GMT-10', 'GMT-9', 'GMT-8', 'GMT-7', 'GMT-6', 'GMT-5',
'GMT-4', 'GMT-3', 'GMT-2', 'GMT-1', 'GMT', 'GMT+12', 'GMT+11', 'GMT+10', 'GMT+9',
'GMT+8', 'GMT+7', 'GMT+6', 'GMT+5', 'GMT+4', 'GMT+3', 'GMT+2', 'GMT+1'])
timeSession = input.session('9000-0300', 'Tine Session To Ionore Trades', group='🕐
Time Filters 🕐', tooltip=timeSessionTip)
useDateFilter = input.bool( false, 'Use Date Session Filter', group= '🕐 Time
Filters 🕐', tooltip=useTimeFilterTip)
monday = input.bool(true, title= 'Mon', group=' Week Days to enter trade? ',
inline="weekdays")
tuesday = input.bool(true, title='Tue', group=' Week Days to enter trade? ',
inline="weekdays")
wednesday = input.bool(true, title='Wed', group=' Week Days to enter trade?
',inline="weekdays")
thursday = input.bool(true, title= 'Thur', group=' Week Days to enter trade? ',
inline="weekdays")
friday = input.bool(true, title='Fri', group=' Week Days to enter trade?
',inline="weekdays")
saturday = input.bool(true, title='Sat', group=' Week Days to enter trade? ',
inline="weekdays")
sunday = input.bool(true, title='Sun', group=' Week Days to enter trade? ',
inline="weekdays")
//
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
// >>>>>>>>>>>>>>>>>>>> DASHBOARD <<<<<<<<<<<<<<<<<<<<<<<<
//
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
_dd_useDavidd = input (false, title="Use DaviddTech Bot? ", group='Daviddtech Bot')
var color _tableFramel = input.color (color.rgb(100, 100, 100, 100), 'Table Frame',
group='Table', inline= 'Frame', tooltip='Color\nTickness')
var int _tableFrameT = input.int(0, '', minval=0, maxval=10, group= 'Table',
inline='Frame')
var color _tableBorderC = input.color(color.rgb(100, 100, 100, 100), 'Table
Border', group='Table', inline='Border', tooltip='Color\nTickness')
var int _tableBorderT = input.int(2, '', minval=0, maxval=10, group='Table',
inline='Border')
var color _tableBGColor = color.rgb(100, 100, 100, 100)
var bool _hasDarkMode = input.bool(true, 'Dark Mode | Bull | Bear | Notr', group=
'Table' , inline='Color')
var color _colorBull = input.color(color.rgb(3, 77, 64, 0), title='colorBull',
inline='Color', group='Table' )
var color _colorbear = input.color (color.rgb(183, 77, 64, 0), title='colorbear',
inline='Color', group='Table' )
var color _cOLOrOtr = input.color(color.rgb (14, 71, 161, 85), title='colorbear',
group='Table', inline='Color')
//
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
// >>>>>>>>>>>>>>>>>>>> LOGIC <<<<<<<<<<<<<<<<<<<<<<<<
//
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
//-----------------------------------------------------------------------------}
// Range Filter
//-----------------------------------------------------------------------------{
filtcolor = upward_RF > 0 ? color.lime : downward_RF > 0 ? color.red: color.orange
range_filter = upward_RF > 0 ? 1 : downward_RF > 0 ? -1 : 0
filtplot = plot (RFactivate ? filt : na, color=filtcolor, linewidth=3, title='Range
Filter')
//-----------------------------------------------------------------------------}
// Volume Flow
//-----------------------------------------------------------------------------{
//-----------------------------------------------------------------------------}
// Time Sessions
//-----------------------------------------------------------------------------{
ff_color = color.new(color.red, 90)
daysOfWeek = '1234567'
isInSession(sess) =>
na(time (timeframe.period, sess + ':' + daysOfWeek, timezones)) == false
//-----------------------------------------------------------------------------}
// Alerts PANEL
//-----------------------------------------------------------------------------{
//input.text_area (defval = "Hello \nWorld!", title = "Message")
threecommasenter = input.text_area('For Connections with 3rd Party services. In
**Placeholders** \n\n Close : #close# \n TP #LongTP# \n TP1', title='API Enter -
Long', group= 'The Alerts')
threecommasexit =input.text_area('3commas ,alerteron etc', title='API Exit - Long',
group= 'The Alerts')
threecommasenter_short = input.text_area('For Connections with 3rd Party
services. \n **Placeholders** \n\n Close : #close# \n TP #ShortT#', title='API
Enter - Short', group= 'The Alerts')
threecommasexit_short =input.text_area('3commas,alerteron etc', title='API Exit -
Short', group= 'The Alerts')
threecommasexitx1 = input.text_area ('3commas, alerteron etc', title='API First TP
- Long', group= 'The Alerts - Multiple Take Profit Levels')
threecommasexit_shortx1 = input.text_area ('3commas, alerteron etc', title='API
First TP - Short', group= 'The Alerts - Multiple Take Profit Levels')
threecommasexitx2 = input.text_area(' Short', group= 'The Alerts - Multiple Take
Profit Levels', title='API Second TP - Long')
threecommasexit_shortx2 = input.text_area ('3commas, alerteron etc', title='API
Second TP - Short' , group= 'The Alerts - Multiple Take Profit Levels')
threecommasenter := str.tostring(threecommasenter)
threecommasexit := str.tostring(threecommasexit)
threecommasenter_short := str.tostring(threecommasenter_short)
threecommasexit_short := str.tostring(threecommasexit_short)
threecommasexitx1 := str.tostring(threecommasexitx1)
threecommasexit_shortx1 := str.tostring(threecommasexit_shortx1)
threecommasexitx2 := str.tostring(threecommasexitx2)
threecommasexit_short := str.tostring(threecommasexit_shortx2)
//-----------------------------------------------------------------------------}
// VWAP
//-----------------------------------------------------------------------------{
vwap_close_plot = plot(vwapBreakout ? valslow: na, title= 'VWAP close',
color=is_vwap_below ? color.red : color.lime)
sma_close_plot = plot(vwapBreakout ? sma_close : na, title= 'VWAP2
close',color=is_vwap_below ? color.red : color.lime)
fill(vwap_close_plot, sma_close_plot, color=color.new(is_vwap_below ? color.red :
color.lime, 85))
useVwapShort= vwapBreakout ? valslow[1] > sma_close[1] : true
useVwapLong = vwapBreakout ? valslow[1] < sma_close[1] : true
//-----------------------------------------------------------------------------}
// MFI
//-----------------------------------------------------------------------------{
_mfi = f_mfi(mfiSource, mfiLength)[1]
mfishorty = enablemfi ? _mfi > mfiOverbrought : true
mfilongy = enablemfi ? _mfi < mfiOversold : true
//-----------------------------------------------------------------------------}
// ADX
//-----------------------------------------------------------------------------{
[_adx_masa_DIPlus,_adx_masa_DIMinus,_sig]=f_adx_func(ADXtype,_adxlen,_sadx_min_len,
_sadx_max_len,_sadx_inv,_sadx_sm,_dilen,choppyline)
sig_ema = ta.sma(_sig, adxlinelen)
_adxline = ADXSM == "Static" ? adxline : getMAflat(_sig, ADXSM, adxlinelen)
roc_adx = getROC(_adxline, 9 )
adxlongshort = enableadx ? enableadx_roc ? roc_adx >= 0 and _sig > _adxline : _sig
> _adxline : true
DIshorty = enableDI ? _adx_masa_DIPlus < _adx_masa_DIMinus : true
DIlongy = enableDI ? _adx_masa_DIPlus > _adx_masa_DIMinus : true
//-----------------------------------------------------------------------------}
// Heiken Ashi
//-----------------------------------------------------------------------------{
_haTS = hq_func ()
plot (enableha ? _haTS <= 0 ? _haTS[1] : _haTS : na, title='Heiken Ashi Candles',
color=close < _haTS ? color.red : color.green)
//-----------------------------------------------------------------------------}
// Choppy
//-----------------------------------------------------------------------------{
main = _choppy_func()
choppyline := flatmaType == 'Static' ? choppyline : getMAflat(main, flatmaType,
flatmaLength)
line_new = choppyline / 10
//-----------------------------------------------------------------------------}
// MAX TRADE CROSS OVER
//-----------------------------------------------------------------------------{
var countall = 0
numberoftrades = countall
var long_row = 0
var short_row = 0
//-----------------------------------------------------------------------------}
// Invariable Constants
//-----------------------------------------------------------------------------{
// built in functions to make the script more readable when referencing position
conditions //
//-----------------------------------------------------------------------------}
// variable calculations
//-----------------------------------------------------------------------------{
atr = ta.atr(atrLen)
//-----------------------------------------------------------------------------}
// Condition Build
//-----------------------------------------------------------------------------{
_LongEntry = stepThreeLong and not na(atr) and _confirmed
_ShortEntry = stepThreeShort and not na(atr) and _confirmed
validLongEntry = _LongEntry and not na(atr) and useVwapLong and rsilongy and
mfilongy and cmlongy and per_long_row and adxlongshort and volumeLong and longha
and DIlongy and FLAT and RFLong and _vf_long and title == 'AlgoPoint' and subtitle
== 'All Leaked Algos \n Instagram: algopoint \n Website: algopoint.mysellix.io' and
textVPosition == 'middle' and textHPosition == 'center' and c_title == #b2b5be80
and s_title == 'large' and a_title == 'center' and c_subtitle == #b2b5be80 and
s_subtitle == 'normal' and a_subtitle == 'center'
validShortEntry = _ShortEntry and not na(atr) and useVwapShort and rsishorty and
mfishorty and cmshorty and per_short_row and adxlongshort and volumeShort and
shortha and DIshorty and FLAT and RFShort and _vf_short and title == 'AlgoPoint'
and subtitle == 'All Leaked Algos \n Instagram: algopoint \n Website:
algopoint.mysellix.io' and textVPosition == 'middle' and textHPosition == 'center'
and c_title == #b2b5be80 and s_title == 'large' and a_title == 'center' and
c_subtitle == #b2b5be80 and s_subtitle == 'normal' and a_subtitle == 'center'
//-----------------------------------------------------------------------------}
// 3 Commas Keys
//-----------------------------------------------------------------------------{
GoLong = threecommasenter
ExitLong = threecommasexit
Goshort = threecommasenter_short
ExitShort = threecommasexit_short
//-----------------------------------------------------------------------------}
// REVERSAL
//-----------------------------------------------------------------------------{
exit_long = closereverse ? validShortEntry and LONG: false
exit_short = closereverse ? validLongEntry and SHORT: false
if exit_long and LONG[1] and title == 'AlgoPoint' and subtitle == 'All Leaked Algos
\n Instagram: algopoint \n Website: algopoint.mysellix.io' and textVPosition ==
'middle' and textHPosition == 'center' and c_title == #b2b5be80 and s_title ==
'large' and a_title == 'center' and c_subtitle == #b2b5be80 and s_subtitle ==
'normal' and a_subtitle == 'center'
alert (ExitLong, _alertfreq)
if exit_short and SHORT[1] and title == 'AlgoPoint' and subtitle == 'All Leaked
Algos \n Instagram: algopoint \n Website: algopoint.mysellix.io' and textVPosition
== 'middle' and textHPosition == 'center' and c_title == #b2b5be80 and s_title ==
'large' and a_title == 'center' and c_subtitle == #b2b5be80 and s_subtitle ==
'normal' and a_subtitle == 'center'
alert (ExitShort, _alertfreq)
if force_exit_long and LONG[1] and title == 'AlgoPoint' and subtitle == 'All Leaked
Algos \n Instagram: algopoint \n Website: algopoint.mysellix.io' and textVPosition
== 'middle' and textHPosition == 'center' and c_title == #b2b5be80 and s_title ==
'large' and a_title == 'center' and c_subtitle == #b2b5be80 and s_subtitle ==
'normal' and a_subtitle == 'center'
alert (ExitLong, _alertfreq)
if force_exit_short and SHORT[1] and title == 'AlgoPoint' and subtitle == 'All
Leaked Algos \n Instagram: algopoint \n Website: algopoint.mysellix.io' and
textVPosition == 'middle' and textHPosition == 'center' and c_title == #b2b5be80
and s_title == 'large' and a_title == 'center' and c_subtitle == #b2b5be80 and
s_subtitle == 'normal' and a_subtitle == 'center'
alert(ExitShort, _alertfreq)
condmaxdrawdown = setMaxDrawdown ? maxPercDd: 100 // used to set the max draw down,
if used
//-----------------------------------------------------------------------------}
// Trialing Stoploss
//-----------------------------------------------------------------------------{
//Keltner Channel
KlKllength = 20
Klmult = trailStopSize
Kllsrc = close
Kllexp = true
BandsStyle = "Average True Range"
atrKllength = atrLen
Klesma ( source, KlKllength)=>
s = ta.sma (source, KlKllength)
e = ta.ema ( source, KlKllength)
Kllexp ? e : s
//Bollinger Bands
lengthBB = 20
srcBB = close
multBB = trailStopSize
basisBB = ta.sma(srcBB, lengthBB)
devBB = multBB * ta.stdev(srcBB, lengthBB)
upperBB = basisBB + devBB
lowerBB = basisBB - devBB
//DonChian
lengthDC = 20
lowerDC = ta.lowest(lengthDC)
upperDC = ta.highest(lengthDC)
if LONG and trailStop and lookForExit and confirmed and title == 'AlgoPoint' and
subtitle == 'All Leaked Algos \n Instagram: algopoint \n Website:
algopoint.mysellix.io' and textVPosition == 'middle' and textHPosition == 'center'
and c_title == #b2b5be80 and s_title == 'large' and a_title == 'center' and
c_subtitle == #b2b5be80 and s_subtitle == 'normal' and a_subtitle == 'center'
new_atr = atr
trailSrcLong = trailSource == 'Close' ? close : trailSource == 'Open' ? open[1]
: lowestLow
trail = trailSource == 'High/low' or trailSource == 'Close' or trailSource ==
'Open' ? trailSrcLong - new_atr * trailStopSize : trailSource == 'Keltner' ?
kl_lower : trailSource == 'Ballinger Bands' ? lowerBB :trailSource == 'Donchian
Channel' ? lowerDC: trailSrcLong - new_atr * trailStopSize
if SHORT and trailStop and lookForExit and confirmed and title == 'AlgoPoint' and
subtitle == 'All Leaked Algos \n Instagram: algopoint \n Website:
algopoint.mysellix.io' and textVPosition == 'middle' and textHPosition == 'center'
and c_title == #b2b5be80 and s_title == 'large' and a_title == 'center' and
c_subtitle == #b2b5be80 and s_subtitle == 'normal' and a_subtitle == 'center'
new_atr = atr
trailSrcShort = trailSource == 'Close' ? close : trailSource == 'Open' ?
open[1] : highestHigh
trail = trailSource == 'High/low' or trailSource == 'Close' or trailSource ==
'Open' ? trailSrcShort + new_atr * trailStopSize :trailSource == 'Keltner' ?
kl_upper : trailSource =='Bollinger Bands' ? upperBB : trailSource == 'Donchian
Channel' ? upperDC: trailSrcShort + new_atr * trailStopSize
//-----------------------------------------------------------------------------}
// Calculate Stopss
//-----------------------------------------------------------------------------{
longStop = lowestLow - atr * RiskM
shortStop = highestHigh + atr * RiskM
table.cell(textstylist, 0, 0, title, width, height, c_title, a_title,
text_size=s_title, bgcolor=c_bg)
pips_to_price(val) =>
val*100*syminfo.mintick
llhhatr_long = close
llhhatr_short = close
//-----------------------------------------------------------------------------}
// Wich Sroo LOss s
//-----------------------------------------------------------------------------{
llhhatr_long := atrType == "Source" ? atr_srcLower : lowestLow
llhhatr_short := atrType == "Source" ? atr_srcUpper : highestHigh
//-----------------------------------------------------------------------------}
// IF SL > X% then use %
//-----------------------------------------------------------------------------{
short_maxpercentSL = close * (1 + maxpercent)
long_maxpercentSL = close * (1 - maxpercent)
short_continue_maxpercent = true
long_continue_maxpercent = true
//-----------------------------------------------------------------------------}
// Leverage
//-----------------------------------------------------------------------------{
_calculateLeverage(_leverage, _value, _shortSell) =>
_shortSell ? _value * _leverage / (_leverage - 1 + i_Maintenance / 100 *
_leverage) : _leverage * _value / (_leverage + 1 - i_Maintenance / 100 * _leverage)
//-----------------------------------------------------------------------------}
// Take Profit // r:r calcualtion
//-----------------------------------------------------------------------------{
longRisk = close - longStop - slbuffer_long
shortRisk = shortStop - close + slbuffer_short
//-----------------------------------------------------------------------------}
// -> Risk MANAGEMENT
//-----------------------------------------------------------------------------{
krp = strategy.wintrades / strategy.closedtrades
krw = strategy.grossprofit / strategy.wintrades
krl = strategy.grossloss / strategy.losstrades
kr = math. round ( (krp - (1 - krp) / (krw / krl)) * 100 / 100,4)
qty = _net_qty
qtyLong = _net_qty
qtyShort = _net_qty
mm = strategy.equity * (risk / 100)
if marginCal == 'Kelly Ratio'
qty := strategy.equity
if kr > 0 and qty > 0 and title == 'AlgoPoint' and subtitle == 'All Leaked
Algos \n Instagram: algopoint \n Website: algopoint.mysellix.io' and textVPosition
== 'middle' and textHPosition == 'center' and c_title == #b2b5be80 and s_title ==
'large' and a_title == 'center' and c_subtitle == #b2b5be80 and s_subtitle ==
'normal' and a_subtitle == 'center'
// qty := g((strategy.equity*(kr*10)) * leverage / open
//qty := g(strategy. equity * leverage / open / kr
//qty := g(((strategy.equity * (kr×10) ) / close) * leverage / open * 100
qty := g(((strategy.equity) * leverage / open) * ( (kr*10) / 100), 4)
mm := strategy.equity * (kr*10)
qtyLong := qty
qtyShort := qty
qty
// BACKTEST ====================
var bool longCond = na
var bool shortCond = na
if strategy.opentrades == 0
strategy.entry('Long', strategy.long, alert_message =
i_alert_txt_entry_long)
TrailSignal := false
TrailTPstep := 0
PlotTrailPos := false
if strategy.position_size > 0
strategy.exit('TP_L', from_entry = 'Long',alert_message =
i_alert_txt_tp_long, comment_loss = "SL long" , comment_profit = "TP Long", limit =
TrailSLContinue ? na : strategy.position_avg_price * (1 + (TakeProfit/100)), stop =
strategy.position_avg_price * (1 - (StopLoss / 100)))
tplLevel := strategy.position_avg_price * (1 + (TakeProfit/100))
sllLevel := strategy.position_avg_price * (1 - (StopLoss / 100))
if GoToPosL and strategy.position_size > 0
GoToPosL := false
//if GoToPosL and (strategy.opentrades == 0 or strategy.position_size < 0)
// GoToPosL := false
// strategy.entry('Long', strategy.long, alert_message = i_alert_txt_entry_long)
// TrailSignal := false
// TrailTPstep := 0
// PlotTrailPos := false
if shortTrades
if shortCond
if strategy.position_size > 0
strategy.cancel_all()
strategy.close_all(comment = "Close long", alert_message =
i_alert_txt_tp_long)
GoToPosS := true
if strategy.opentrades == 0
strategy.entry('Short', strategy.short, alert_message =
i_alert_txt_entry_short)
TrailSignal := false
TrailTPstep := 0
PlotTrailPos := false
if strategy.position_size < 0
strategy.exit('TP_S', from_entry = 'Short', alert_message =
i_alert_txt_tp_short,comment_loss = "SL Short" , comment_profit = "TP Short", limit
= TrailSLContinue ? na : strategy.position_avg_price * (1 - (TakeProfit/100)), stop
= strategy.position_avg_price * (1 + (StopLoss / 100)))
tpsLevel := strategy.position_avg_price * (1 - (TakeProfit/100))
slsLevel := strategy.position_avg_price * (1 + (StopLoss / 100))
if GoToPosS and strategy.position_size < 0 and title == 'AlgoPoint' and subtitle ==
'All Leaked Algos \n Instagram: algopoint \n Website: algopoint.mysellix.io' and
textVPosition == 'middle' and textHPosition == 'center' and c_title == #b2b5be80
and s_title == 'large' and a_title == 'center' and c_subtitle == #b2b5be80 and
s_subtitle == 'normal' and a_subtitle == 'center'
GoToPosS := false
//if GoToPosS and (strategy.opentrades == 0 or strategy.position_size > 0)
// GoToPosS := false
// strategy.entry('Short', strategy.short, alert_message =
i_alert_txt_entry_short)
// TrailSignal := false
// TrailTPstep := 0
// PlotTrailPos := false
//plot
plotshape(longCond and (strategy.opentrades == 0 or strategy.position_size < 0),
title='Long', style=shape.triangleup, location=location.belowbar,
color=color.new(color.blue, 0), size=size.small, text='',
textcolor=color.new(color.white, 0))
plotshape(shortCond and (strategy.opentrades == 0 or strategy.position_size > 0),
title='Short', style=shape.triangledown, location=location.abovebar,
color=color.new(color.red, 0), size=size.small, text='',
textcolor=color.new(color.white, 0))
//Long
if useTrailSL and strategy.position_size > 0
if TrailSteps == 2
TrailPricePart := (strategy.position_avg_price * (1 +
((TakeProfit/100)/2))) - strategy.position_avg_price
if TrailSignal == false
TrailSLPrice := strategy.position_avg_price * (1 +
((TakeProfit/100)/2))
if PlotTrailPos == false
if showLines
line.new(bar_index,TrailSLPrice,bar_index+ExtendTrailLines,TrailSLPrice,color =
color.green,width = 1)
PlotTrailPos := true
if TrailSteps == 3
TrailPricePart := (strategy.position_avg_price * (1 +
((TakeProfit/100)/3))) - strategy.position_avg_price
if TrailSignal == false
TrailSLPrice := strategy.position_avg_price * (1 +
((TakeProfit/100)/3))
if PlotTrailPos == false
if showLines
line.new(bar_index,TrailSLPrice,bar_index+ExtendTrailLines,TrailSLPrice,color =
color.green,width = 1)
line.new(bar_index,TrailSLPrice+TrailPricePart,bar_index+ExtendTrailLines,TrailSLPr
ice+TrailPricePart,color = color.green,width = 1)
PlotTrailPos := true
if useWicksSL and WickSLcalc and LadderTrail ? high > TrailSLPrice : close >
TrailSLPrice
TrailSignal := true
if useWicksSL and WickSLcalc and LadderTrail ? high > TrailSLPrice : close >
TrailSLPrice
if LadderTrail
if useClosePriceForTrailTP
TrailSLLastPrice := useWicksSL ? high - TrailPricePart : close -
TrailPricePart
else
TrailSLLastPrice := useWicksSL ? high - TrailPricePart :
TrailSLPrice - TrailPricePart
else
TrailSLLastPrice := TrailSLPrice
strategy.cancel_all()
if useTrailTP
if TrailTPstep == 0
strategy.close("Long", comment = "trail TP long", qty_percent = 33,
alert_message = i_alert_txt_trailTP_long)
SecureTrailPrice := TrailSLPrice
TrailTPstep := 1
else
if TrailTPstep == 1 and TrailSteps == 3
strategy.close("Long", comment = "trail TP long", qty_percent =
50, alert_message = i_alert_txt_trailTP2_long)
SecureTrailPrice := TrailSLPrice
TrailTPstep := 2
//Short
if useTrailSL and strategy.position_size < 0
if TrailSteps == 2
TrailPricePart := strategy.position_avg_price -
(strategy.position_avg_price * (1 - ((TakeProfit/100)/2)))
if TrailSignal == false
TrailSLPrice := strategy.position_avg_price * (1 -
((TakeProfit/100)/2))
if PlotTrailPos == false
if showLines
line.new(bar_index,TrailSLPrice,bar_index+ExtendTrailLines,TrailSLPrice,color =
color.red,width = 1)
PlotTrailPos := true
if TrailSteps == 3
TrailPricePart := strategy.position_avg_price -
(strategy.position_avg_price * (1 - ((TakeProfit/100)/3)))
if TrailSignal == false
TrailSLPrice := strategy.position_avg_price * (1 -
((TakeProfit/100)/3))
if PlotTrailPos == false
if showLines
line.new(bar_index,TrailSLPrice,bar_index+ExtendTrailLines,TrailSLPrice,color =
color.red,width = 1)
line.new(bar_index,TrailSLPrice-
TrailPricePart,bar_index+ExtendTrailLines,TrailSLPrice-TrailPricePart,color =
color.red,width = 1)
PlotTrailPos := true
if useWicksSL and WickSLcalc and LadderTrail ? low < TrailSLPrice : close <
TrailSLPrice
TrailSignal := true
if useWicksSL and WickSLcalc and LadderTrail ? low < TrailSLPrice : close <
TrailSLPrice
if LadderTrail
if useClosePriceForTrailTP
TrailSLLastPrice := useWicksSL ? low + TrailPricePart : close +
TrailPricePart
else
TrailSLLastPrice := useWicksSL ? low + TrailPricePart :
TrailSLPrice + TrailPricePart
else
TrailSLLastPrice := TrailSLPrice
strategy.cancel_all()
if useTrailTP
if TrailTPstep == 0
strategy.close("Short", comment = "trail TP short", qty_percent =
33, alert_message = i_alert_txt_trailTP_short)
SecureTrailPrice := TrailSLPrice
TrailTPstep := 1
else
if TrailTPstep == 1 and TrailSteps == 3
strategy.close("Short", comment = "trail TP short", qty_percent
= 50, alert_message = i_alert_txt_trailTP2_short)
SecureTrailPrice := TrailSLPrice
TrailTPstep := 2
TrailSLPrice := TrailSLPrice - TrailPricePart
strategy.exit('TSL_S', from_entry = 'Short', alert_message =
i_alert_txt_tp_short, comment_profit = "TP Short", comment_loss = "trail SL short",
limit = TrailSLContinue ? na : strategy.position_avg_price * (1 -
(TakeProfit/100)), stop = TrailSLLastPrice)