Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1814

 
In mql4 OrderSend() immediately returned the result of order processing by the trade server.
In mql5 such a function has to be written by yourself?

 
Tretyakov Rostyslav #:

Fixed it, now it works. Of course it's not right, but it works.

{
              if(iTrailTakeProfit > 0.0)
                {
                tp=OrderTakeProfit() + NormalizeDouble(iTrailTakeProfit * Point(),_Digits);
                if(NormalizeDouble(((tp - OrderTakeProfit())) < 0.0,Digits))return;
                tp = OrderTakeProfit();
                }else tp = 0.0;
              if(OrderProfit() + OrderSwap() + OrderCommission() > MarketInfo(Symbol(), MODE_TICKVALUE) * iTrailStart * OrderLots());
                {
                 if(((NormalizeDouble((Bid - OrderOpenPrice()*Point),Digits) >= NormalizeDouble(((Bid - NormalizeDouble((iTrailStart * Point),_Digits))),_Digits) > OrderStopLoss() || OrderStopLoss()==0)));//true
                   {
                    if((OrderStopLoss() == 0.0 && NormalizeDouble(Bid - OrderStopLoss()* Point,Digits) < NormalizeDouble((Bid - NormalizeDouble((iTrailDist * Point),_Digits)),_Digits)));//true
                      {
                      if(iTrailStep > 0.0 && OrderStopLoss() >= 0.0 && NormalizeDouble(((Bid - OrderStopLoss() - iTrailDist * Point)),Digits) >= iTrailStep);//true
                        {
                         sl_lev = NormalizeDouble((Bid - iTrailDist * Point()),_Digits);
                         if(NormalizeDouble(Bid - sl_lev * Point,_Digits) < MarketInfo(Symbol(),MODE_STOPLEVEL));//false
                           {
                            if(!OrderModify(Forder,OrderOpenPrice(),NormalizeDouble(Bid - NormalizeDouble((iTrailStart * Point),_Digits),_Digits),tp,OrderExpiration()));
                            Print("Не удалось модифицировать стоплосс ордера №",OrderTicket(),". Ошибка: ",GetLastError());
                           }
                        }
                      }
                   }
                }
             }

It doesn't set stops correctly, how do I fix it?

 
Valeriy Yastremskiy #:

And look in the magazine to see what it turns out to be)

At first I didn't write anything, then I started looking sequentially and it turned out to be a lot.

Thank you.

 
Alexander Avksentyev #:

Fixed it, now it works. It's not right, of course, but it works.

It doesn't set the stops right, how do you fix it?

Where are you getting this data from?

OrderTakeProfit()
OrderProfit() + OrderSwap() + OrderCommission()
OrderOpenPrice()
OrderStopLoss()
 
Tretyakov Rostyslav #:

Where are you getting this data from?

From the warrant.

if(OrderSelect(i, SELECT_BY_POS,MODE_TRADES))
       {
        if(OrderSymbol() == Symbol() && OrderMagicNumber() == Magic)
          {
           if(OrderType() == OP_BUY) 
             {
              if(iTrailTakeProfit > 0.0)
                {
                tp=OrderTakeProfit() + NormalizeDouble(iTrailTakeProfit * Point(),_Digits);
                if(NormalizeDouble(((tp - OrderTakeProfit())) < 0.0,Digits))return;
                tp = OrderTakeProfit();
                }else tp = 0.0;
              if(OrderProfit() + OrderSwap() + OrderCommission() > MarketInfo(Symbol(), MODE_TICKVALUE) * iTrailStart * OrderLots());
 
secret of order processing by the trade server.
In mql5, such a function has to be written by yourself?

Types of trade transactions

MQL5 will also immediately return

OrderSend

If the order is successfully accepted by the trade server, the OrderSend() function returns true.

 
Alexander Avksentyev #:

Fixed it, now it works. It's not right, of course, but it works.

It sets stops wrong, how can I fix it?

OrderOpenPrice()*Point
OrderStopLoss()* Point

1,12500*Point=0.0000112500

 
Tretyakov Rostyslav #:

1,12500*Point=0.0000112500

Print(/*((*/NormalizeDouble((Bid - OrderOpenPrice()*Point),Digits) 

2021.12.15 00:26:55.086 2021.01.04 00:00:00 test1 EURUSD,M1: 1.22373


But if you count separately
Print(/*((NormalizeDouble((Bid - */OrderOpenPrice()*Point/*),Digits)/*

2021.12.15 00:30:09.557 2021.01.04 00:00:00 test1 EURUSD,M1: 1.2238e-05

Print(/*((NormalizeDouble((*/Bid - OrderOpenPrice()*Point/*
2021.12.15 00:34:05.979 2021.01.04 00:00:00 test1 EURUSD,M1: 1.223727762

 
secret of order processing by the trade server.
In mql5 such a function has to be written by yourself?

OnTradeTransaction

Документация по MQL5: Обработка событий / OnTradeTransaction
Документация по MQL5: Обработка событий / OnTradeTransaction
  • www.mql5.com
OnTradeTransaction - Обработка событий - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Alexander Avksentyev #:

2021.12.15 00:26:55.086 2021.01.04 00:00:00 test1 EURUSD,M1: 1.22373


But if you count separately

2021.12.15 00:30:09.557 2021.01.04 00:00:00 test1 EURUSD,M1: 1.2238e-05

2021.12.15 00:34:05.979 2021.01.04 00:00:00 test1 EURUSD,M1: 1.223727762

Read 3-4 posts

Любые вопросы новичков по MQL4 и MQL5, помощь и обсуждение по алгоритмам и кодам
Любые вопросы новичков по MQL4 и MQL5, помощь и обсуждение по алгоритмам и кодам
  • 2021.12.14
  • www.mql5.com
В этой ветке я хочу начать свою помощь тем, кто действительно хочет разобраться и научиться программированию на новом MQL4 и желает легко перейти н...
Reason: