TECHNICAL MANUAL
This weblog is meant as a short technical information to start out utilizing the OpenAI API and exploit the large potential provided by means of synthetic intelligence, particularly Giant Language Fashions, utilized to buying and selling.
Hyperlink to buy the Library:
https://www.mql5.com/en/market/product/112766?supply=Unknown
First that you must proceed to incorporate the connected file StormWaveOpenAI.mqh, which comprises the lessons and the header of the library, in order that you do not have to fret about the rest.
As soon as the library has been included, we will begin with a very easy instance, which is the commented supply code for the “OpenAI API” Professional Advisor, which you’ll be able to obtain without cost and take a look at with my OpenAI API on the following hyperlink:
https://www.mql5.com/en/market/product/112756?supply=Web site+Market+Product+Web page
Let’s proceed!
#embrace <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 consumer" ;   _message_.AddMessage(system_content, system);   string warning = "Warning. You might be utilizing API KEY, so you're restricted to getting into a shorter message!n" +                     "If you wish to enter an extended message you need to use your API KEY." +                     "You will 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, consumer);            int token = is_personal_key ? MAX_TOKEN_ : 100 ;   completion = consumer.completions_create(                     "gpt-3.5-turbo-0125" ,                     _message_,                              300 ,                                    1.0                                   );   :: MessageBox (consumer.PrintResultMessage(), "End result" , 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 got created a easy EA that responds to questions made by way of the enter window.
Different examples will comply with quickly with using instruments (i.e. capabilities) and with using GPT-Imaginative and prescient’s Pc Imaginative and prescient.
Thanks for studying this text!