طلب من موقع ذكاء اصطناعي عمل مؤشر لاستراتيجية ليعمل علي تريدنج فيو ولكن الكود به خطأ
ارجو من احد الأخوة ايجاد الخطأ و اصلاحه
هذا هو الكود :
//@version=5
strategy("Modified Moving Average and Stochastic Strategy", overlay=true)
// Moving Averages
fastMa = ta.w(close, 50)
slowMa = ta.wma(close, 100)
// High and Low values
highValue = ta.highest(high, 1)
lowValue = ta.lowest(low, 1)
// Stochastic Oscillator
[stochK, stochD] = ta.stoch(high, low, close, 21, 5, 5)
// Set plot colors
plot_color = fastMa > slowMa ? color.blue : color.red
// Plotting Moving Averages
plot(fastMa, color=plot_color, title="Fast MA")
plot(slowMa, color=plot_color, title="Slow MA")
// Plotting High and Low values
hline(highValue, color=color.blue, title="High Value")
hline(lowValue, color=color.blue, title="Low Value")
// Plotting Stochastic Oscillator
plot(stochK, color=color.red, title="Stochastic K")
plot(stochD, color=color.red, title="Stochastic D")
// PinBar Condition
isPinBar(close, body, shadow) =>
body > 0 and shadow > 2 * body and shadow > 2 * ta.atr(14) and close > open
// Engulfing Candle Condition
isEngulfing(top, bottom, reverse) =>
top > 0 and bottom > 0 and reverse > 0 and (close[1] > open[1] and close < open[1]) and (close < open and close[1] > open)
// Buy Entry Conditions
buyCondition = (isPinBar(close, body, shadow) or isEngulfing(close, open, high)) and close > ta.wma(close, 100)
and (close > ta.wma(close, 50) or ta.wma(close, 50) > ta.wma(close, 100))
and stochK < 50
// Sell Entry Conditions
sellCondition = (isPinBar(close, body, shadow) or isEngulfing(close, open, high)) and close < ta.wma(close, 100)
and (close < ta.wma(close, 50) or ta.wma(close, 50) < ta.wma(close, 100))
and stochK > 50
// Set Target and Stop Loss levels
target = strategy.position_avg_price + 30
stopLoss = strategy.position_avg_price - 30
// Buy Signal and Stop Loss
strategy.entry("Buy", strategy.long, when=buyCondition)
strategy.exit("Sell", "Buy", profit=target, loss=stopLoss)
// Sell Signal and Stop Loss
strategy.entry("Sell", strategy.short, when=sellCondition)
strategy.exit("Cover", "Sell", profit=target, loss=stopLoss)
// Plot Strategy Signals
plotshape(buyCondition, color=color.green, style=shape.labelup, text="Buy", title="Buy Signal")
plotshape(sellCondition, color=color.red, style=shape.labeldown, text="Sell", title="Sell Signal")
plot(stopLoss, title="Stop Loss", color=color.red)
plot(target, title="Target", color=color.green)