I will write an advisor free of charge - page 167

 
Yuriy Bykov #:

No, it's a different form of writing the number 10000000000, so you don't have to write it that way

double minOpenPriceBuy = 10000000000;

...

Got it. e to a degree.
 
Yuriy Bykov #:

No, it's a different form of writing the number 10000000000, so you don't have to write it that way

double minOpenPriceBuy = 10000000000;

...

Thank you very much, it's good to be smart! If you don't mind, as I'm testing the strategy, I can share nuances or ideas, where maybe something needs to be added or tweaked, IF YOU are interested. Either here or in person...
 
Questions of this sort should be posted in this thread - there are more opportunities to edit the text of messages on the forum than in private messages. And more people will be able to reply.
 
Yuriy Bykov #:
Questions like that are better to write in this thread - there are more opportunities to edit the text of messages on the forum than in private messages. And more people will have the chance to reply.

If it is possible to do the following in this EA: - the EA trades, it has a profit and always has a current minus. As soon as the current minus is less than the profit, for example, in the following ratio: 150% profit, 100% minus (or let's say, clearly the profit earned 300 currency of the deposit, and the minus current 200 currency of the deposit), then all is closed (all the orders and trades). Clearly the set of trades needs time to close all the set, it's probably a minute, so until all is not closed, of course, nothing new should not open. To be on the safe side, after closing all pending and current deals, let it wait for another minute and do not open anything. Then the next "race" starts. Begs the question, from what amount of profit to count this ratio 1:1.5 (by the way this ratio should be variable in the settings), what would close all? - I do not know, it seems to me that as soon as we obtain such a ratio, so we can act. How's that for you?

 

Here is an example of code that can close all orders opened by the EA.

Function TryCloseAll() tries to close all orders, but to be safe, it should be used in a loop, which will be executed until it returns True.

An example of such a loop is in function OnDeinit() called when the EA is removed from the chart.

//+------------------------------------------------------------------+
//| Закрыть все рыночные и отложенные ордера                         |
//| на текущем символе с нужными магическими номерами                |
//+------------------------------------------------------------------+
bool TryCloseAll() {
   bool res = true;
   for(int i = OrdersTotal(); i >= 0; i--) {
      if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
         if(OrderSymbol() != Symbol()) {
            continue;
         }
         int magic = OrderMagicNumber();
         if((magic == MagicBuy || magic == MagicSell)) {
            int type = OrderType();
            int ticket = OrderTicket();
            if((type > 1)) {
               Print("Close pending order #", ticket);
               res &= OrderDelete(ticket);
               if(!res) {
                  Print ("Error closing pending order ", ticket, ": ", GetLastError());
               }
            } else {
               double price = (type == OP_BUY ? Bid : Ask);
               Print("Close market order #", ticket);
               res &= OrderClose(ticket, OrderLots(), price, 1000);
               if(!res) {
                  Print ("Error closing pending order ", ticket, ": ", GetLastError());
               }
            }
         }
      }
   }

   return res;
}
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnDeinit(const int reason) {
   bool res = false;
   Print("Start closing all orders");
   while(!res && !IsStopped()) {
      res = TryCloseAll();
   }
}
//+------------------------------------------------------------------+

Here is a hammer, and you can decide for yourself where and when to hammer nails with it )

Files:
Pending.mq4  13 kb
 
Yuriy Bykov #:

Here is an example of code that can close all orders opened by the EA.

Function TryCloseAll() tries to close all orders, but to be safe, it should be used in a loop, which will be executed until it returns True.

An example of such a loop is in function OnDeinit() called when the EA is removed from the chart.

Here you have a hammer, decide for yourself where and when to hammer.)

Thank you

 

Hello all, help me write a forex robot for mt5. since I can not pay for the service on mql5 because of the ban on sanctions. remuneration will write to the card.

 
Kind . Need a programmer who will promote and sell an MQL 5 inductor. does not draw. Works on all pairs . Reward percentage of sales Percentage of sales of the indyuk.
 
Roman251117 #:
Kind . Need a programmer who promotes and sells an MQL 5. does not draw. Works on all pairs . Reward percentage of sales and interest on the sale of an indyuk.

A programmer programs - a programmer.

A salesman sells; a promoter promotes.

 
Anton Yakovlev:
If you have a good strategy and are willing to share it, I can write an advisor.
Hey Anton can you help me make my On Balance Volume Divergence EA more consistently profitable? Maybe change some things in the code or add some features and make it better please. the code is fully working but i am not satisfied with the results i am getting from it