Who can help with the robot, why isn't it working? - page 5

 
Sergey Gritsay:
Most likely, the compiler is fighting, but it should give a warning rather than an error.
I just compiled the code above and attached a screenshot, under#property strict strangely no errors and warnings, but variables should not coincide, unless of course it is cleverly designed that way. I didn't go into the logic of it.
 

Then it's like this

//+------------------------------------------------------------------+
//|                                                          123.mq4 |
//|                        Copyright 2016, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict

input double  lots       = 0.01;   // Лот
input int     stop_loss      = 10; // Указываем в валюте депозита
input int     take_profit    = 20; // Указываем в валюте депозита
extern int    Slippage = 3;        // Допустимое проскальзываение цены в пунктах
input int     Magic = 16384;       // Уникальный номер эксперта

int            last_bar       = 0;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
// ===== Пересчет под пятизнак =========
   if(Digits()==3 || Digits()==5)
     {
      Slippage           *= 10;
     }   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   if (last_bar == Bars) {return;}
   last_bar = Bars;
   if (OrdersTotal() == 0){
          int ticketbuy = OrderSend(Symbol(), OP_BUY, lots ,Ask, Slippage, 0, 0,  "", Magic, 0, clrBlue);
            if(ticketbuy<0)
               Print(Symbol()," OpenPosition. OrderSend Buy fail #",GetLastError());
            else
               Print(Symbol()," OpenPosition. OrderSend Buy successfully");
          int ticketsell = OrderSend(Symbol(), OP_SELL, lots ,Bid, Slippage, 0, 0,  "", Magic, 0, clrRed);
            if(ticketsell<0)
               Print(Symbol()," OpenPosition. OrderSend Sell fail #",GetLastError());
            else
               Print(Symbol()," OpenPosition. OrderSend Sell successfully");      
}
 double profit=0;
   for(int i=0;i<OrdersTotal();i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES) && OrderSymbol()==_Symbol && OrderMagicNumber()== Magic)
        {
         profit+=OrderProfit()+OrderSwap()+OrderCommission();
        }
     }
 int requot=0;
 if(profit>=take_profit || (-profit)>=stop_loss)
   for(int ii=0;ii<OrdersTotal();ii++)
     {
      if(OrderSelect(ii,SELECT_BY_POS,MODE_TRADES) && OrderSymbol()==_Symbol && OrderMagicNumber()== Magic)
        {
         if(OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),Slippage,clrRed))
               requot=0;
            else
              {
               requot++;
              }
         if(requot>10)
              {
               ii++;
               requot=0;
              }
            ii--;
        }
     }
 
  }
//+------------------------------------------------------------------+
 
Vladimir Zubov:

Then it's like this

Thank you! I'll try to check tomorrow....
 
Vladimir Zubov:

Then it's like this

Works via tester, but no trades open on real account....
 
GIM:
The tester works, but the real account does not open a single trade....
The Expert Advisor has some entries in the Expert Advisors tab, but in general I think the real account EA is crookedly written.
 
Sergey Gritsay:
The Expert Advisor has some entries in the Expert Advisors tab, but in my opinion it is crookedly written for real money.
Where do I need to fix it to make it work?
 
GIM:
Where do you need to fix it to make it work?
Everywhere, I cannot yet understand the logic of this EA as written, you open in different directions at once, but the profit of these two orders will always be the same, it will only change when swaps are accrued.
 
Sergey Gritsay:
You open in different directions at once, but the profit of these two orders will always be the same, it will only change when swaps are charged.
When I install the EA on the chart I adjust that the orders open only in one direction, in the trend and on several pairs, either buying or selling.
 
GIM:
When I install an EA on a chart I adjust that the orders open in one direction only, in the trend and on several pairs, either buying or selling, so I need to close all deals in total profit
I understand, it is too late for me today, I will outline an option for you tomorrow.
 
Sergey Gritsay:
I see, it's too late for me today, I'll sketch a version for you tomorrow.
Thank you!
Reason: