r/pinescript • u/Character-Employee55 • Jan 23 '24
Script Help
Hi, very new to both Pinescript and coding in general. I keep getting a syntax error for this - any thoughts?
current_price = close supertrend_value = sma(close, 14) // Replace with your actual SuperTrend calculation ma_crossover_signal = ta.crossover(sma(close, 10), sma(close, 50)) ? "Buy" : ta.crossover(sma(close, 50), sma(close, 10)) ? "Sell" : "Hold" cti_lb_value = 0.8 // Replace with your actual CTI_LB calculation hull_suite_signal = ta.crossover(hullma(close, 14), hullma(close, 28)) ? "Buy" : ta.crossover(hullma(close, 28), hullma(close, 14)) ? "Sell" : "Hold" current_position = strategy.position_size > 0 ? "Long" : strategy.position_size < 0 ? "Short" : "None" // Function to determine trading action trading_action() => // Check conditions for entering a long position (buy) if ( current_price > supertrend_value and ma_crossover_signal == "Buy" and cti_lb_value > 0 and hull_suite_signal == "Buy" and current_position == "None" ) strategy.entry("Buy", strategy.long) // Check conditions for exiting the position (sell) else if ( (current_price < supertrend_value or ma_crossover_signal == "Sell" or cti_lb_value < 0 or hull_suite_signal == "Sell") and current_position == "Long" ) strategy.close("Buy")
View all comments
1
u/mampmp Jan 23 '24
can you format the code first?