TECHNICAL MANUAL
This weblog is meant as a short technical information to begin utilizing the OpenAI API and exploit the big potential provided by means of synthetic intelligence, specifically Giant Language Fashions, utilized to buying and selling.
Hyperlink to buy the Library:
https://www.mql5.com/en/market/product/112766?supply=Unknown
First you might want to proceed to incorporate the hooked up file StormWaveOpenAI.mqh, which incorporates the courses and the header of the library, in order that you do not have to fret about anything.
As soon as the library has been included, we will begin with a extremely easy instance, which is the commented supply code for the “OpenAI API” Professional Advisor, which you’ll be able to obtain without spending a dime and take a look at with my OpenAI API on the following hyperlink:
https://www.mql5.com/en/market/product/112756?supply=Website+Market+Product+Web page
Let’s proceed!
#embody <StormWaveOpenAI.mqh> enter string OPENAI_API_KEY_ = "" ; enter string MESSAGE_ = "" ; enter int MAX_TOKEN_ = 300 ; COpenAI *consumer; CMessages *_message_; string __api_key__ = OPENAI_API_KEY_; int OnInit () { if ( MQLInfoInteger ( MQL_TESTER )) return ( INIT_FAILED ); consumer = iOpenAI(__api_key__); consumer.ParseCache(); consumer.start_thread(); string completion; _message_ = iMessages(); string system_content = "You're a technical {and professional} monetary assistant specializing in foreign exchange chart evaluation and reply in a most of 40 phrases within the language of the final message despatched by the person" ; _message_.AddMessage(system_content, system); string warning = "Warning. You're utilizing API KEY, so you might be restricted to coming into a shorter message!n" + "If you wish to enter an extended message you should use your API KEY." + "You may get them by going to the next URL : https://platform.openai.com/api-keys " ; string user_content = MESSAGE_; int str_tokens = consumer.CalculateTokens(MESSAGE_); if (str_tokens > MAX_TOKEN_) MB_ICONWARNING ); return ( INIT_FAILED ); user_content = MESSAGE_; _message_.AddMessage(user_content, person); int token = is_personal_key ? MAX_TOKEN_ : 100 ; completion = consumer.completions_create( "gpt-3.5-turbo-0125" , _message_, 300 , 1.0 ); :: MessageBox (consumer.PrintResultMessage(), "Consequence" , MB_OK | MB_ICONINFORMATION ); DeletePointer(_message_); DeletePointer(consumer); return ( INIT_SUCCEEDED ); } void OnTick () { if ( MQLInfoInteger ( MQL_TESTER )) return ; ExpertRemove (); } template < typename T> void DeletePointer(T* &ptr) { if (:: CheckPointer (ptr) == POINTER_DYNAMIC && ptr != NULL ) { delete ptr; ptr = NULL ; } }
Effectively on this instance we’ve created a easy EA that responds to questions made via the enter window.
Different examples will observe quickly with the usage of instruments (i.e. features) and with the usage of GPT-Imaginative and prescient’s Laptop Imaginative and prescient.
Thanks for studying this text!