只是玩玩,学习如何写策略。我现在试的是(伪码).
if(previousCandle == red
... AND previousCandle.high >= sma
... AND previousCandle.low <= sma
... AND currentPrice > previousCandle.high)
enter trade
我在松树剧本里的是..。
redTouch = close < open and high >= ma and low <= ma
longCond = redTouch[
我正在试着检查过去的n蜡烛是否是同一类型的。
例如,之前的五支蜡烛都是看涨的,还是都看跌。
在我的方法中,任何连续的蜡烛都不符合条件
如果之前的n个蜡烛都是蓝色或绿色的,我该如何开始检查一个蜡烛序列呢?
提前感谢大家。
我也愿意尝试任何其他可行的方法/想法。
isBullish = true
isBearish = true
for i = 1 to iterationCount
notSeries = not(isBullish and isBearish)
if notSeries
break
if close[i] > open[i]
我如何在最后一个历史栏上退出策略中的所有头寸?when=barstate.islast不能工作,因为它会在下一根蜡烛上执行订单(对吗?)。 last_historic_bar = is the last bar but not realtime?
strategy.close_all(last_historic_bar)
我想做一个代码,在图片中的情况下不会进入这个位置。
greenCandle = barstate.isconfirmed and (close > open)
sixGreenCandles = greenCandle[6] and greenCandle[5] and greenCandle[4] and greenCandle[3] and greenCandle[2] and greenCandle[1]
我不知道进入这个位置前要数蜡烛的密码
(除信号处的蜡烛外)
试图使用barssince函数取消登录订单。
希望它取消,如果没有填补相同的蜡烛订单是放置/蜡烛后,进入条件被满足。我不明白为什么它不起作用--它看起来如此简单。
rp1 = close[1] >= open [1] and close < open and high >= high[1]
rp1p = highest(high,1)
plotshape(rp1, style=shape.circle, location=location.abovebar, color=color.red)
if rp1 and strategy.opentrades == 0
我试图在一个条件之后得到一系列蜡烛的最低值,但它总是返回条件的最后一支蜡烛。我尝试使用min()、最低点()和for循环,但它不起作用。另外,尝试使用blackCandle[]和min(ThreeinARow)/lowest(ThreeinARow),有时它返回最后一支蜡烛,有时它会给我带来编译错误。
blackCandle = close < open
ThreeinARow = blackCandle[3] and blackCandle[2] and blackCandle[1]
SL = ThreeinARow ? min(low[1], low[2], low[3]) : na
我正在尝试通过pine脚本在tradingview上测试一个策略。我需要来自5根蜡烛的RSI数据,我正在使用这段代码来做这件事,我试图使用一个for循环来获取这些数据。 //for loop test
`enter code here`RSIBonus = 0
for i = 5 to 1 by 1
if RSI [abs(i)] > 35
RSIBonus := RSIBonus + abs(i)`enter code here` 但每次我收到这个错误的时候block of statements end expecting 'block of statements
我正在写一个基本的烛台检测功能,我也想检测2-蜡烛和3-蜡烛模式。
我能探测到两种蜡烛图案,比如在蜡烛里或吞没。
但是我想把这两支蜡烛围成一个圆圈,这样任何人都能从中受益,特别是新的学习者。
我该怎么做呢?
我目前的检测代码是:
// Two Candles Patterns ///////////////////////////////////////////////////////////////////////////////////////
// Engulfing Pattern
// op: Open Prev, cp: Close Prev .. so on
bullish_en
我想要计算指数移动平均( EMA )与EMA在未来的一支蜡烛,只需复制最后一支蜡烛。
意味着我想绘制一个偏移量为1的EMA,偏移量为1的值是基于当前的烛光计算得出的。
不幸的是,我想我对这个系列有一个错误的理解,为什么它不能工作。但希望我的代码能显示我想要做的事情:
CustomEma(source, length) =>
alpha = 2 / (length + 1)
ema = 0.0
// iterate through the length e.g. calculate with a length of 20
for i = 1 to length
y=length-i