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

 
Artyom Trishkin:
The rubbish is in the buffers. First you have to enter a blank value into all buffers to be drawn (if they are arrow buffers), and only then calculate the indicator. I can't see the code from my mobile, I can't say exactly.

You mean do ArrayInitialize first?

 
Roman Sharanov:

You mean do ArrayInitialize first?

This is already in place.
In the indicator loop, you have to assign the buffer to an "empty value" in the buffer cell with the loop index.
 
Artyom Trishkin:
This is already in place.
In the indicator loop, you need to assign an "empty value" to the buffer cell with the loop index.

OK, thank you.

 
Artyom Trishkin:

Yes. Study the example:

Thank you, I will go to the source of knowledge :-)


Forum on trading, automated trading systems & strategy testing

Any questions for beginners on MQL4, help and discussion on algorithms and codes

Artyom Trishkin, 2019.03.31 09:10

It's already there.
In an indicator loop, you need to assign a buffer value "empty value" to the buffer cell with the loop index.

Is it that every array needs to be explicitly given a null value?

This rubbish can be dealt with via PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0) ?

 
psyman:

Thanks, I'll go to the knowledge source :-)



Is it necessary to explicitly set each array to a zero value?

Can this rubbish be dealt with by PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0) ?

Put the cursor on the function name in the editor and press F1 and a miracle will appear.
 
Downloaded the bot, what can this error be related to?
Everyone who installed the bot works, I'm the only one who has this. Reinstalled the terminal, opened it as an administrator, nothing helps

 
No errors or warnings during compilation. But positions do not open (opened only 1 position to buy and closed it on the take line).

I don't know what the problem is yet.

//+------------------------------------------------------------------+
//|                                    Test advisor on iDeMarker.mq4 |
//|                        Copyright 2017, MetaQuotes Software Corp. |
//|                                         https:/goga342@yandex.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
//------------------параметры советника -------------------------------
extern double lots=0.01; //
extern int Magic=1111678111;
extern int Slippage=1;
//double sell_level=0.7;
//double buy_level=0.3;

extern double StopLoss=50;
extern double TakeProfit=50;
extern double TrailingStop=30;
double SL,TP;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   if(Digits==3 || Digits==5)
     {
      TakeProfit *=10;
      StopLoss   *=10;
      Slippage   *=10;
     }
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
int start()
  {
   int ticket;
// int cnt,total;

// открытие продаж

   if(CountSell()==0 && iCustom(NULL,0,"ZigZag_Rosh",12,5,3,1,0)==Low[0] && iCustom(NULL,0,"ZigZag_Rosh",48,20,12,1,0)==Low[0])
     {
      SL = NormalizeDouble(Bid+StopLoss*Point, Digits);
      TP = NormalizeDouble(Bid-TakeProfit*Point, Digits);
        {

         ticket=OrderSend(Symbol(),OP_SELL,lots,Bid,3,0,Bid-TakeProfit*Point,"macd sample",16384,0,Red);
         if(ticket>0)
           {
            // закрытие продаж
            if(CountSell()>0 && iCustom(NULL,0,"ZigZag_Rosh",12,5,3,0,1)==High[0] && iCustom(NULL,0,"ZigZag_Rosh",48,20,12,0,1)==High[0])
              {
               for(int i=OrdersTotal()-1; i>=0; i--)
                 {
                  if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
                    {
                     if(OrderMagicNumber()==Magic && OrderType()==OP_SELL)
                        if(OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,clrNONE))
                           Print("Ошибка открытия ордера на покупку !");
                    }
                 }
              }
           }
        }
     }
// открытие покупок

   if(CountBuy()==0 && iCustom(NULL,0,"ZigZag_Rosh",12,5,3,0,1)==High[0] && iCustom(NULL,0,"ZigZag_Rosh",48,20,12,0,1)==High[0])
     {
      TP = NormalizeDouble(Ask+TakeProfit*Point, Digits);
      SL = NormalizeDouble(Ask-StopLoss*Point, Digits);
        {
         ticket=OrderSend(Symbol(),OP_BUY,lots,Ask,3,0,Ask+TakeProfit*Point,"macd sample",16384,0,Green);
         if(ticket>0)
           {
            // закрытие покупок    
            if(CountBuy()>0 && iCustom(NULL,0,"ZigZag_Rosh",12,5,3,1,0)==Low[0] && iCustom(NULL,0,"ZigZag_Rosh",48,20,12,1,0)==Low[0])
              {
               for(int i=OrdersTotal()-1; i>=0; i--)
                 {
                  if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
                    {
                     if(OrderMagicNumber()==Magic && OrderType()==OP_BUY)
                        if(!OrderClose(OrderTicket(),OrderLots(),Bid,Slippage,clrNONE))
                           Print("Ошибка открытия ордера на продажу!");
                    }
                 }
              }
           }
        }
     }
   return(0);
  }
//+------------------------------------------------------------------+
int CountSell()//проверкна открытие ордеров на продажу
  {
   int count=0;

   for(int trade=OrdersTotal()-1; trade>=0; trade--)
     {
      if(OrderSelect(trade,SELECT_BY_POS,MODE_TRADES)==true)
        {
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic && OrderType()==OP_SELL)
           {
            if(OrderType()==OP_SELL)
               count++;
           }
        }
     }
   return(count);
  }
//+------------------------------------------------------------------+
int CountBuy()// проверкна открытие ордеров на покупку
  {
   int count=0;
   for(int trade=OrdersTotal()-1; trade>=0; trade--)
     {
      if(OrderSelect(trade,SELECT_BY_POS,MODE_TRADES)==true)
        {
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic && OrderType()==OP_BUY)
           {
            if(OrderType()==OP_BUY)
               count++;
           }
        }
     }
   return(count);
  }
//+------------------------------------------------------------------+
 
Roman Sharanov:
I downloaded the robot, what can this error be related to?
I do not know what to do with it. I reinstalled the terminal, opened it as an administrator, nothing helps.

The only thing left to do is to reinstall the operating system, or change... you know what.




You got the wrong idea. I meant the Expert Advisor.

 
Alexey Viktorov:

The only thing left to do is to reinstall the operating system, or change... you know what.




You got the wrong idea. I meant the advisor.

What is the reason?
 
Roman Sharanov:
What is the reason?

I don't try to figure it out or fix it in such cases. I always throw it away without regret and forget it.

Reason: