#Binance
Creating a simple buy and sell strategy in TradingView using the Stochastic RSI indicator involves setting up conditions for both buy and sell signals. Here's a basic example:
1. Open the TradingView platform and create or open a chart.
2. Add the Stochastic RSI indicator to your chart:
- Click on "Indicators" (top menu).
- Search for "Stochastic RSI" and add it to your chart.
3. Set the parameters for the Stochastic RSI indicator. Common values are 14 for length, 3 for smoothK, and 3 for smoothD. You can adjust these based on your preference and market conditions.
4. Define the buy and sell conditions:
- Buy Condition:
- When the Stochastic RSI crosses above a certain threshold (e.g., 20).
- Add a condition for confirmation, such as the Stochastic RSI crossing above a certain level (e.g., 80).
- Sell Condition:
- When the Stochastic RSI crosses below a certain threshold (e.g., 80).
- Add a condition for confirmation, such as the Stochastic RSI crossing below a certain level (e.g., 20).
5. Implement the conditions using TradingView's Pine Script, the scripting language used for creating custom indicators and strategies. Here's a simple example in Pine Script:
```pinescript
//@version=4
study("Stochastic RSI Buy/Sell Strategy", shorttitle="StochRSI Strategy", overlay=true)
length = input(14, title="Length")
smoothK = input(3, title="SmoothK")
smoothD = input(3, title="SmoothD")
overbought = input(80, title="Overbought")
oversold = input(20, title="Oversold")
// Calculate the Stochastic RSI
StochRSI = sma(stoch(close, close, close, length), smoothK)
K = sma(StochRSI, smoothD)
// Plot the Stochastic RSI
plot(K, color=color.blue, title="StochRSI")
// Buy and Sell Conditions
plotshape(crossunder(K, oversold) and crossunder(StochRSI, oversold), style=shape.triangleup, location=location.belowbar, color=color.green, title="Buy Signal")
plotshape(crossover(K, overbought) and crossover(StochRSI, overbought), style=shape.triangledown, location=location.abovebar, color=color.red, title="Sell Signal")
```