pine脚本策略没有显示任何交易



我已经根据renko和每日值编码了一个策略。请注意,每日值被作为指标在策略中的输入。然而,当我将策略添加到图表中时,它会根据plotshape绘制正确的多空信号,但没有交易列表,也没有策略生成的自动多空信号。代码如下:

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Sahil_Trader
//@version=5
strategy("Renko Strat", overlay=true, margin_long=100, margin_short=100)

var firstflag = 0
var r_open = 0.0
var r_close = 0.0
var r_low = 0.0
var r_high = 0.0
var c_color = color.white
var c = 0
timeexit = not na(time("35", "1500-1534")) ? 1 : 0
timeentry = not na(time("10", "0900-0909")) ? 1 : 0
//GETTING THE DAILY ATR
ei = input(close, "ATR")
d_atr = 0.0
if na(ei)
d_atr := d_atr[1]
else
d_atr := ei
//CALCULATING BOX SIZE
box_size = 0.0
box_size := 0.07 * d_atr
//GETTING THE OPEN VALUE OF THE INDEX / SYMBOL
r1_open = 0.0
if timeentry
r_open := open    //FIRST OPEN VALUE OF THE DAY
r_close := close
//RENKO CALCULATIONS

size = 0.0
size := math.abs(close-open)
c := size >= box_size and close > open ? 1 : size >= box_size and close < open ? -1 : 0
if c == 1
r_open := r_close[1]
r_low := r_open
r_close := r_open + box_size
r_high := r_close
c_color := color.green
if c == -1
r_open := r_close[1]
r_high := r_open
r_close := r_open - box_size
r_low := r_close
c_color := color.red
if math.abs(close-open) <= box_size and firstflag == 1 and timeexit == 0

r_open := r_open[1]
r_close := r_close[1]
r_high := r_high[1]
r_low := r_low[1]
c_color := c_color[1]
plotcandle(r_open, r_high, r_low, r_close, title='Title', color = c_color)



if timeexit
c_color := color.yellow
call_entry = 0.0
put_entry = 0.0
callflag = 0
putflag = 0
call = c == 1 and c[1] == 0
put = c == -1 and c[1] == 0


longCondition = call
if (longCondition)
callflag := 1
strategy.entry("Long", strategy.long)
strategy.close("Short")
plotshape(call, style=shape.triangleup, color=color.new(color.blue, 0), location=location.bottom, size=size.small)
strategy.exit("long exit", "Long", profit = 4000 , loss = 1000)
shortCondition = put
if (shortCondition)
strategy.entry("Short", strategy.short)
strategy.close("Long")
strategy.exit("short exit", "Short", profit = 4000 , loss = 1000)
plotshape(put, style=shape.triangledown, color=color.new(color.red, 0), location=location.bottom, size=size.small)
//@version=5
strategy("Renko Strat", overlay=true, margin_long=100, margin_short=100)
// ATR //
atrTimefame = input.timeframe("1D")
length = input.int(title="Length", defval=14, minval=1)
smoothing = input.string(title="Smoothing", defval="RMA", options=["RMA", "SMA", "EMA", "WMA"])
ma_function(source, length) =>
switch smoothing
"RMA" => ta.rma(source, length)
"SMA" => ta.sma(source, length)
"EMA" => ta.ema(source, length)
=> ta.wma(source, length)
atrValue = ma_function(ta.tr(true), length)
atrSecurity = request.security("", atrTimefame, atrValue)
// STRAT //
var firstflag = 0
var r_open = 0.0
var r_close = 0.0
var r_low = 0.0
var r_high = 0.0
var c_color = color.white
var c = 0
timeexit = not na(time("35", "1500-1534")) ? 1 : 0
timeentry = not na(time("10", "0900-0909")) ? 1 : 0
//GETTING THE DAILY ATR
//  ei = input(close, "ATR")
ei = atrSecurity
d_atr = 0.0
if na(ei)
d_atr := d_atr[1]
else
d_atr := ei
//CALCULATING BOX SIZE
box_size = 0.0
box_size := 0.07 * d_atr
//GETTING THE OPEN VALUE OF THE INDEX / SYMBOL
r1_open = 0.0
if timeentry
r_open := open    //FIRST OPEN VALUE OF THE DAY
r_close := close
//RENKO CALCULATIONS

size = 0.0
size := math.abs(close-open)
c := size >= box_size and close > open ? 1 : size >= box_size and close < open ? -1 : 0
if c == 1
r_open := r_close[1]
r_low := r_open
r_close := r_open + box_size
r_high := r_close
c_color := color.green
if c == -1
r_open := r_close[1]
r_high := r_open
r_close := r_open - box_size
r_low := r_close
c_color := color.red
if math.abs(close-open) <= box_size and firstflag == 1 and timeexit == 0

r_open := r_open[1]
r_close := r_close[1]
r_high := r_high[1]
r_low := r_low[1]
c_color := c_color[1]
plotcandle(r_open, r_high, r_low, r_close, title='Title', color = c_color)



if timeexit
c_color := color.yellow
call_entry = 0.0
put_entry = 0.0
callflag = 0
putflag = 0
call = c == 1 and c[1] == 0
put = c == -1 and c[1] == 0


longCondition = call
if (longCondition)
callflag := 1
strategy.entry("Long", strategy.long)
strategy.close("Short")
plotshape(call, style=shape.triangleup, color=color.new(color.blue, 0), location=location.bottom, size=size.small)
strategy.exit("long exit", "Long", profit = 4000 , loss = 1000)
shortCondition = put
if (shortCondition)
strategy.entry("Short", strategy.short)
strategy.close("Long")
strategy.exit("short exit", "Short", profit = 4000 , loss = 1000)
plotshape(put, style=shape.triangledown, color=color.new(color.red, 0), location=location.bottom, size=size.small)

最新更新