it has issue on line 2 You cannot use strategy functions (strategy.entry) in indicator…
- User
it has issue on line 2 You cannot use strategy functions (strategy.entry) in indicator script. Please replace 'indicator' with 'strategy' /@version=5 indicator('Daily Fibs Levels with Orders', 'Daily Fibs Levels with Orders', overlay=true)
// Inputs firstLength = input(50, title='ADR Calculation Period (Days)') i_timeframe = input.timeframe(title='Custom Timeframe', defval='D') calcType = input.string("Basic", title = "Fibs Calculation", options=["Basic", "Standard Deviation", "Variance"]) showFib5 = input.bool(true, title='Fib Level 5 (0.786)', group='Fibonacci Levels') fibLevel5 = input.float(0.786, title='Fib Level 5', group='Fibonacci Levels') fib5Color = input.color(#FFFFFF, title='Fib Level 5 Color', group='Fibonacci Levels') showFib6 = input.bool(true, title='Fib Level 6 (1.0)', group='Fibonacci Levels') fibLevel6 = input.float(1.0, title='Fib Level 6', group='Fibonacci Levels') fib6Color = input.color(#FFFFFF, title='Fib Level 6 Color', group='Fibonacci Levels') openColor = input.color(#ffffff, title='Open Plot Color')
// Functions to get high, low, open dayOpen = request.security(syminfo.tickerid, i_timeframe, open, barmerge.gaps_off, barmerge.lookahead_on) dayHigh = request.security(syminfo.tickerid, i_timeframe, high) dayLow = request.security(syminfo.tickerid, i_timeframe, low)
dayRange = dayHigh - dayLow avgRange = ta.sma(dayRange, firstLength)
// Fib level calculations fibRange5 = avgRange * fibLevel5 / 2 fibRange6 = avgRange * fibLevel6 / 2
fib5Level = dayOpen + fibRange5 fib6Level = dayOpen + fibRange6
// Plotting Fib Levels plot(showFib5 ? fib5Level : na, color=fib5Color, title='Fib Level 5 (0.786)') plot(showFib6 ? fib6Level : na, color=fib6Color, title='Fib Level 6 (1.0)') plot(dayOpen, color=openColor, title="Daily Open")
// Trend detection (simple moving averages as an example for uptrend/downtrend) shortSMA = ta.sma(close, 20) longSMA = ta.sma(close, 50)
isUptrend = shortSMA > longSMA isDowntrend = shortSMA < longSMA
// Buy condition: Price goes below Fib 5 on an uptrend buyCondition = (isUptrend and close < fib5Level)
// Sell condition: Price goes above Fib 5 on a downtrend sellCondition = (isDowntrend and close > fib5Level)
// Stop Loss and Take Profit stopLossBuy = fib6Level // Below Fib 6 for Buy stopLossSell = fib6Level // Above Fib 6 for Sell takeProfit = dayOpen // Daily Open line for both Buy and Sell
// Execute Buy if (buyCondition) strategy.entry("Buy", strategy.long) strategy.exit("Take Profit/Stop Loss", from_entry="Buy", stop=stopLossBuy, limit=takeProfit)
// Execute Sell if (sellCondition) strategy.entry("Sell", strategy.short) strategy.exit("Take Profit/Stop Loss", from_entry="Sell", stop=stopLossSell, limit=takeProfit)
- Assistant