ChatGPT v4 (paid version) is better in many ways, but still have to define some infos before creating a prompt.
I asked:
“code a compatible simple RSI strategy for prorealtime”
and the answer is:
ProRealTime is a technical analysis and trading software platform that allows users to create custom trading strategies using its programming language, ProBuilder. Here’s a simple RSI (Relative Strength Index) strategy for ProRealTime:
- Define the parameters for the RSI calculation and the overbought and oversold levels.
- Calculate the RSI based on the defined parameters.
- Implement the buy and sell conditions based on the overbought and oversold levels.
- Manage the trading positions and add stop loss and take profit levels (optional).
Here’s the code for the simple RSI strategy:
// Parameters
RSI_Period = 14
Overbought_Level = 70
Oversold_Level = 30
StopLoss = 2 // optional, in percent
TakeProfit = 4 // optional, in percent
// Calculate RSI
RSI_Value = RSI[RSI_Period](close)
// Buy and Sell conditions
Buy_Condition = RSI_Value crosses under Oversold_Level
Sell_Condition = RSI_Value crosses over Overbought_Level
// Manage positions
IF Buy_Condition THEN
Buy at market
StopLossLevel = close * (1 - StopLoss / 100)
TakeProfitLevel = close * (1 + TakeProfit / 100)
ENDIF
IF Sell_Condition THEN
Sell at market
StopLossLevel = close * (1 + StopLoss / 100)
TakeProfitLevel = close * (1 - TakeProfit / 100)
ENDIF
// Set stop loss and take profit levels (optional)
IF longonmarket THEN
SET STOP pLOSS StopLossLevel
SET TARGET pPROFIT TakeProfitLevel
ENDIF
IF shortonmarket THEN
SET STOP pLOSS StopLossLevel
SET TARGET pPROFIT TakeProfitLevel
ENDIF
This simple RSI strategy buys when the RSI crosses under the oversold level and sells when the RSI crosses over the overbought level. It also includes optional stop loss and take profit levels. Note that this strategy is designed for educational purposes and should be tested and optimized before using it in live trading.
Almost ok, so I continue:
with probuilder language, variable names can’t contain underscore. Also, the pLOSS and pPROFIT are used for points values, not percentage, which are: %LOSS and %PROFIT
and the new code:
Apologies for the oversight. Here’s the corrected version of the simple RSI strategy for ProRealTime using ProBuilder language with the proper variable naming conventions and the correct stop loss and take profit values:
// Parameters
RSIPeriod = 14
OverboughtLevel = 70
OversoldLevel = 30
StopLoss = 2 // optional, in percent
TakeProfit = 4 // optional, in percent
// Calculate RSI
RSIValue = RSI[RSIPeriod](close)
// Buy and Sell conditions
BuyCondition = RSIValue crosses under OversoldLevel
SellCondition = RSIValue crosses over OverboughtLevel
// Manage positions
IF BuyCondition THEN
Buy at market
StopLossLevel = close * (1 - StopLoss / 100)
TakeProfitLevel = close * (1 + TakeProfit / 100)
ENDIF
IF SellCondition THEN
Sell at market
StopLossLevel = close * (1 + StopLoss / 100)
TakeProfitLevel = close * (1 - TakeProfit / 100)
ENDIF
// Set stop loss and take profit levels (optional)
IF longonmarket THEN
SET STOP %LOSS StopLoss
SET TARGET %PROFIT TakeProfit
ENDIF
IF shortonmarket THEN
SET STOP %LOSS StopLoss
SET TARGET %PROFIT TakeProfit
ENDIF
Now, the variable names are without underscores, and the stop loss and take profit values are set using %LOSS and %PROFIT. Please note that this strategy is designed for educational purposes and should be tested and optimized before using it in live trading.