random

SoftKill21 · strategy · 23 行 · 点赞 826 · TradingView 原页

本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。

Pine Script

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © SoftKill21
 
//@version=4
strategy(title="random", shorttitle="random", overlay=true, initial_capital = 1000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent , commission_value=0.1 )
UseHAcandles    = input(true, title="Use Heikin Ashi Candles in Algo Calculations")
//
// === /INPUTS ===
 
// === BASE FUNCTIONS ===
 
haClose = UseHAcandles ? security(heikinashi(syminfo.tickerid), timeframe.period, close) : close
haOpen  = UseHAcandles ? security(heikinashi(syminfo.tickerid), timeframe.period, open) : open
haHigh  = UseHAcandles ? security(heikinashi(syminfo.tickerid), timeframe.period, high) : high
haLow   = UseHAcandles ? security(heikinashi(syminfo.tickerid), timeframe.period, low) : low
 
long = haClose > haHigh[1] and haClose > haOpen  and haHigh[1] > haHigh[2] //and close > high[3]
short =  haClose < haOpen and haClose < haLow[1]
strategy.entry("long",1,when=long)
//strategy.entry("short",0,when=short)
strategy.close("long",when=short)
 
//strategy.close_all()

← 返回列表