Turtle System

racer8 · strategy · 29 行 · 点赞 786 · 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/
// © racer8
//@version=4
strategy("Turtle System", overlay=true)
 
n = input(55,"Entry Length")
e = input(20,"Exit Length")
 
HI = highest(n)
LO = lowest(n)
hi = highest(e)
lo = lowest(e)
 
if close>HI[1]
    strategy.entry("Buy", strategy.long)
 
if close<LO[1]
    strategy.entry("Sell", strategy.short)
    
if low<lo[1]
    strategy.close("Buy")
 
if high>hi[1]
    strategy.close("Sell")
 
plot(HI,color=color.lime)
plot(LO,color=color.red)
plot(hi,color=color.blue)
plot(lo,color=color.maroon)

← 返回列表