برای بهینه سازی این استراتزی ایا پیشنهادی داری؟//@version=5
strategy('[VV] Sahand Buy Sell', overlay=true)
tim = input.timeframe('375')
// gann 81, 1 & 81, 2 as channel
length = input.int(81, minval=1)
src = input(close, title='Source')
// Band factors
Band1 = input.float(1.0, minval=0.001, maxval=10, step=0.1)
Band2 = input.float(2.0, minval=0.001, maxval=10, step=0.1)
// Create a function to calculate bands
f_calculateBands(src, length, bandFactor) =>
basis = ta.sma(src, length)
dev = bandFactor * ta.stdev(src, length)
[basis, basis + dev, basis - dev]
// Call the function for Band1 and Band2
[basis, upper1, lower1] = f_calculateBands(src, length, Band1)
[basis2, upper2, lower2] = f_calculateBands(src, length, Band2)
// Plot the bands
plot(basis, color=color.new(color.black, 0), linewidth=3)
plot(upper1, color=color.new(color.green, 0), linewidth=2)
plot(lower1, color=color.new(color.green, 0), linewidth=2)
plot(upper2, color=color.new(color.blue, 0), linewidth=3)
plot(lower2, color=color.new(color.blue, 0), linewidth=3)
// Get close and open prices from specific timeframe
close_tf = request.security(syminfo.tickerid, tim, close)
open_tf = request.security(syminfo.tickerid, tim, open)
// Create a function for entry conditions
f_checkEntryConditions(close_tf, open_tf, upper1, lower1) =>
longCondition = ta.crossover(close_tf, open_tf) and close < upper1
shortCondition = ta.crossunder(close_tf, open_tf) and close > lower1
[longCondition, shortCondition]
// Get the conditions
[longCondition, shortCondition] = f_checkEntryConditions(close_tf, open_tf, upper1, lower1)
// Define take profit and stop loss levels
takeProfit = input.float(1.5, title='Take Profit (%)')
stopLoss = input.float(1.0, title='Stop Loss (%)')
// Execute long entry and exit
if longCondition
strategy.entry('long', strategy.long)
strategy.exit('TP/SL Long', from_entry='long', limit=close * (1 + takeProfit / 100), stop=close * (1 - stopLoss / 100))
// Execute short entry and exit
if shortCondition
strategy.entry('short', strategy.short)
strategy.exit('TP/SL Short', from_entry='short', limit=close * (1 - takeProfit / 100), stop=close * (1 + stopLoss / 100))