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

 
Alexey Viktorov: Slippage on opening and closing.

Alexey! MT5 has become generally verbose today - duplicates TP in the commentary:


 
STARIJ:

Thank you Alexey!!! Thought so too - but how do you check it ? and how do you know what it is? and why are there no real accounts. Maybe because it's old and the demo account is new?

The difference in tp price and closing price of the order divide by _Point and reconcile with the entry in the order comment. This is exactly how we have found out. Random coincidence cannot last indefinitely and stably. I guess there are no such slippages on the real account. Although I used to have them. I was calculating it on the real account. At first I noticed that the close was on tp and the close price was not highlighted in green.

 

Hello, can you help me, please?

I want, at any time, to know the number of the bar where the indicator arrow is.

In the example, tried to fill the buffer if the arrow is on the tenth bar.

int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---
   if(rates_total<2) return(0);
   int limit=rates_total-prev_calculated;
   if(limit>1)
     {
      limit=rates_total-2;
      ArrayInitialize(BufferUP,EMPTY_VALUE);
      ArrayInitialize(BufferDN,EMPTY_VALUE);
     }
   for(int i=limit; i>=0; i--)
     {
      for(int il=i+1;il<=i+300;il++)
        {
         if(NormalizeDouble(iCustom(NULL,0,"Arrow v.3",0,il),Digits)!=EMPTY_VALUE
            )
           {
            num_buy=il;
            break;
           }
        }
      //
      if(num_buy==10)
        {
         BufferUP[i+1]=low[i+1]-distance*MyPoint;

        }

      for(int il=i+1;il<=i+300;il++)
        {
         if(NormalizeDouble(iCustom(NULL,0,"Arrow v.3",1,il),Digits)!=EMPTY_VALUE
            )
           {
            num_sell=il;
            break;
           }
        }
      if(num_sell==10)
        {
         BufferDN[i+1]=high[i+1]+distance*MyPoint;
         
         
        }

      Comment(num_buy,"num_sell",num_sell);
     }
//--- return value of prev_calculated for next call

   return(rates_total);
  }

Where is it wrong?

 
mila.com: Hello, can you help me, please?
I want to know at any time the number of the bar where the indicator arrow is.
In the example, tried to fill the buffer if the arrow is on the tenth bar.
Where is it wrong?

Usually when I check it, I run it and see the result. This is just a part of the code. Everything is very small here, it's hard to see - in my editor it's bigger

if(NormalizeDouble(iCustom(NULL,0,"Arrow v.3",0,il),Digits)!=EMPTY_VALUE)
{
    num_buy=il;
    break;  // Это выход из цикла. Остальные бары лишаются чести быть просмотренными. Ошибка здесь?
}
 

Hello, could you advise how to make an indicator save data to a file

instead of RSI indicator Williams' Percent Range


//| expert start function |

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

int start()

{

//----

int iRSI;

iRSI=FileOpen("File.txt", FILE_CSV|FILE_WRITE, '\t');

//------------------------------------------------//

//-------------------------------------------------//

if(iRSI>0)

{

FileWrite(iRSI, [0]);

FileClose(iRSI);

}

//----

return(0);

}

 
STARIJ:

Everything is very small here,

There is an option in the browser to change the scale )

STARIJ:
Ошибка здесь?


Unfortunately, this is not the only error.

The correct value is displayed in the comment, from the current bar, now num_buy 9

Why is there no condition in the history?

if(num_buy==10)

I checked it, the EA opens a position when the arrow is on bar 10

for(int il=1;il<=300;il++)
        { 
        if(NormalizeDouble(iCustom(NULL,0,"Arrow v.3",0,il),Digits)!=EMPTY_VALUE)
            
           {
            num_buy=il;
            break;
           }
        }
        if(num_buy==10)
           {
            B_OrderSend();
           }

How do I place a point in the indicator when the arrow is on bar 10?

 
mila.com:

In the browser there is an option to change the scale )


Unfortunately, this is not the only error.

The comment displays the correct value, from the current bar, now num_buy 9

Why is there no condition in the history?

Checked in the EA, opens position when arrow is on bar 10

How do I place a point in the indicator when the arrow is on bar 10?

You interrupt the loop as soon as you see the first non-blank indicator value. That's why it doesn't reach 10.

 
Artyom Trishkin:

So, you break the loop here as soon as you encounter the first non-empty indicator value. That's why it doesn't reach ten.

I removed a break from the indicator; as recommended by STARIJ

still no point on the chart, and in the comment writes the numbers of the third and fourth arrows, but the first and second (closest to the current date) does not see.

 
mila.com:

In the indicator I removed the break; as recommended by STARIJ

still no point on the chart

But you left it in the Expert Advisor. And what does it do? It finds the first point of the indicator and... break

 
Artyom Trishkin:

But the councillor was left behind. So what does it do? It finds the first point of the indicator and... break

I made the Expert Advisor to check the possibility, it opens correctly, but in the indicator it does not see values of the nearest two indicator buffers "Arrow v.3" at all

Reason: