// Entry Logic - Buy when MACD crosses above the Signal Line and Sell when MACD crosses below the Signal Line entry_condition_long = ta.crossover(macd_line, signal_line) entry_condition_short = ta.crossunder(macd_line, signal_line)
// Exit Logic exit_long = strategy.position_avg_price <= fix_stop_loss or low <= atr_stop_loss exit_short = strategy.position_avg_price >= fix_stop_loss or high >= atr_stop_loss
// Trail Stop Logic trail_stop_long = close >= trail_stop trail_stop_short = close <= trail_stop
// Submit entry orders if entry_condition_long strategy.entry("Buy", strategy.long) if entry_condition_short strategy.entry("Sell", strategy.short)
// Plot MACD lines and Signal line for reference plot(macd_line, title="MACD", color=color.blue) plot(signal_line, title="Signal Line", color=color.red)
// Plot ATR value for reference plot(atr_value, color=color.green)
Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.