Discussing the article: "OpenAI's ChatGPT features within the framework of MQL4 and MQL5 development" - page 2

 
Valeriy Yastremskiy #:
It would be good) as part of sharing experience) the task is complicated by the fact that µl doesn't know gpt languages very well. Sometimes it is quite difficult to get the code without errors.
ChatGPT 3.5 writes normally in MQL4/5, so don't get any ideas. The value of the article should be in the prompts and showing the process of development with ChatGPT, but there is no such thing at all. Just ready-made generated codes that nobody is interested in for free. The value of the article is zero, the author gets a "D" and I wonder how this shoddy work was allowed to be published.
 
Alexey Volchanskiy #:
ChatGPT 3.5 writes normally in MQL4/5, don't be so glib. The value of the article should be in prompts and showing the process of development using ChatGPT, but there is no such thing at all. Just ready-made generated codes that nobody is interested in for free. The value of the article is zero, the author gets a "D" and I wonder how this shoddy work was allowed to be published .

For those who are in the tank, let me tell you again, the point of the article is not to give you prompts, but to instil the idea that you should produce them yourself. You just don't realise what would happen to the article if I dumped everything I've done. There are tonnes of unnecessary junk that will only confuse people. The material should be simple and clear. And you're not taking an exam to give me a D. Be careful.

 
Alexey Volchanskiy #:
ChatGPT 3.5 writes normally in MQL4/5, don't be so glib. The value of the article should be in prompts and showing the process of development using ChatGPT, but there is no such thing at all. Just ready-made generated codes that nobody is interested in for free. The value of the article is zero, the author gets a "D" and I wonder how this hack job was allowed to be published .

I failed to get the code for placing a market order. If you can promt. Each time returned the ticket.

 
Valeriy Yastremskiy #:

I have not been able to get the code for placing a market order. If you can promt. It returned the ticket every time.

Write a procedure in MQL5 to open a market order. The function should accept the following input data:


1) Lot

2) Take Profit as a module of price difference between opening and closing prices

3) Stop Loss as a module of the price difference between the opening and closing prices

4) Order Direction (bool bDirection) true - BUY ; false - SELL

5) Slippage in pips (this is the maximum possible deviation from the opening price in pips)

6) Magic order number


Additionally, if the Stop Loss or Take Profit is zero, the order should be opened without the corresponding Stop Loss or Take Profit, depending on what is zero, or without Stop Loss and Take Profit at all if they are both zero.


Additionally, provide a lot check for minimum and maximum allowable lot, and if the lot is out of the allowable range, bring it to the nearest available number (minimum or maximum).


Provide extensive comments and try to make the code shorter, and don't forget that stop loss and take profit prices are calculated differently for buy and sell orders.


You can't use any libraries, but only MQL5 language features.

// Function for obtaining the corrected volume
double CorrectedVolume(double volume)
{
   double minVol = SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_MIN);
   double maxVol = SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_MAX);
   double VolStep = SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_STEP);
   
   // If the volume is less than the minimum volume, set the minimum volume
   if(volume < minVol)
       return minVol;
   // If the volume is greater than the maximum volume, set the maximum volume
   else if(volume > maxVol)
       return maxVol;
   
   // Convert the volume to a multiple of the volume step
   return (double)((int)(volume / VolStep)) * VolStep; 
}

