砖型计数策略

Author: 雨幕(youquant), Date: 2022-06-13 10:19:09
Tags: IFF

砖形指标

策略回测

img

img

img


/*backtest
start: 2022-01-01 09:00:00
end: 2022-06-12 15:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_CTP","currency":"FUTURES"}]
args: [["ContractType","hc888",360008]]
*/
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/

//@version=4
study("Renko count", overlay=false) 


counter_green = iff(close > open, 1, 0)
counter_red = iff(close > open, 0, 1)

size = iff(bar_index>39, 40, bar_index+1)
// function to create a rolling sum and return an integer value using series and series objects

pine_sum(x, y) =>
    sum = 0.0
    for i = 0 to y - 1
        sum := sum + x[i]

brick_red = pine_sum(counter_red, size)
brick_green = pine_sum(counter_green, size)
if cross(brick_red, brick_green)
    label.new(bar_index, brick_red, style = label.style_arrowdown, size = size.normal, xloc =xloc.bar_index, color = color.green)

plot(brick_red, color = color.red)
plot(brick_green, color = color.green)
if brick_red
   strategy.entry("buy", strategy.long)
else if brick_green
    strategy.entry("sell", strategy.short)


相关内容

更多内容