Pine 脚本简单代码(策略)- 没有交易

问题描述 投票:0回答:1

大家好我正在尝试学习 pine 脚本我不知道发生了什么我只想回测这段代码但它不起作用。

时间为09:00-11:00时买入,止损30点,止盈60点,触及止损或获利退出。

//@version=5
strategy('test', overlay=true)

timeCondition = time('0900-1100', 'America/New_York:23456')


if timeCondition
    strategy.entry('Buy', strategy.long,stop=high - 30, limit=high + 60)


strategy.exit('Buy', stop=high - 30, limit=high + 60)

. . . . . . . . . .

pine-script pine-script-v5 trading tradingview-api pine-script-v4
1个回答
0
投票

几件事,你的止损和获利设置为与入场限价相同的价格。

就 9:00 到 11 点之间的买入而言,不确定你想要什么。买入多少,需要具体说明,但此代码将在 9:30 买入纽约公开赛,然后在 11:00 卖出,或者如果止损或在此之前击中目标。它应该给你一个想法,你可以根据你的策略调整它。

//@version=5
strategy('test', overlay=true)

buyTime = hour(time, 'America/New_York') == 09 and minute(time, 'America/New_York') == 30
sellTime = (hour(time, 'America/New_York') == 11 and minute(time,'America/New_York') == 00)

var float stopLoss = 0.0
var float target = 0.0

if buyTime
    strategy.entry('Buy', strategy.long)
    stopLoss := high - 30
    target := high + 30


if sellTime or high >= target or low <= stopLoss
    strategy.exit('Buy', stop=stopLoss, limit=target)
© www.soinside.com 2019 - 2024. All rights reserved.