// Basic function of order placement
bool OpenOrder(double volume, double stoploss, double takeprofit, bool bDirection, int slip, int magic)
{
   MqlTick last_tick;
   SymbolInfoTick(_Symbol,last_tick);
   
   // Determine the order opening price 
   double open_price = bDirection ? last_tick.ask : last_tick.bid;
   // Determine the value of the item 
   double point = SymbolInfoPoint(_Symbol);
   
   // Adjust SL and TP depending on direction
   double corrected_sl = bDirection ? open_price - stoploss * point : open_price + stoploss * point;
   double corrected_tp = bDirection ? open_price + takeprofit * point : open_price - takeprofit * point;
   
   // If SL or TP = 0, the order is opened without SL or TP
   if (stoploss == 0) corrected_sl = 0; 
   if (takeprofit == 0) corrected_tp = 0;
   
   // Transaction type used
   ENUM_ORDER_TYPE order_type = bDirection ? ORDER_TYPE_BUY : ORDER_TYPE_SELL;
   
   // Structure for filling in the request parameters
   MqlTradeRequest request;
   request.type = order_type;
   request.symbol = _Symbol;
   request.volume = CorrectedVolume(volume);
   request.price = open_price;
   request.sl = corrected_sl;
   request.tp = corrected_tp;
   request.deviation = slip;
   request.magic = magic;
   request.type_filling = ORDER_FILLING_FOK;
   request.type_time = ORDER_TIME_DAY;
   
   MqlTradeResult result;
   return OrderSend(request,result); // Send the order to the exchange
}

It didn't work right away, I had to make the prompt more detailed. Note that it took only 5 minutes. And I didn't look for any prompts, I just wrote what I wanted and how. Prompt is not a question at all....

 
This is all pointless with current GPT skills because the "customer" has to find errors in the generated source, meaning actually know the correct answer or write most of it. Current GPTs are chatterboxes.
 
Stanislav Korotky #:
This is all pointless with current GPT skills because the "customer" has to find errors in the generated source, meaning actually know the correct answer or write most of it. Current GPTs are chatterboxes.

Well actually you are the same as I say, really without knowing the language and correcting what it gives out it is useless, I tried to explain it in the article, but it seems not very much to people yet). They want to give me a prompt and that's it and I'm in the chocolate ))) And the fact that you need to think about it, GPT is there ))))

 
Thanks Eugene for the article! I have also experimented with CHATGPT and other AIs. Yes, sometimes it comes up with good texts, it can even write poems in any style, but it makes a lot of mistakes in programming, you can't do anything without checking and editing.
I agree with you about Promtov, even when you give the AI the same request, it generates different text or code. That's why you have to communicate with it like a child and thoroughly explain to it what you want to get from it. The only thing is that you, as a programmer with experience and experience, plus a mathematical education, and therefore with the appropriate style of thinking, can more clearly and briefly formulate a task for the AI, like a ToR. Many traders cannot make up elementary TOR for writing a simple Expert Advisor. When I started writing the first Expert Advisors in MQL4, I remembered how we were taught in university, back in Fortran, to first draw an algorithm of the future programme and then write code according to it, it helped a lot. Also, as future design engineers in radio-electronic systems, we were taught to write TOR, also useful.
 
Evgeniy Ilin #:

You'd better think about the fact that the starting EMA calculation is not equal to the subsequent ones, because you need to save bars until you are blue in the face, and you need to trade here and now. About the cycles, everything works by bars, I didn't notice any noticeable slowdowns. You can finalise the calculations as you want for this indicator, but will it give you much ) I just know that nothing at all ).

This is the task of the EMA writer - to make all his subsequent calculations equal to the previous ones. You don't need to save up bars until you are blue in the face, but, as I wrote above, you only need 10-20 times more bars than the period.

About cycles is very convincing... Of course, there is absolutely no difference between a cycle of 10 bars and a cycle of 100 bars... Especially if you consider the existence of fast algorithms for calculating averages.

 
Evgeniy Ilin #:

I didn't notice it at first)

   MqlTick last_tick;
   SymbolInfoTick(_Symbol,last_tick);
   
   
   // Determine the value of the item 
   double point = SymbolInfoPoint(_Symbol); // видимо по аналогии придумано)))
   
   
 
Valeriy Yastremskiy #:

I didn't notice it at first)

SymbolInfoDouble(_Symbol,SYMBOL_POINT) - this is how it should be. In general, you have understood... I have fixed most of the errors. I would have seen it all if it was the code for my ts. There are flaws... and if you don't know what you're doing, it's useless. You're on the right track. He's often wrong. There's a reason I wrote that article. I could make a super prompt, it would not make a mistake and give everything perfectly, but it would be useless because it's all a show-off. In real field conditions we ask simple human questions, which in the best case can be more specific, but as practice shows it does not reduce post processing much.