[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 5

 
granit77:

Question: how do I put a clean terminal? After all, when I try to reboot, the system automatically recognises me, allowing me to reload the terminal file and saving previously accumulated information: demo account, written indicators, etc. Apparently there is a file among the saved ones that doesn't allow to reload the historical data. :)
 
Hello, my question is whether MT4 EAs will work on this device
 
boris.45:
Simply download again from your broker and put it in a different directory. Enter your demo account username and password manually if you need to, but it's better to open a new one.
And like a newborn baby you will be completely sinless.
 
afirius:
Hello! The question is whether MT4 EAs will work on this device
it will!
 
Cool) finally a cure-all.)
T-G:
will be!
 
who would help, change buy to sell in the code of this expert
Files:
ema_wma.mq4  5 kb
 

Hi. Here's the problem.

The same Expert Advisor trades normally on a demo account and in the tester, but refuses to work or works incorrectly on a real account.

What should I do to fix it?

extern int ma1 = 7;
extern int ma2 = 100;
extern int ma3 = 200;
extern int ma4 = 300;
extern int shift = 15;
extern double StartLot = 0.5;
extern double LotStep = 0.25;
extern int candleAmount = 25;
extern bool workAlone = true;

double   MA1;
double   MA2;
double   MA3;
double   MA4;
int      Trend;
int      i;
datetime shiftTime;
int      ticket;

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   if (Digits == 3 || Digits == 5)
      shift = shift*10;
   MA1 = iMA(NULL,0,ma1,0,MODE_SMA,PRICE_CLOSE,1);
   MA2 = iMA(NULL,0,ma2,0,MODE_SMA,PRICE_CLOSE,1);
   MA3 = iMA(NULL,0,ma3,0,MODE_SMA,PRICE_CLOSE,1);
   MA4 = iMA(NULL,0,ma4,0,MODE_SMA,PRICE_CLOSE,1);
   if (MA1<MA2 && MA1<MA3 && MA1<MA4)        {Trend = 1;}
   else if (MA1>MA2 && MA1>MA3 && MA1>MA4)   {Trend = 4;}
   else                                      {Trend = 2;}
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
   MA1 = iMA(NULL,0,ma1,0,MODE_SMA,PRICE_CLOSE,1);
   MA2 = iMA(NULL,0,ma2,0,MODE_SMA,PRICE_CLOSE,1);
   MA3 = iMA(NULL,0,ma3,0,MODE_SMA,PRICE_CLOSE,1);
   MA4 = iMA(NULL,0,ma4,0,MODE_SMA,PRICE_CLOSE,1);

   if (Trend == 2)
   {  if (MA1<MA2 && MA1<MA3 && MA1<MA4)
      {  for (i = OrdersTotal(); i >= 0; i--)
         {  if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES) && OrderType() == OP_BUY)
               OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Bid,Digits),shift,Blue);
         }
         shiftTime = Time[0];
         if (OrdersTotal() == 0 || !workAlone)
         {  ticket = OrderSend(Symbol(),OP_SELL,LotsOptimized(Symbol()),NormalizeDouble(Bid,Digits),shift,0,0,"",777,0,Red);
            if (OrderSelect(ticket, SELECT_BY_TICKET, MODE_TRADES))
               shiftTime = OrderOpenTime();
         }
         Trend = 1;
      }
      else if (MA1>MA2 && MA1>MA3 && MA1>MA4)
      {  for (i = OrdersTotal(); i >= 0; i--)
         {  if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES) && OrderType() == OP_SELL)
              OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Ask,Digits),shift,Red);
         }
         shiftTime = Time[0];
         if (OrdersTotal() == 0 || !workAlone)
         {  ticket = OrderSend(Symbol(),OP_BUY,LotsOptimized(Symbol()),NormalizeDouble(Ask,Digits),shift,0,0,"",777,0,Blue);
            if (OrderSelect(ticket, SELECT_BY_TICKET, MODE_TRADES))
               shiftTime = OrderOpenTime();
         }
         Trend = 4;
      }
   }

   if (Trend == 1)
   {  if (MA1>MA2 || MA1>MA3 || MA1>MA4)
      {  Trend = 2;
         if (iBarShift(NULL,0,shiftTime,false) >= candleAmount)
         {  for (i = OrdersTotal(); i >= 0; i--)
            {  if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
               {  OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Ask,Digits),shift,Red);}}}}}

   if (Trend == 4)
   {  if (MA1<MA2 || MA1<MA3 || MA1<MA4)
      {  Trend = 2;
         if (iBarShift(NULL,0,shiftTime,false) >= candleAmount)
         {  for (i = OrdersTotal(); i >= 0; i--)
            {  if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
               {  OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Bid,Digits),shift,Blue);}}}}}
//----
   return(0);
  }

//+------------------------------------------------------------------+

double LotsOptimized(string symbol)
{  double lot = StartLot;
   int    losses = 0;
   if (LotStep > 0)
   {  for (int c = OrdersHistoryTotal() - 1; c >= 0; c--)
      {  if (OrderSelect(c,SELECT_BY_POS,MODE_HISTORY) == false) break;
         if (OrderSymbol() != symbol) continue;
         //----
         if (OrderProfit() > 0) break;
         if (OrderProfit() < 0) losses++;
      }
      if (losses >= 1) lot = NormalizeDouble(lot + LotStep * losses,2);
   }
   if (lot < MarketInfo(symbol,MODE_MINLOT)) lot = MarketInfo(symbol,MODE_MINLOT);
   return (lot);
}

//+------------------------------------------------------------------+ 
 
deboir:

Hi. Here's the problem.

The same Expert Advisor trades normally on a demo account and in the tester, but refuses to work or works incorrectly on a real account.

What should I do to fix it?


Miracles do not happen. What brokerage company do you have? Some brokerage companies do not allow you to place market orders if your order contains instructions to set a stop loss and/or take profit. Broco, for example, is like that. There, you have to open a market order first and only after that place stop orders via modification.
 
I specifically ran a test with the parameter x=1, then the parameter x=2, then I optimised x from 1 to 2 step 1. all the checkboxes are off, skipping useless cuts too. the genetic algorithm has been turned on and off. the results are different, helpppp!

I unchecked "skip useless cuts" and the cuts appear. only they differ from a simple test. for example, with the parameter x=1 a simple test results in 500 deals, with x=2 - 700 deals. I should optimise this parameter and x=1 now gets 1 deal, x=2 also gets 1 deal. My Expert Advisor is using virtual graphic modification, is it possible it is that the optimization fails to create a graphic object?

advise what could it be, I have tried it in the tester, orders are opening and closing normally, I have selected the parameter, I have tested all results are rejected, I have manually changed this parameter in the test, all is ok. I have activated the genetic algorithm during optimization and disabled it, changed my settings.
 

dzhini, eddy

Warning for duplicate posts. Duplicate posts deleted. There will be a ban from here on out.