ProRealTime Code – ChatGPT agent in training
Forums › ProRealTime English forum › General trading discussions › ProRealTime Code – ChatGPT agent in training
- This topic has 12 replies, 4 voices, and was last updated 1 year ago by CFD AutoTrading.
-
-
11/11/2023 at 5:32 PM #223542
Hello,
Continuing from previous threads about using ChatGPT, we’ve taken a step forward. Now, ChatGPT allows users to create and train specific agents (previously done by external apps, but now supported natively by OpenAI).
This means that, instead of launching a lengthy prompt to prepare the ChatGPT conversation, you can create an ‘agent’ and train it with a specific knowledge base retained over time. That’s what we’ve done by creating the ‘ProRealTime Code’ agent for ChatGPT. The downside is that OpenAI only allows access to this for ChatGPT Plus subscribers.
We’ve fed the agent with various official documentation and courses, as well as content from ProRealCode (the code and snippets libraries). The results are impressive, but of course, we didn’t automatically get a model that interprets all the documentation correctly. In fact, we needed a few hours to train the model to get some results that work well without modifications. And that’s not always the case! The agent will need ongoing instructions to debug problems and achieve better results.
We’re requesting your help to test and train the agent. In our training, we specifically requested the model to allow internet searches, but not to increase the knowledge base or adapt answers using sources from any commercial site. We also trained it to gather information about trading and general trading strategies, but not to draw specific conclusions.
This means that the agent will learn and enhance code using the instructions we continue providing and internet sources, but it won’t state if one strategy is better than another or discuss commercial providers. The focus is on coding on demand, although it can find general information like trading recommendations, classic or common strategies, information about seasonality, etc.
We will keep the agent open (for ChatGPT Plus users, though that’s not up to us), and would appreciate if you share your results and provide error-fixing proposals here. If you share problems in code generation, we will feed the agent with your proposal, but only if it’s neutral and specifically related to programming, without allowing discussion. For example, it would be helpful to receive feedback like ‘the agent doesn’t know how to set the TP in points, only in percentages,’ but not something like ‘the agent says that Wednesday is the best day for trading, and I think Monday is better.’ (It’s hard to explain this paragraph, sorry! It might be part of future discussions.)
I don’t have time to prepare a video now, but we’ve managed to create simple screeners, indicators, and strategies with code that worked on the first try. Note that this won’t always be the case, and that the agents work better when we make requests step-by-step.
Try the ‘ProRealTime Code’ ChatGPT agent here: https://chat.openai.com/g/g-6WBXOWXx2-prorealtime-code
Knowledge Base included:
- The three programming guides of ProRealTime
- The ‘Snippet Link Library’ at https://docs.google.com/spreadsheets/d/1rgboqj7sVwsP9ZRhOduOefye48QMWC07jWVXCl-KJPU/edit#gid=0
- The training program ‘Introduction to Programming with ProRealTime’ at https://www.prorealcode.com/courses/training-program-introduction-programming-prorealtime/
- The ProRealCode library at https://www.prorealcode.com/library-list-view/
- The ChatGPT prompt found here in ProRealCode
- A few hours of debugging errors in the code generated, feeding the agent with specific instructions to avoid it.
Looking forward to your feedback and new instructions to enhance the results!
4 users thanked author for this post.
11/27/2023 at 1:00 PM #224395The agent is overall pretty good.
For further debugging I found it gets these codes wrong – sell short, exit short
1 user thanked author for this post.
11/28/2023 at 9:24 AM #224432I find the knowledge base function isnt all that good.
We need to do finetuning and for that we need a good dataset.
If you make your json template public, we can all help to add to it.
11/28/2023 at 11:16 AM #224454Thanks, @monochrome.
Could you please provide an example of your input when receiving incorrect sell-related instructions for ‘sell short’ and ‘exit short’? I tried a simple strategy and the output correctly showed ‘sellshort’ and ‘exitshort’ without spaces, working throughout the entire code.
Regarding the requested JSON template, I am not sure how to export it. Is it possible? GPT agents have a ‘GPT builder’ where we can add specific instructions one by one for debugging errors found. That is what I plan to do when you confirm when the ‘sell short’ appears. For example, when specific behavior is needed, such as ‘all the code shown should be fully commented for easy understanding.’
I have tried different ways to output all these instructions but without success. I only know how to show the summary of the knowledge base documents received. Additionally, I found that the agent’s description was auto-updated with samples of the past injected instructions. The description you see in the related image is not the same as the original, and I now understand that it is dynamic. Part of the comments inside are precisely some instructions to the agent previously requested, but not all. We launched various tens of instructions after the injection of the PDF documents of the Knowledge Base.
Please see the related images for the different points. By the way, the field “instructions” max is 8.000 characters, then we cannot prepare a full set of instruction” in that field, to ‘rebuild’ the agent periodically.
I figure that using the API is possible, but we have not explored this option.
11/28/2023 at 11:31 AM #224459…found something interesting! See the images.
That means we lost a considerable part of the work…but the good news is that we can maintain a document with all the extra instructions and ‘fine-tuning’, loading it as a document periodically.
11/28/2023 at 11:57 AM #22446711/28/2023 at 12:28 PM #224471Yep, sorry, I missed specifying all the cases correctly. Previously, I was only thinking about the wrong ‘cumulateOrders’. Thank you for pointing out the issue. Later we will update all cases.
My current point is that we went wrong in training the agent, as it missed and discarded information before. However, the good news is that now it seems we can debug and fine-tune it using an external document that can be versioned and reloaded.
It would be great if you could also share your feedback about the agent and point out any other problems it may have, as its training is an ongoing process.
11/28/2023 at 12:45 PM #224473Sorry my bad, i thought you were finetuning the agent. What you are doing is using GPTbuilder adjust the prompt.
What i meant was finetuning – https://platform.openai.com/docs/guides/fine-tuning
This requires a preparation of a dataset. minimum 10 examples. The more the better. Needs to be high quality.
This will tune the agent to respond how we want it to. But it dosent add knowledge.
For adding knowledge – Instead of the PRT pdf we can make curated document containing specific imformation of prt and upload it and ask it in the prompt to always refer to the document before replying.
There is only so much we can do with prompts. To take it to the next level we need to do proper Fine-tuning.
Finetuning is working for gpt3.5 but currently only in beta for gpt4 so im just waiting for it to be released before i put time into it.
1 user thanked author for this post.
11/28/2023 at 1:26 PM #224475Let’s proceed as you prefer @monochrome. How do you propose to store and maintain the source document with instructions?
Versioning it and attaching it in posts on every step, or maintained externally (updated anyway here, but maybe periodically, not in every single step)?
I gathered a big part of the initial extra instructions, which I can put on the resulting document when you prefer; while continue talking here about the progress.
11/28/2023 at 2:54 PM #224505Could you please provide an example of your input when receiving incorrect sell-related instructions for ‘sell short’ and ‘exit short’?
Prompt i used – (it was a question asked in the forum)
Help me make this code – Base numbers: Stock ABC is at 100 Buy 1 lot when rsi 3 crosses above 70 (follow momentum) Set SL: x points (example 10 points) Set TP y points (example 20 points) If TP is hit, we open lot #2 and move both SL to 5 points below lot #2 entry (we opened the buy in ABC at 100, moved to our TP at 120, we open lot #2 at 120, SL for both lots are at 115) If SL is hit, exit all positions If new TP at 140 is hit, open lot #3, set SL for all 3 lots at 5 points below lot #3 entry. Repeat until SL is hit. Reverse the rules for shorts.
Response code –
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061// Initial setupDEFPARAM CumulateOrders = False // Each order is treated separatelyDEFPARAM FlatAfter = 235900 // Close all positions at the end of the day// ParametersLot1EntryPrice = 100SLPoints = 10TPPoints = 20SLAdjustment = 5LotSize = 1 // Size of each lot// RSI calculationRSI3 = RSI[3](close)// ConditionsBuyCondition = RSI3 crosses over 70SellCondition = RSI3 crosses under 30// State variables to keep track of lotsNumLots = 0TotalEntryPrice = 0// Buying LogicIF BuyCondition AND NumLots = 0 THENBUY LotSize CONTRACT AT MARKETSetStop = Lot1EntryPrice - SLPointsSetTarget = Lot1EntryPrice + TPPointsNumLots = 1TotalEntryPrice = Lot1EntryPriceENDIFIF NumLots > 0 AND close >= TotalEntryPrice + (TPPoints * NumLots) THENBUY LotSize CONTRACT AT MARKETNumLots = NumLots + 1TotalEntryPrice = TotalEntryPrice + closeSetStop = close - SLAdjustmentENDIF// Selling LogicIF SellCondition AND NumLots = 0 THENSELL SHORT LotSize CONTRACT AT MARKETSetStop = Lot1EntryPrice + SLPointsSetTarget = Lot1EntryPrice - TPPointsNumLots = 1TotalEntryPrice = Lot1EntryPriceENDIFIF NumLots > 0 AND close <= TotalEntryPrice - (TPPoints * NumLots) THENSELL SHORT LotSize CONTRACT AT MARKETNumLots = NumLots + 1TotalEntryPrice = TotalEntryPrice + closeSetStop = close + SLAdjustmentENDIF// Exiting LogicIF (LongOnMarket AND close <= SetStop) OR (ShortOnMarket AND close >= SetStop) THENSELL AT MARKETSELL SHORT AT MARKETNumLots = 0TotalEntryPrice = 0ENDIF11/29/2023 at 12:00 PM #224557Hey Guys,
I’m trying to use Chat GPT to automate a fib trading strategy but I seem to be hitting a brick wall. I had a look at both PDFs (probuilder and probacktest) to try and figure it out but there isn’t anything written about Fibonacci so I cant correct it myself. Seems that ChatGPT isn’t that familiar with the prorealcode and I cant seem to get the 4.0 for the timebeing.
(just for a bit of background)
The strategy uses fibs to enter( finds a recent high to low (for shorts) or low to highs(for longs) and enters on the 50% retracement of that price. 100% being the start of the move and 0% being the end)
The stoploss is around the 61.8% mark and there is a 2 tier take profit (one at 38.2 and the other at -23.6%).
Any chance anyone could eyeball the script for the main errors?
defparam cumulateOrders = false
// Calculate Fibonacci retracement levels
CalculateFibonacciLevels(low, high) =
range = high – low
fib50 = low + range * 0.5 / 100
fib38 = low + range * 0.382 / 100
fibNeg236 = low + range * (-0.236) / 100
fibLevels = [fib50, fib38, fibNeg236]
fibLevels// Variables
frontRunPips = 5
extraPips61_8 = 2
positionSizePercent = 1// Initial trade direction assumption
longTrade = true// Function to enter a trade
EnterTrade(direction, entryPrice, stopLoss, target1, target2) =
if direction then
// Buy
entryPrice = entryPrice – frontRunPips
buy at entryPrice stop
sell at entryPrice – stopLoss stoploss
set target pprofit target1
set target pprofit target2
else
// Sell Short
entryPrice = entryPrice + frontRunPips
sellshort at entryPrice stop
cover at entryPrice + stopLoss stoploss
set target pprofit target1
set target pprofit target2
endif// Function to manage the trade
ManageTrade(direction, stopLoss, target1, target2) =
if direction then
// Buy trade management
set stop ploss stopLoss
if high >= target1 then
// Move stop loss to breakeven after hitting target1
set stop ploss entryPrice
endif
else
// Sell Short trade management
set stop ploss stopLoss
if low <= target1 then
// Move stop loss to breakeven after hitting target1
set stop ploss entryPrice
endif
endif// Main strategy
Length = 14
Multiplier = 3
indicator1 = supertrend[Multiplier, Length]if close crosses over indicator1 then
// Determine Fibonacci levels for the uptrend
fibLevels = CalculateFibonacciLevels(low[1], high[1])// Enter trade based on Fibonacci levels
if low <= fibLevels[1] then
// Entry at 50% retracement level
EnterTrade(longTrade, fibLevels[1], fibLevels[2] – extraPips61_8, fibLevels[2], fibLevels[3])
endif// Manage the trade
ManageTrade(longTrade, fibLevels[2] – extraPips61_8, fibLevels[2], fibLevels[3])
endif// Additional conditions for continuing the trade
if low <= fibLevels[3] then
// If the price keeps climbing past -23.6%, update entry level
longTrade = true
entryPrice = high
fibLevels = CalculateFibonacciLevels(low, high)
// Enter trade based on updated Fibonacci levels
EnterTrade(longTrade, fibLevels[1], fibLevels[2] – extraPips61_8, fibLevels[2], fibLevels[3])
endifThis is what ChatGPT populated. I’m sure its not right, but just don’t know where the mistakes are. Any ideas?
11/30/2023 at 11:31 AM #224620Thanks for posting @dudewheresmycar. There are indeed multiple problems in that code. For example, the agent invented a way to call functions (like ‘EnterTrade’), which is incorrect.
Anyway, when asking about the Agent results, please add all the input sent to it, because GPT agents can usually get into the error of being “complacent”. I don’t know if this is the case, but if you say something like ‘…and then call the enter function’, the agent skips the instructions it knows and might make something up. It is also a good practice to make the request iterative, to build the code sequentially and step by step. I mean, for example, to use several requests like:
– Build a strategy that…something
– Add a SL of 1%.
– Add a trailing stop of 0.5%.
– Add an additional condition that…
…..Please, @dudewheresmycar, post the full entry here, and we’ll see how to proceed.
In fact, the fix of the previous post is also pending. Please, @monochrome tell me first your proposal to keep the source document with instructions (a Google Spreadsheet is fine? It allows the concurrent and online collaboration). I prefer to first rebuild the Agent, and then we and anyone else who wants to could help improve each case’s results.
Come on, let’s build something good that people can use! 🙂
1 user thanked author for this post.
12/05/2023 at 9:03 PM #224905Hello, we have noted limited engagement with the ProRealTime Code ChatGPT Agent. As a result, we are redirecting our efforts and will continue development on our dedicated website.
The project is still active; the Agent will remain accessible. However, we will continue its development privately and as a no-priority project.
Nevertheless, we welcome anyone interested in collaborations to contact us via our channels.
Best regards
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on