为什么我的策略无法在交易视图中执行?它不创造贸易吗?警告!该策略在整个测试范围内没有生成任何订单

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

`//@version=5 Strategy("4:4 S1", Overlay=true) // 指标输入 fairValueGap = input(0.5, "Lux Algo 公允价值缺口") cciLevel = input(100, "CCI Level") cci = ta.cci(close, 20) regressionLength = input(20, "回归长度") supertrendLength = input(10, "超级趋势长度") stopLoss = input(4, "止损(点)") takeProfit = input( 4, "止盈 (点)") // 计算指标 fairValue = ta.sma(close, 20) + fairValueGap supertrendUp = ta.sma(high, supertrendLength) + fairValueGap supertrendDown = ta.sma(low, supertrendLength) - fairValueGap regressionMA = ta.linreg(close, regressionLength, 0) // 定义长入场条件 longEntry = close > (fairValue) and close > supertrendUp and (regressionMA) > 0 and ta.cci(close, 20) > -100 和 ta.cci(close, 20) > -100 and ta. cci(收盘价, 20) < 100 // Define Short Entry Condition shortEntry = close < (fairValue) and close < (supertrendDown) and (regressionMA) < 0 and ta.cci(close, 20) > -100 和 ta.cci(收盘价, 20) < 100 // Execute Trades if longEntry strategy.entry("Long", strategy.long) if shortEntry strategy.entry("Short", strategy.short) // Set Stop Loss and Take Profit stopLossPips = ta.valuewhen(longEntry, close, 0) - stopLoss * syminfo.mintick takeProfitPips = ta.valuewhen(longEntry, close, 0) + takeProfit * syminfo.mintick strategy.exit("Stop Loss/Take Profit", "Long", stop=stopLossPips, limit=takeProfitPips) strategy.exit("Stop Loss/Take Profit", "Short", stop=stopLossPips, limit=takeProfitPips) plotshape(longEntry, location=location.belowbar, size=size.normal, color=color.green, style=shape.triangleup) plotshape(shortEntry, location=location.abovebar, size=size.normal, color=color.red, style=shape.triangledown)``

pine-script tradingview-api execute strategy-pattern entry-point
1个回答
0
投票

当我将您的策略应用于图表时,它会执行数千笔交易,因此入场标准似乎没有任何问题。

通常阻止策略进入交易的是您的头寸规模设置。对于某些工具,TradingView 的经纪商模拟器不会填写订单,除非您至少购买了一份合约。

为确保您的策略始终购买至少一份合约,请将

Order Size
设置为
1 Contract

© www.soinside.com 2019 - 2024. All rights reserved.