Hi I'm currently in the process of learning to write a script. Here's a very basic SMA 34/4 crossover script I've done so far. Is somebody able to help me with learning to add the following functions to the script.
Add an alert and indicator to close a short or long trade whenever any candle (price) touches the SMA 34 line?
When a SMA 34/4 Crossover has been executed (a Short Trade condition) add an alert/indicator (Titled “Add”) every time a Green bullish candle has closed.
When a SMA 34/4 Crossunder has been executed (a Long Trade condition) add an alert/indicator (Titled “Add) every time a Red bearish candle has closed.
To used on 15m/30m/1hr/2hr/4hr/1D/1W timeframe charts?
Demo script so far;
strategy("SMA Crossover demo", overlay=true)
shortCondition = crossover(sma(close, 34), sma(close, 4))
if (shortCondition)
strategy.entry("Sell/Short", strategy.short)
longCondition = crossunder(sma(close, 34), sma(close, 4))
if (longCondition)
strategy.entry("Buy/Long", strategy.long)