【问题标题】:Custom Screener on Trading View Pine Script for a List of SymbolsTradingview Pine 脚本中用于交易品种列表的自定义筛选器
【发布时间】:2021-12-24 08:42:15
【问题描述】:

我是 Pine 脚本的初学者。我正在尝试为 25 个符号的固定列表创建自定义筛选器和警报。

筛选器将扫描列表中 15 分钟蜡烛收盘价高于 Pivot 的符号。

我无法找到一种方法来获取前一天的高点、低点、固定交易品种列表的动态收盘价。

我尝试使用 security(syminfo.tickerid,'D',high) 但 syminfo.tickerid 意味着它特定于当前显示的图表

你能帮忙吗?

当日枢轴水平的计算基于:

pivot = (前一天高点 + 前一天低点 + 前一天收盘价)/3。

higherTF = input.timeframe("D") 
prevCloseHTF = request.security(syminfo.tickerid, higherTF, close[1], lookahead=barmerge.lookahead_on) 
prevHighHTF = request.security(syminfo.tickerid, higherTF, high[1], lookahead=barmerge.lookahead_on) 
prevLowHTF = request.security(syminfo.tickerid, higherTF, low[1], lookahead=barmerge.lookahead_on)  
pivot = ( prevHighHTF[1] + prevLowHTF[1] + prevCloseHTF[1] ) / 3

customFunc() => close > pivot  // The close should be the current 15minute candle close

s1  = security('BTCUSD', timeframe.period, customFunc())
s2  = security('ETHUSD', timeframe.period, customFunc())
s3  = security('XRPUSD', timeframe.period, customFunc())
s4  = security('LTCUSD', timeframe.period, customFunc())
s5  = security('USDTUSD', timeframe.period, customFunc())

scr_label = 'Pivot Screener: \n##########\n'

scr_label := s1  ? scr_label + 'BTCUSD\n'  : scr_label
scr_label := s2  ? scr_label + 'ETHUSD\n'  : scr_label
scr_label := s3  ? scr_label + 'XRPUSD\n'  : scr_label
scr_label := s4  ? scr_label + 'LTCUSD\n'  : scr_label
scr_label := s5  ? scr_label + 'USDTUSD\n' : scr_label

alert_message = "Above Pivot : " + scr_label + "\n\n"

// Send an alert
alert(alert_message, freq = alert.freq_once_per_bar_close )

不幸的是,我不知道如何为这 5 个动态计算枢轴信息的固定符号运行 customFunc()。

我在另一个工具中实现了类似的警报系统。概念是一样的。

有一个固定的符号列表,可以使用以下条件进行筛选。如果是真的,我会收到警报。

15 分钟收盘上方每日枢轴警报示例:

Example of the strategy

【问题讨论】:

  • 那么,您在编写pivot 计算时需要帮助吗?
  • 是 @BarisYakut ,我需要使用枢轴公式 pivot = (前一天高点 + 前一天低点 + 前一天收盘价)/3 并确保它计算所有固定的符号列表.这样,当 15 分钟蜡烛高于枢轴水平时,我会收到警报。
  • @BarisYakut 我在另一个工具中实现了类似的警报系统。概念是一样的。我无法在评论中添加图片。请在下面我的答案中找到所附图片。

标签: pine-script algorithmic-trading trading


【解决方案1】:

您可以使用History reference operator 引用历史数据。例如,close[2] 将返回前两根柱线的收盘价。

所以,你的枢轴计算应该是:

pivot = (high[1] + low[1] + close[1])/3

然后在您的security() 调用中使用此变量。

【讨论】:

  • 感谢您的回复。所以例如。 higherTF = input.timeframe("D") prevCloseHTF = request.security(syminfo.tickerid, higherTF, close[1], lookahead=barmerge.lookahead_on) prevHighHTF = request.security(syminfo.tickerid, higherTF, high[1], lookahead=barmerge.lookahead_on) prevLowHTF = request.security(syminfo.tickerid, higherTF, low[1], lookahead=barmerge.lookahead_on) 这里 syminfo.tickerid 表示特定于电视显示的一张图表。但是我需要筛选器来运行固定的预定义符号列表。继续...
  • higherTF = input.timeframe("D") prevCloseHTF = request.security(syminfo.tickerid, higherTF, close[1], lookahead=barmerge.lookahead_on) prevHighHTF = request.security(syminfo.tickerid, higherTF, high[1], lookahead=barmerge.lookahead_on) prevLowHTF = request.security(syminfo.tickerid, higherTF, low[1], lookahead=barmerge.lookahead_on) pivot = ( prevHighHTF[1] + prevLowHTF[1] + prevCloseHTF[1] ) / 3 customFunc() => close > pivot // The close should be the current 15minute candle close. 是这样吗?继续……
  • s1 = security('BTCUSD', timeframe.period, customFunc()) s2 = security('ETHUSD', timeframe.period, customFunc()) s3 = security('XRPUSD', timeframe.period, customFunc()) s4 = security('LTCUSD', timeframe.period, customFunc()) s5 = security('USDTUSD', timeframe.period, customFunc()) 不幸的是,我不知道如何处理这 5 个固定符号,而不是基于显示的电视图表
  • 请编辑您的原始问题并再次说明您的问题或不清楚的地方。 cmets中的代码很难阅读。
  • 我已经更新了原始问题。我希望现在一切都好。
猜你喜欢
  • 1970-01-01
  • 2022-01-24
  • 1970-01-01
  • 2020-11-14
  • 1970-01-01
  • 1970-01-01
  • 2021-08-17
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多