0% found this document useful (1 vote)
666 views7 pages

(Crypto-Scalping) EXTREME Profit Strategy

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 (1 vote)
666 views7 pages

(Crypto-Scalping) EXTREME Profit Strategy

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

//@version=5

strategy(title='[Crypto-Scalping] EXTREME Profit Strategy', shorttitle='[Crypto-


Scalping] EXTREME Profit Strategy', overlay=true, explicit_plot_zorder=true)

// Входные параметры
res = input.timeframe('15', 'TIMEFRAME', group="NON REPAINT")
useRes = input(true, 'Use Alternate Signals')
intRes = input(10, 'Multiplier for Alernate Signals')
basisType = input.string('ALMA', 'MA Type: ', options=['TEMA', 'HullMA', 'ALMA'])
basisLen = input.int(50, 'MA Period', minval=1)
offsetSigma = input.int(5, 'Offset for LSMA / Sigma for ALMA', minval=0)
offsetALMA = input.float(2, 'Offset for ALMA', minval=0, step=0.01)
scolor = input(false, 'Show coloured Bars to indicate Trend?')
delayOffset = input.int(0, 'Delay Open/Close MA', minval=0, step=1, tooltip='Forces
Non-Repainting')
tradeType = input.string('BOTH', 'What trades should be taken : ', options=['LONG',
'SHORT', 'BOTH', 'NONE'])
h = input(false, 'Signals for Heikin Ashi Candles')
swing_length = input.int(10, 'Swing High/Low Length', group='Settings', minval=1,
maxval=50)
history_of_demand_to_keep = input.int(20, 'History To Keep', minval=5, maxval=50)
box_width = input.float(2.5, 'Supply/Demand Box Width', group='Settings', minval=1,
maxval=10, step=0.5)
show_zigzag = input.bool(false, 'Show Zig Zag', group='Visual Settings',
inline='1')
show_price_action_labels = input.bool(false, 'Show Price Action Labels',
group='Visual Settings', inline='2')
supply_color = input.color(#00000000, 'Supply', group='Visual Settings',
inline='3')
supply_outline_color = input.color(#00000000, 'Outline', group='Visual Settings',
inline='3')
demand_color = input.color(#00000000, 'Demand', group='Visual Settings',
inline='4')
demand_outline_color = input.color(#00000000, 'Outline', group='Visual Settings',
inline='4')
bos_label_color = input.color(#00000000, 'BOS Label', group='Visual Settings',
inline='5')
poi_label_color = input.color(#00000000, 'POI Label', group='Visual Settings',
inline='7')
poi_border_color = input.color(#00000000, 'POI border', group='Visual Settings',
inline='7')
swing_type_color = input.color(#00000000, 'Price Action Label', group='Visual
Settings', inline='8')
zigzag_color = input.color(#00000000, 'Zig Zag', group='Visual Settings',
inline='9')

// Функции
f_array_add_pop(array, new_value_to_add) =>
array.unshift(array, new_value_to_add)
array.pop(array)

f_sh_sl_labels(array, swing_type) =>


var string label_text = na
if swing_type == 1
if array.get(array, 0) >= array.get(array, 1)
label_text := 'HH'
else
label_text := 'LH'
label.new(
bar_index - swing_length,
array.get(array,0),
text=label_text,
style=label.style_label_down,
textcolor=swing_type_color,
color=swing_type_color,
size=size.tiny)
else if swing_type == -1
if array.get(array, 0) >= array.get(array, 1)
label_text := 'HL'
else
label_text := 'LL'
label.new(
bar_index - swing_length,
array.get(array,0),
text=label_text,
style=label.style_label_up,
textcolor=swing_type_color,
color=swing_type_color,
size=size.tiny)

f_check_overlapping(new_poi, box_array, atrValue) =>


atr_threshold = atrValue * 2
okay_to_draw = true
for i = 0 to array.size(box_array) - 1
top = box.get_top(array.get(box_array, i))
bottom = box.get_bottom(array.get(box_array, i))
poi = (top + bottom) / 2
upper_boundary = poi + atr_threshold
lower_boundary = poi - atr_threshold
if new_poi >= lower_boundary and new_poi <= upper_boundary
okay_to_draw := false
break
else
okay_to_draw := true
okay_to_draw

f_supply_demand(value_array, bn_array, box_array, label_array, box_type, atrValue)


=>
atr_buffer = atrValue * (box_width / 10)
box_left = array.get(bn_array, 0)
box_right = bar_index
var float box_top = 0.00
var float box_bottom = 0.00
var float poi = 0.00
if box_type == 1
box_top := array.get(value_array, 0)
box_bottom := box_top - atr_buffer
poi := (box_top + box_bottom) / 2
else if box_type == -1
box_bottom := array.get(value_array, 0)
box_top := box_bottom + atr_buffer
poi := (box_top + box_bottom) / 2
okay_to_draw = f_check_overlapping(poi, box_array, atrValue)
if box_type == 1 and okay_to_draw
box.delete(array.get(box_array, array.size(box_array) - 1))
f_array_add_pop(box_array, box.new(left=box_left, top=box_top,
right=box_right, bottom=box_bottom, border_color=supply_outline_color,
bgcolor=supply_color, extend=extend.right, text='SUPPLY',
text_halign=text.align_center, text_valign=text.align_center,
text_color=poi_label_color, text_size=size.small, xloc=xloc.bar_index))
box.delete(array.get(label_array, array.size(label_array) - 1))
f_array_add_pop(label_array, box.new(left=box_left, top=poi,
right=box_right, bottom=poi, border_color=poi_border_color,
bgcolor=poi_border_color, extend=extend.right, text='POI',
text_halign=text.align_left, text_valign=text.align_center,
text_color=poi_label_color, text_size=size.small, xloc=xloc.bar_index))
else if box_type == -1 and okay_to_draw
box.delete(array.get(box_array, array.size(box_array) - 1))
f_array_add_pop(box_array, box.new(left=box_left, top=box_top,
right=box_right, bottom=box_bottom, border_color=demand_outline_color,
bgcolor=demand_color, extend=extend.right, text='DEMAND',
text_halign=text.align_center, text_valign=text.align_center,
text_color=poi_label_color, text_size=size.small, xloc=xloc.bar_index))
box.delete(array.get(label_array, array.size(label_array) - 1))
f_array_add_pop(label_array, box.new(left=box_left, top=poi,
right=box_right, bottom=poi, border_color=poi_border_color,
bgcolor=poi_border_color, extend=extend.right, text='POI',
text_halign=text.align_left, text_valign=text.align_center,
text_color=poi_label_color, text_size=size.small, xloc=xloc.bar_index))

f_sd_to_bos(box_array, bos_array, label_array, zone_type) =>


if zone_type == 1
for i = 0 to array.size(box_array) - 1
level_to_break = box.get_top(array.get(box_array, i))
if close >= level_to_break
copied_box = box.copy(array.get(box_array, i))
f_array_add_pop(bos_array, copied_box)
mid = (box.get_top(array.get(box_array, i)) +
box.get_bottom(array.get(box_array, i))) / 2
box.set_top(array.get(bos_array, 0), mid)
box.set_bottom(array.get(bos_array, 0), mid)
box.set_extend(array.get(bos_array, 0), extend.none)
box.set_right(array.get(bos_array, 0), bar_index)
box.set_text(array.get(bos_array, 0), 'BOS')
box.set_text_color(array.get(bos_array, 0), bos_label_color)
box.set_text_size(array.get(bos_array, 0), size.small)
box.set_text_halign(array.get(bos_array, 0), text.align_center)
box.set_text_valign(array.get(bos_array, 0), text.align_center)
box.delete(array.get(box_array, i))
box.delete(array.get(label_array, i))
if zone_type == -1
for i = 0 to array.size(box_array) - 1
level_to_break = box.get_bottom(array.get(box_array, i))
if close <= level_to_break
copied_box = box.copy(array.get(box_array, i))
f_array_add_pop(bos_array, copied_box)
mid = (box.get_top(array.get(box_array, i)) +
box.get_bottom(array.get(box_array, i))) / 2
box.set_top(array.get(bos_array, 0), mid)
box.set_bottom(array.get(bos_array, 0), mid)
box.set_extend(array.get(bos_array, 0), extend.none)
box.set_right(array.get(bos_array, 0), bar_index)
box.set_text(array.get(bos_array, 0), 'BOS')
box.set_text_color(array.get(bos_array, 0), bos_label_color)
box.set_text_size(array.get(bos_array, 0), size.small)
box.set_text_halign(array.get(bos_array, 0), text.align_center)
box.set_text_valign(array.get(bos_array, 0), text.align_center)
box.delete(array.get(box_array, i))
box.delete(array.get(label_array, i))

f_extend_box_endpoint(box_array) =>
for i = 0 to array.size(box_array) - 1
box.set_right(array.get(box_array, i), bar_index + 100)

// Расчеты
stratRes = timeframe.ismonthly ? str.tostring(timeframe.multiplier * intRes,
'###M') :
timeframe.isweekly ? str.tostring(timeframe.multiplier * intRes, '###W')
:
timeframe.isdaily ? str.tostring(timeframe.multiplier * intRes,
'###D') :
timeframe.isintraday ? str.tostring(timeframe.multiplier * intRes,
'####') :
'60'
src = h ? request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period,
close, lookahead=barmerge.lookahead_off) : close

// Расчет ATR
atrValue = ta.atr(50)

// Расчет зигзагов
swing_high = ta.pivothigh(high, swing_length, swing_length)
swing_low = ta.pivotlow(low, swing_length, swing_length)

// Массивы для зигзагов и зон


var swing_high_values = array.new_float(5, 0.00)
var swing_low_values = array.new_float(5, 0.00)
var swing_high_bns = array.new_int(5, 0)
var swing_low_bns = array.new_int(5, 0)
var current_supply_box = array.new_box(history_of_demand_to_keep, na)
var current_demand_box = array.new_box(history_of_demand_to_keep, na)
var current_supply_poi = array.new_box(history_of_demand_to_keep, na)
var current_demand_poi = array.new_box(history_of_demand_to_keep, na)
var supply_bos = array.new_box(5, na)
var demand_bos = array.new_box(5, na)

// Новый зигзаг
if not na(swing_high)
f_array_add_pop(swing_high_values, swing_high)
f_array_add_pop(swing_high_bns, bar_index[swing_length])
if show_price_action_labels
f_sh_sl_labels(swing_high_values, 1)
f_supply_demand(swing_high_values, swing_high_bns, current_supply_box,
current_supply_poi, 1, atrValue)

else if not na(swing_low)


f_array_add_pop(swing_low_values, swing_low)
f_array_add_pop(swing_low_bns, bar_index[swing_length])
if show_price_action_labels
f_sh_sl_labels(swing_low_values, -1)
f_supply_demand(swing_low_values, swing_low_bns, current_demand_box,
current_demand_poi, -1, atrValue)

f_sd_to_bos(current_supply_box, supply_bos, current_supply_poi, 1)


f_sd_to_bos(current_demand_box, demand_bos, current_demand_poi, -1)
f_extend_box_endpoint(current_supply_box)
f_extend_box_endpoint(current_demand_box)

// Функции для скользящих средних


variant(type, src, len, offSig, offALMA) =>
v1 = ta.sma(src, len)
v2 = ta.ema(src, len)
v3 = 2 * v2 - ta.ema(v2, len)
v4 = 3 * (v2 - ta.ema(v2, len)) + ta.ema(ta.ema(v2, len), len)
v5 = ta.wma(src, len)
v6 = ta.vwma(src, len)
v7 = 0.0
sma_1 = ta.sma(src, len)
v7 := na(v7[1]) ? sma_1 : (v7[1] * (len - 1) + src) / len
v8 = ta.wma(2 * ta.wma(src, len / 2) - ta.wma(src, len),
math.round(math.sqrt(len)))
v9 = ta.linreg(src, len, offSig)
v10 = ta.alma(src, len, offALMA, offSig)
v11 = ta.sma(v1, len)
a1 = math.exp(-1.414 * 3.14159 / len)
b1 = 2 * a1 * math.cos(1.414 * 3.14159 / len)
c2 = b1
c3 = -a1 * a1
c1 = 1 - c2 - c3
v12 = 0.0
v12 := c1 * (src + nz(src[1])) / 2 + c2 * nz(v12[1]) + c3 * nz(v12[2])
type == 'EMA' ? v2 : type == 'DEMA' ? v3 : type == 'TEMA' ? v4 : type ==
'WMA' ? v5 : type == 'VWMA' ? v6 : type == 'SMMA' ? v7 : type == 'HullMA' ? v8 :
type == 'LSMA' ? v9 : type == 'ALMA' ? v10 : type == 'TMA' ? v11 : type == 'SSMA' ?
v12 : v1

// Получение серии для скользящих средних


closeSeries = variant(basisType, close[delayOffset], basisLen, offsetSigma,
offsetALMA)
openSeries = variant(basisType, open[delayOffset], basisLen, offsetSigma,
offsetALMA)

// Получение альтернативной серии для скользящих средних


closeSeriesAlt = useRes ? request.security(syminfo.tickerid, stratRes, closeSeries)
: closeSeries
openSeriesAlt = useRes ? request.security(syminfo.tickerid, stratRes, openSeries) :
openSeries

// Условия для входа и выхода


leTrigger = ta.crossover(closeSeriesAlt, openSeriesAlt)
seTrigger = ta.crossunder(closeSeriesAlt, openSeriesAlt)

// Уровни стоп-лоссов и тейк-профитов


i_lxLvlTP1 = input.float(0.2, 'Level TP1', group = 'RISK', tooltip = '(%) Exit
Level')
i_lxQtyTP1 = input.float(80.0, 'Qty TP1', group = 'RISK', tooltip = '(%) Adjust
trade exit volume')
i_lxLvlTP2 = input.float(0.5, 'Level TP2', group = 'RISK', tooltip = '(%) Exit
Level')
i_lxQtyTP2 = input.float(10.0, 'Qty TP2', group = 'RISK', tooltip = '(%) Adjust
trade exit volume')
i_lxLvlTP3 = input.float(7.0, 'Level TP3', group = 'RISK', tooltip = '(%) Exit
Level')
i_lxQtyTP3 = input.float(2, 'Qty TP3', group = 'RISK', tooltip = '(%) Adjust trade
exit volume')
i_lxLvlSL = input.float(0.5, 'Stop Loss', group = 'RISK', tooltip = '(%) Exit
Level')

// Функции для расчета уровней стоп-лоссов и тейк-профитов


f_tp(_condition, _conditionValue, _leTrigger, _seTrigger, _src, _lxLvlTP, _sxLvlTP)
=>
var float _tpLine = 0.0
_topLvl = _src + (_src * (_lxLvlTP / 100))
_botLvl = _src - (_src * (_sxLvlTP / 100))
_tpLine := _condition[1] != _conditionValue and _leTrigger ? _topLvl :
_condition[1] != -_conditionValue and _seTrigger ? _botLvl :
nz(_tpLine[1])
[_tpLine]

f_cross(_scr1, _scr2, _over) =>


_cross = _over ? _scr1 > _scr2 and _scr1[1] < _scr2[1] :
_scr1 < _scr2 and _scr1[1] > _scr2[1]

// Расчет уровней стоп-лоссов и тейк-профитов


var float condition = 0.0
var float slLine = 0.0
var float entryLine = 0.0

entryLine := leTrigger and condition[1] <= 0.0 ? close :


seTrigger and condition[1] >= 0.0 ? close : nz(entryLine[1])

slTopLvl = close + (close * (i_lxLvlSL / 100))


slBotLvl = close - (close * (i_lxLvlSL / 100))
slLine := condition[1] <= 0.0 and leTrigger ? slBotLvl :
condition[1] >= 0.0 and seTrigger ? slTopLvl : nz(slLine[1])

[tp3Line] = f_tp(condition, 1.2, leTrigger, seTrigger, close, i_lxLvlTP3,


i_lxLvlTP3)
[tp2Line] = f_tp(condition, 1.1, leTrigger, seTrigger, close, i_lxLvlTP2,
i_lxLvlTP2)
[tp1Line] = f_tp(condition, 1.0, leTrigger, seTrigger, close, i_lxLvlTP1,
i_lxLvlTP1)

tp3Long = f_cross(high, tp3Line, true)


tp3Short = f_cross(low, tp3Line, false)
tp2Long = f_cross(high, tp2Line, true)
tp2Short = f_cross(low, tp2Line, false)
tp1Long = f_cross(high, tp1Line, true)
tp1Short = f_cross(low, tp1Line, false)

switch
leTrigger and condition[1] <= 0.0 => condition := 1.0
seTrigger and condition[1] >= 0.0 => condition := -1.0
tp3Long and condition[1] == 1.2 => condition := 1.3
tp3Short and condition[1] == -1.2 => condition := -1.3
tp2Long and condition[1] == 1.1 => condition := 1.2
tp2Short and condition[1] == -1.1 => condition := -1.2
tp1Long and condition[1] == 1.0 => condition := 1.1
tp1Short and condition[1] == -1.0 => condition := -1.1
f_cross(low, slLine, false) and condition[1] >= 1.0 => condition := 0.0
f_cross(high, slLine, true) and condition[1] <= -1.0 => condition := 0.0
leTrigger and condition[1] >= 1.0 => condition := 0.0
seTrigger and condition[1] <= -1.0 => condition := 0.0
longE = leTrigger and condition[1] <= 0.0 and condition == 1.0
shortE = seTrigger and condition[1] >= 0.0 and condition == -1.0
longX = leTrigger and condition[1] >= 1.0 and condition == 0.0
shortX = seTrigger and condition[1] <= -1.0 and condition == 0.0
longSL = f_cross(low, slLine, false) and condition[1] >= 1.0 and condition == 0.0
shortSL = f_cross(high, slLine, true) and condition[1] <= -1.0 and condition == 0.0
longTP3 = tp3Long and condition[1] == 1.2 and condition == 1.3
shortTP3 = tp3Short and condition[1] == -1.2 and condition == -1.3
longTP2 = tp2Long and condition[1] == 1.1 and condition == 1.2
shortTP2 = tp2Short and condition[1] == -1.1 and condition == -1.2
longTP1 = tp1Long and condition[1] == 1.0 and condition == 1.1
shortTP1 = tp1Short and condition[1] == -1.0 and condition == -1.1

// Стратегия
if (tradeType == 'LONG' or tradeType == 'BOTH') and longE
strategy.entry('Long', strategy.long)
strategy.exit('Long TP1', from_entry='Long', qty_percent=i_lxQtyTP1,
limit=tp1Line, stop=slLine)
strategy.exit('Long TP2', from_entry='Long', qty_percent=i_lxQtyTP2,
limit=tp2Line, stop=slLine)
strategy.exit('Long TP3', from_entry='Long', qty_percent=i_lxQtyTP3,
limit=tp3Line, stop=slLine)

if (tradeType == 'SHORT' or tradeType == 'BOTH') and shortE


strategy.entry('Short', strategy.short)
strategy.exit('Short TP1', from_entry='Short', qty_percent=i_lxQtyTP1,
limit=tp1Line, stop=slLine)
strategy.exit('Short TP2', from_entry='Short', qty_percent=i_lxQtyTP2,
limit=tp2Line, stop=slLine)
strategy.exit('Short TP3', from_entry='Short', qty_percent=i_lxQtyTP3,
limit=tp3Line, stop=slLine)

// Условия для выхода


if (tradeType == 'LONG' or tradeType == 'BOTH') and strategy.position_size > 0 and
(shortE or longSL or longTP1 or longTP2 or longTP3)
strategy.close('Long')

if (tradeType == 'SHORT' or tradeType == 'BOTH') and strategy.position_size < 0 and


(longE or shortSL or shortTP1 or shortTP2 or shortTP3)
strategy.close('Short')

You might also like

pFad - Phonifier reborn

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

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


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy