senpai

Senpai_Strat_3

58
Binary Option --- Only for Range Trade (1 minute Frame)
Mã nguồn mở

Với tinh thần TradingView, tác giả của tập lệnh này đã xuất bản nó dưới dạng mã nguồn mở, vì vậy các nhà giao dịch có thể hiểu và xác minh nó. Chúc mừng tác giả! Bạn có thể sử dụng mã này miễn phí, nhưng việc sử dụng lại mã này trong một ấn phẩm chịu sự điều chỉnh của Nội quy nội bộ. Bạn có thể yêu thích nó để sử dụng nó trên biểu đồ.

Thông báo miễn trừ trách nhiệm

Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.

Bạn muốn sử dụng tập lệnh này trên biểu đồ?
//@version=2
//Based on Senpai BO 3
strategy(title="Senpai_Strat_3", shorttitle="Senpai_Strat_3", overlay=false, default_qty_type=strategy.percent_of_equity, default_qty_value=100)
src = close

//psar
start = input(0.02)
increment = input(0.02)
maximum = input(0.2)
psar = sar(start, increment, maximum)


//ADX Init
adxlen = input(30, title="ADX Smoothing")	
dilen = input(30, title="DI Length")	
dirmov(len) =>	
	up = change(high)
	down = -change(low)
	truerange = rma(tr, len)
	plus = fixnan(100 * rma(up > down and up > 0 ? up : 0, len) / truerange)
	minus = fixnan(100 * rma(down > up and down > 0 ? down : 0, len) / truerange)
	[plus, minus]
	
adx(dilen, adxlen) => 	
	[plus, minus] = dirmov(dilen)
	sum = plus + minus
	adx = 100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)
	[adx, plus, minus]
	
[sig, up, down] = adx(dilen, adxlen)	


// BB Init
source = close
length = input(50, minval=1)
mult = input(0.5, title="Mult Factor", minval=0.001, maxval=50)
alertLevel=input(0.1)
impulseLevel=input(0.75)
showRange = input(false, type=bool)


//RSI CODE
up1 = rma(max(change(src), 0), 14)
down1 = rma(-min(change(src), 0), 14)
rsi = down1 == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up1 / down1))


//BB CODE
basis = sma(source, length)
dev = mult * stdev(source, length)
upper = basis + dev
lower = basis - dev
bbr = source>upper?(((source-upper)/(upper-lower))/10): source<lower?(((source-lower)/(upper-lower))/10) : 0.05
bbi = bbr - nz(bbr[1]) 

//////////////////// Algo

//if (rsi>50 and n1>n2)
   //strategy.exit("Close", "Short")
  // strategy.entry("Long", strategy.long)
//if (rsi<50 and n2>n1)
   //strategy.exit("Close", "Long")
//   strategy.entry("Short", strategy.short)

//col = ma30 > ma50 > ma200 and rsi <=53?lime: ma50 < ma200  and rsi >= 60?red : silver
//short1 =  sig<18.5 and high>=upper and rsi>=70 and psar<close = 100%
//long1 = sig<18.5 and low<=lower and rsi<=30 and psar>close = 100%
short1 =  sig<18.5 and high>=upper and rsi>=70 and psar<close
long1 = sig<18.5 and low<=lower and rsi<=30 and psar>close

//Entry

long = long1[1] == 0 and long1 == 1
short = short1[1] == 0 and short1 == 1
longclose = long[3] == 1
shortclose = short[3] == 1
strategy.entry("short", strategy.short,qty = 10,oca_type = strategy.oca.cancel, when=short)
strategy.entry("long", strategy.long,qty=10,oca_type = strategy.oca.cancel, when=long)
strategy.close("long",when=longclose)
strategy.close("short",when=shortclose)



/////////////////////
///PLOT

plot(long,"long",color=green,linewidth=1)
plot(short,"short",color=red,linewidth=1)
plot(longclose,"close",color=blue,linewidth=1)
plot(shortclose,"close",color=orange,linewidth=1)


//plot(short,"short",color=red,linewidth=1)
//

//strategy.exit(id="long",qty = 100000,when=longclose)
//strategy.exit(id="short",qty = 100000,when=shortclose)

//strategy.exit(id="Stop", profit = 20, loss = 100)