Scalping Trading System Crypto and Stocks

exlux · strategy · 56 行 · 点赞 3,418 · 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/
// © exlux99
 
//@version=5
strategy(title="Scalping Trading System Crypto and Stocks", overlay=true)
src = input(low, title="Source")
 
//sma and ema
len = input.int(25, minval=1, title="Length SMA" , group="Moving Averages")
len2 = input.int(200, minval=1, title="Length EMA", group="Moving Averages")
 
out = ta.sma(src, len)
out2 = ta.ema(src, len2)
 
 
//keltner
lengthk = input.int(10, minval=1, title="Length Keltner Channel",group="Keltner")
mult = input(2.0, "Multiplier",group="Keltner")
BandsStyle = input.string("Average True Range", options = ["Average True Range", "True Range", "Range"], title="Bands Style",group="Keltner")
atrlength = input(14, "ATR Length",group="Keltner")
 
ma = ta.sma(src, lengthk)
rangema = BandsStyle == "True Range" ? ta.tr(true) : BandsStyle == "Average True Range" ? ta.atr(atrlength) : ta.rma(high - low, lengthk)
upper = ma + rangema * mult
lower = ma - rangema * mult
 
//stoch
periodK = input.int(10, title="%K Length", minval=1,group="Stochastic")
smoothK = input.int(1, title="%K Smoothing", minval=1,group="Stochastic")
periodD = input.int(1, title="%D Smoothing", minval=1,group="Stochastic")
k = ta.sma(ta.stoch(close, high, low, periodK), smoothK)
d = ta.sma(k, periodD)
 
//macd 1
fast_length = input(title="Fast Length MACD", defval=4,group="MACD Fast")
slow_length = input(title="Slow Length MACD", defval=34,group="MACD Fast")
signal_length = input.int(title="Signal Smoothing MACD",  minval = 1, maxval = 50, defval = 5,group="MACD Fast")
sma_source = input.string(title="Oscillator MA Type MACD",  defval="EMA", options=["SMA", "EMA"],group="MACD Fast")
sma_signal = input.string(title="Signal Line MA Type MACD", defval="EMA", options=["SMA", "EMA"],group="MACD Fast")
 
fast_ma = sma_source == "SMA" ? ta.sma(src, fast_length) : ta.ema(src, fast_length)
slow_ma = sma_source == "SMA" ? ta.sma(src, slow_length) : ta.ema(src, slow_length)
macd = fast_ma - slow_ma
signal = sma_signal == "SMA" ? ta.sma(macd, signal_length) : ta.ema(macd, signal_length)
hist = macd - signal
 
 
 
 
long= close > out and close < upper and close > lower and hist < 0 and k < 50 and close > out2 
 
short= close < out and close < upper and close > lower and hist > 0 and k > 50 and close < out2 
 
strategy.entry("long",strategy.long,when= long)
 
strategy.entry("short",strategy.short,when=short)

← 返回列表