如何在特定的时间段内达到高潮和低谷 [英] How to get high and low for a specific time period

查看:11
本文介绍了如何在特定的时间段内达到高潮和低谷的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试写一个策略,在Pinescrip的交易观点,我必须得到的最高和最低值在一定的时间段。比如上午10:00到10:30在文档中,我可以看到时间范围,但不确定如何设置该特定时间段的最高点和最低点。

推荐答案

此代码由this PineCoders FAQ entry修改而来。请注意,HI/LO随着监测时间的推移而发展:

//@version=4
study("Session hi/lo", "", true)
noPlotOutside = input(true, "Don't plot outside of hours")
showHi = input(true, "Show highs")
showLo = input(true, "Show lows")
srcHi = input(high, "Source for Highs")
srcLo = input(low, "Source for Lows")
timeAllowed = input("1000-1030", "Allowed hours", input.session)

// Check to see if we are in allowed hours using session info on all 7 days of the week.
timeIsAllowed = time(timeframe.period, timeAllowed + ":1234567")
var hi = 10e-10
var lo = 10e10
if timeIsAllowed
    // We are entering allowed hours; reset hi/lo.
    if not timeIsAllowed[1]
        hi := srcHi
        lo := srcLo
    else
        // We are in allowed hours; track hi/lo.
        hi := max(srcHi, hi)
        lo := min(srcLo, lo)

plot(showHi and not(noPlotOutside and not timeIsAllowed)? hi : na, "Highs", color.blue, 3, plot.style_circles)
plot(showLo and not(noPlotOutside and not timeIsAllowed)? lo : na, "Lows", color.fuchsia, 3, plot.style_circles)

披露:此答案中的链接指向PineCoders常见问题条目。我是PineCoders社区的成员,我很可能写了那个常见问题条目。PineCoders是一个由TradingView支持的PineCoders志愿者小组,PineCoders的网站完全是教育性的。TradingView和PineCoders都不会从向Pinecoders.com发送流量中获得经济利益,而且该网站不包含任何附属/推荐链接。

这篇关于如何在特定的时间段内达到高潮和低谷的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