Close icon
Marketing & BusinessDown chevron icon
šŸ¤– GPT

Pine Script Trading Strategy Developer

Pine Script Trading Strategy Developer gpt prompt mini thumbnail
13Eye icon
TestedTick icon
TipsTick icon
4 examplesTick icon
Pine Script Trading Strategy Developer
Get prompt
After purchasing, you will gain access to the prompt file which you can use with GPT or the app builder. You'll receive 20 free generation credits with this purchase. By purchasing this prompt, you agree to our terms of service.
2 weeks ago
Related item

Prompt Details

Chat - GPT-3.5 (gpt-3.5-turbo)
Token size
53 ($0.00027 / call)
Example input
[market]: Cryptocurrency [target audience]: advanced traders [trading approach]: algorithmic trading [key elements]: entry/exit signals, risk management, and backtesting
Example output
Here's a custom Pine Script trading strategy for advanced cryptocurrency traders. This strategy focuses on algorithmic trading, including essential components such as entry/exit signals, risk management, and backtesting. ```pinescript //@version=5 strategy("Advanced Crypto Algorithmic Trading Strategy", overlay=true) // --- Input Parameters --- length =, title="RSI Length") rsiOverbought =, title="RSI Overbought Level") rsiOversold =, title="RSI Oversold Level") smaLength =, title="SMA Length") stopLossPerc = input.float(2.0, title="Stop Loss Percentage", step=0.1) takeProfitPerc = input.float(4.0, title="Take Profit Percentage", step=0.1) // --- Indicator Calculations --- rsi = ta.rsi(close, length) sma = ta.sma(close, smaLength) // --- Entry Conditions --- longCondition = ta.crossover(rsi, rsiOversold) and close > sma shortCondition = ta.crossunder(rsi, rsiOverbought) and close < sma // --- Exit Conditions --- stopLoss = close * (1 - stopLossPerc / 100) takeProfit = close * (1 + takeProfitPerc / 100) // --- Trading Logic --- if (longCondition) strategy.entry("Long", strategy.long, stop=stopLoss, limit=takeProfit) if (shortCondition) strategy.entry("Short", strategy.short, stop=stopLoss, limit=takeProfit) // --- Plotting --- plot(rsi, title="RSI", hline(rsiOverbought, "Overbought", hline(rsiOversold, "Oversold", plot(sma, title="SMA", // --- Backtesting --- strategy.exit("Take Profit/Stop Loss", from_entry="Long", loss=stopLoss, profit=takeProfit) strategy.exit("Take Profit/Stop Loss", from_entry="Short", loss=stopLoss, profit=takeProfit) // --- Risk Management --- risk = input.float(1.0, title="Risk Percentage", step=0.1) capital = input.float(10000, title="Initial Capital", step=100) riskAmount = capital * (risk / 100) size = riskAmount / (stopLossPerc / 100 * close) // --- Position Sizing --- strategy.risk.allow_entry_in(strategy.direction.long) strategy.risk.max_contracts(size) ``` ### Explanation: 1. **Inputs:** - `length`: Length for RSI calculation. - `rsiOverbought`: RSI level indicating overbought conditions. - `rsiOversold`: RSI level indicating oversold conditions. - `smaLength`: Length for Simple Moving Average (SMA) calculation. - `stopLossPerc`: Stop loss percentage. - `takeProfitPerc`: Take profit percentage. - `risk`: Percentage of capital to risk per trade. - `capital`: Initial trading capital. 2. **Indicators:** - `rsi`: Calculates the Relative Strength Index (RSI). - `sma`: Calculates the Simple Moving Average (SMA). 3. **Entry Conditions:** - Long entry: RSI crosses above the oversold level and price is above the SMA. - Short entry: RSI crosses below the overbought level and price is below the SMA. 4. **Exit Conditions:** - Stop loss and take profit are calculated as percentages of the entry price. 5. **Trading Logic:** - Long and short entries are triggered based on the defined conditions, with stop loss and take profit levels. 6. **Plotting:** - RSI and SMA are plotted for visualization. - Overbought and oversold levels are indicated with horizontal lines. 7. **Backtesting:** - The strategy includes logic for backtesting with defined exit conditions. 8. **Risk Management:** - Position sizing is based on the percentage of capital to risk per trade. This script provides a robust framework for advanced algorithmic trading in cryptocurrencies. Adjust the parameters and conditions based on specific market conditions and backtest thoroughly before using it in live trading.
Browse Marketplace