-
Notifications
You must be signed in to change notification settings - Fork 0
/
ohlc-buy-only
31 lines (31 loc) · 1.48 KB
/
ohlc-buy-only
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
//@version=3
strategy("^_^ strategy", shorttitle="^_^", overlay=true, default_qty_type=strategy.percent_of_equity, max_bars_back=420, default_qty_value=100, calc_on_order_fills=true, calc_on_every_tick=true, pyramiding=0)
TP = input(defval=5000.00, title="TargetPoint in $", type=float, step=1)
SL = input(defval=-1000.00, title="StopLoss in $", type=float, step=1)
signal = input(title="Signal Length", type=integer, defval=200)
keh=input(title="HullMA cross",type=integer,defval=200)
long=35,short=35,linebuy=4,linesell=-4,ot=1,p=ohlc4[0]
double_smooth(src, long, short) =>
fist_smooth = ema(src, long)
ema(fist_smooth, short)
pc = change(p)
n2ma=2*wma(p,round(keh/2))
nma=wma(p,keh)
diff=n2ma-nma
sqn=round(sqrt(keh))
n2ma1=2*wma(p[1],round(keh/2))
nma1=wma(p[1],keh)
diff1=n2ma1-nma1
sqn1=round(sqrt(keh))
n1=wma(diff,sqn)
n2=wma(diff1,sqn)
hullbuy=n1>n2 and n1>n2[1]
hullsell=n1<n2 and n1<n2[1]
candlebuy=ohlc4[0]>ohlc4[1] and ohlc4[0]>ohlc4[2] and ohlc4[1]>ohlc4[3]
candlesell=ohlc4[0]<ohlc4[1] and ohlc4[0]<ohlc4[2] and ohlc4[1]<ohlc4[3]
double_smoothed_pc = double_smooth(pc, long, short)
double_smoothed_abs_pc = double_smooth(abs(pc), long, short)
tsi_value = 100 * (double_smoothed_pc / double_smoothed_abs_pc)
strategy.entry("buy", true, na, when = tsi_value>ema(tsi_value, signal) and candlebuy and hullbuy)
// strategy.entry("sell", false, na, when = tsi_value<ema(tsi_value, signal) and candlesell and hullsell)
strategy.close_all(when = strategy.openprofit>TP or strategy.openprofit<SL)