MCX:GOLD1!   Gold Futures
//@version=4
strategy("Breakout Strategy", overlay=true)

// Define the inputs
atr_length = input(14, title="ATR Length")
multiplier = input(2.5, title="Multiplier")

// Calculate the ATR
atr = atr(atr_length)

// Calculate the long and short entry levels
long_entry_level = high + atr * multiplier
short_entry_level = low - atr * multiplier

// Plot the entry levels on the chart
plot(long_entry_level, color=color.green)
plot(short_entry_level, color=color.red)

// Set up long and short entry conditions
long_entry_condition = crossover(close, long_entry_level)
short_entry_condition = crossunder(close, short_entry_level)

// Enter long and short trades when the conditions are met
if (long_entry_condition)
strategy.entry(id="Long", long=true, comment="Long")

if (short_entry_condition)
strategy.entry(id="Short", long=false, comment="Short")


Type your question...

相關想法

免責聲明

這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。