forked from SoYan500/vsvtrend-strategy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVSVTrend.pine
28 lines (22 loc) · 1.08 KB
/
VSVTrend.pine
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
//@version=5
strategy("VSVTrend Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=10)
// === INPUTS ===
show_strategy = input.bool(true, title="Стратегия ВКЛ/ИЗКЛ")
use_supertrend = input.bool(true, title="Supertrend филтър")
atrPeriod = input.int(10, title="ATR период")
factor = input.float(3.0, title="Фактор")
// === SUPER TREND ===
[supertrend, direction] = ta.supertrend(factor, atrPeriod)
plot(use_supertrend ? supertrend : na, color=direction ? color.green : color.red, title="Supertrend")
// === УСЛОВИЯ ЗА ВХОД/ИЗХОД ===
longCond = show_strategy and (direction == 1)
shortCond = show_strategy and (direction == -1)
if (longCond)
strategy.entry("Long", strategy.long)
if (shortCond)
strategy.entry("Short", strategy.short)
// === TP/SL ===
sl = input.float(1.5, title="Стоп Лос (%)") / 100
tp = input.float(3.0, title="Тейк Профит (%)") / 100
strategy.exit("TP/SL Long", from_entry="Long", profit=tp, loss=sl)
strategy.exit("TP/SL Short", from_entry="Short", profit=tp, loss=sl)