0

我在 PineScript 中为 TradingView 编写了一个非常简单的策略该策略确实在图表上显示了买入和卖出信号,但是由于某种原因没有触发警报。

这是代码,我还附上了图表上的买入/卖出图像和警报设置。如果你看到我遗漏的东西,请告诉我@PineCoders-LucF @PineCoders

//@version=4

strategy("PreHaltAlgo", overlay=true, pyramiding = 1, calc_on_every_tick = true, default_qty_type = strategy.percent_of_equity, default_qty_value = 2, currency = currency.USD)

stratbull = input(title="Enter longs ?", group = "General Settings", type = input.bool, defval=true)
stratbear = input(title="Enter shorts ?", type = input.bool, defval=false)

stratyear = input(2016, title = "Strategy Start Year")
stratmonth = input(1, title = "Strategy Start Month")
stratday = input(1, title = "Strategy Start Day")
stratstart = timestamp(stratyear,stratmonth,stratday,0,0)

timebull = stratbull and time > stratstart
timebear = stratbear and time > stratstart

tier1 = security(syminfo.tickerid,"D",close[1]) >= 0.75 and security(syminfo.tickerid,"D",close[1]) <= 3.00
tier2 = security(syminfo.tickerid,"D",close[1]) > 3.00
perc_change = ((high[0] - open[0]) / open[0]) * 100
limit_up = perc_change > 9.5

min_vol = security(syminfo.tickerid,"D",volume[0]) > sma(security(syminfo.tickerid,"D",volume[0]),30)

// longCondition = limit_up  

if timebull and limit_up and min_vol
    strategy.entry("Long", true, alert_message="{\"ticker\": \"{{ticker}}\", \"action\": \"buy\", \"quantity\":\"100\"}")
if strategy.position_size > 0    
    strategy.close("Long", when = open[0], alert_message="{\"ticker\": \"{{ticker}}\", \"action\": \"sell\", \"quantity\":\"100\"}")

图 1

图 2

4

0 回答 0