满足条件后并在Pine Script(Tradingview)中打印了一定数量的条之后进行长时间输入

时间:2019-03-01 04:35:31

标签: trading pine-script tradingview-api

我试图建立一种策略,该策略按照以下条件添加多头头寸:

  1. 形成绿色蜡烛
  2. 如果形成的绿色蜡烛收盘价高于EMA_High
  3. 如果已涂了四支绿色蜡烛

该策略基于34 ema波策略,该策略根据条形图在高,低和关闭时与34 ema的距离来绘制条形的颜色。

我已经使用barsince函数来尝试实现此功能,但是在获取数据和交易时遇到了麻烦。

任何帮助将不胜感激。

// === STRATEGY === //

TP = (200)
SL = (100)
 

 
EMA_len = input(34, title="EMA wave length")
EMA_src = input(close, title="EMA wave length")
EMA_lim = input(4, title="No of green bars") 
 
EMA_High = ema(high, PACLen)
EMA_High_Over = crossover(close, EMA_High)
since_EMA_High_Over = barssince(EMA_High_Over)
 
plot(since_EMA_High_Over)

longCondition = EMA_High_Over and since_EMA_High_Over <= EMA_lim
if (longCondition)
    strategy.entry("Buy", strategy.long)
    strategy.exit("Close", profit = TP, loss = SL)

0 个答案:

没有答案