Why my strategy doss not execute in tradingview? it creates no trade? caution! this strategy did not generate any orders throughout the testing range

107 views Asked by At

`//@version=5 strategy("4:4 S1", overlay=true) // Indicator Inputs fairValueGap = input(0.5, "Lux Algo Fair Value Gap") cciLevel = input(100, "CCI Level") cci = ta.cci(close, 20) regressionLength = input(20, "Regression Length") supertrendLength = input(10, "Supertrend Length") stopLoss = input(4, "Stop Loss (pips)") takeProfit = input(4, "Take Profit (pips)") // Calculate Indicators fairValue = ta.sma(close, 20) + fairValueGap supertrendUp = ta.sma(high, supertrendLength) + fairValueGap supertrendDown = ta.sma(low, supertrendLength) - fairValueGap regressionMA = ta.linreg(close, regressionLength, 0) // Define Long Entry Condition longEntry = close > (fairValue) and close > supertrendUp and (regressionMA) > 0 and ta.cci(close, 20) > -100 and ta.cci(close, 20) < 100 // Define Short Entry Condition shortEntry = close < (fairValue) and close < (supertrendDown) and (regressionMA) < 0 and ta.cci(close, 20) > -100 and ta.cci(close, 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)``

1

There are 1 answers

4
Whitebox.so On

When I apply your strategy to a chart, it executes thousands of trades, so there doesn't seem to be any issue with the entry criteria.

What usually prevents the strategy from entering trades is your position sizing settings. For some instruments, TradingView's broker emulator would not fill an order unless you bought at least one contract.

To ensure that your strategy always buys at least one contract, set the Order Size to 1 Contract:

Order size settings