- 2010.05.17
- Sergey Pavlov
- www.mql5.com
Read the article https://www.mql5.com/en/articles/81 and https://www.mql5.com/en/articles/66
I've already seen all the pages but I do not understand is why I would love a person for me to convert this code in MQL5, again I speak English so it's not easy for me if it does not help me.
thank you for your help.
cordially
You can start learning with this article - Introduction to MQL5: How to write simple Expert Advisor and Custom Indicator
You can start learning with this article - Introduction to MQL5: How to write simple Expert Advisor and Custom Indicator
thank you for all your answers but I speak ENGLISH and to understand it faudrais translation of this code MQL5 because you will send me on codes I do not understand because I have no referential my repos is my code that I know well that is why it is very important to me that a person is willing to spend some time to convert it is very important to me.
I'm not a computer specialist and I am not a genius :-) so help me.
thank you
cordially
Hi phenix, I rewrite your MQL4 code to be like this below;
//+------------------------------------------------------------------+ //| MQL4 Note.mq4 | //| Copyright 08 May 2012 , onewithzachy | //| | //+------------------------------------------------------------------+ #property show_inputs extern double Lot = 0.1; extern string TradeComment = "IA 8 Paires"; int TradesSent = 0; //+------------------------------------------------------------------+ //| script program start function | //+------------------------------------------------------------------+ int start() { ORDER_SEND_FUNC ("AUDUSD", OP_SELL); ORDER_SEND_FUNC ("EURUSD", OP_SELL); ORDER_SEND_FUNC ("GBPUSD", OP_SELL); ORDER_SEND_FUNC ("NZDUSD", OP_SELL); ORDER_SEND_FUNC ("NZDJPY", OP_BUY); ORDER_SEND_FUNC ("EURJPY", OP_BUY); ORDER_SEND_FUNC ("AUDJPY", OP_BUY); ORDER_SEND_FUNC ("GBPJPY", OP_BUY); return(0); } //+----------------------------------------------------------------------------------------------------+ int ORDER_SEND_FUNC (string my_symbol, int trade_type) { int ticket, mode_price, try; if (trade_type == OP_BUY) mode_price = MODE_ASK; if (trade_type == OP_SELL) mode_price = MODE_BID; while(true) { try ++; ticket= OrderSend(my_symbol, trade_type, Lot, MarketInfo(my_symbol,mode_price), 10, 0, 0, TradeComment, 0, 0, CLR_NONE); if(ticket <= 0) { Print("Error = ",GetLastError()); // some error code process here to decide whether to continue open position or not } else { Print("Success sending order for ",my_symbol," with ticket = ", ticket," after ",try," trying."); TradesSent++; break; } } return (ticket); } //+----------------------------------------------------------------------------------------------------+
Here's the conversion to MQL5. I did not test this because I have bad internet connection. Rosh would you please be kind to help us to correct the codes if there's any error. :)
1st conversion
// the codes is removed to save some space, please download the attachment to review the codes. Thank you. onewithzachy
Personally, I don't think it's good idea to send order with while loop like that.
I'll write more, when I have time, you just have to check this topic again phenix. :)
BTW, what's the french of Hello, Good luck and Have fun ?
Have Fun :)
onewithzachy, a very very big big thank you to you for your help and your availability this will help me a lot.
and it is heartwarming to find people who still helps as you did.
yes I would be happy even when you have time the improvements of this script :-)
thank you again for your patience and your help.
friendly
Phenix, I don't have much time right now, so this is the best that I can help.
In the attachments below are the same code with adding tp and sl after position successfully opened. I only test this briefly, and it looks like it's running well.
Personally I think we should process the error codes, for example if there is requote, we can adjust the opening price properly so the position will be opened anyway.
Have fun :)
friendly
Use Standard library class CTrade, try this:
#property description "https://www.mql5.com/en/forum/6666" #property link "https://www.mql5.com/en/forum/6666" #include <Trade\Trade.mqh> #property script_show_inputs input double Lot = 0.1; input double SL = 300; input double TP = 300; input string TradeComment = "IA 8 Paires"; double My_SL=0.0,My_TP=0.0; int TradesSent=0; CTrade trade; //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStart() { PlaySound("wait.wav"); //--- //ORDER_SEND_FUNC ("AUDUSD", ORDER_TYPE_SELL); //ORDER_SEND_FUNC ("EURUSD", ORDER_TYPE_SELL); //ORDER_SEND_FUNC ("GBPUSD", ORDER_TYPE_SELL); //ORDER_SEND_FUNC ("NZDUSD", ORDER_TYPE_SELL); //ORDER_SEND_FUNC ("NZDJPY", ORDER_TYPE_BUY); //ORDER_SEND_FUNC ("EURJPY", ORDER_TYPE_BUY); //ORDER_SEND_FUNC ("AUDJPY", ORDER_TYPE_BUY); //ORDER_SEND_FUNC ("GBPJPY", ORDER_TYPE_BUY); //--- sell one pair double open_price=SymbolInfoDouble("AUDUSD",SYMBOL_BID); int digits=(int)SymbolInfoInteger("AUDUSD",SYMBOL_DIGITS); double SLprice=NormalizeDouble(SymbolInfoDouble("AUDUSD",SYMBOL_ASK)+SL*_Point,digits); double TPprice=NormalizeDouble(SymbolInfoDouble("AUDUSD",SYMBOL_ASK)-TP*_Point,digits); if(trade.Sell(Lot,"AUDUSD",open_price,SLprice,TPprice,TradeComment)==false) { Print("Sell AUDUAS failed, Error=",GetLastError(), " Retcode description:",trade.CheckResultRetcodeDescription()); } PlaySound("wait.wav"); } //+------------------------------------------------------------------+
Dear Rosh, thanks for the codes. The reason I didn't try that (for trade 3.mq5) was that Ctrade trade.sell (or trade.buy) doesn't have slippage, so we may end up in requotes.
BTW, I think that's a copy paste typo, you usually calculate TP for sell base on Bid price :).

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I started in programming and I try to learn the MQL5, I know a bit MQL4, therefore I would like to know if someone could bring me this MQL5 code so that I can understand the difference between MQL5 and MQL4 this help me much.
thank you sincerely
Sorry for my English i am French