Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 126

 
Forexman77:
Can you tell me how to find out the spread at the time of opening a trade, or better yet, how to get it displayed in the log?

Immediately after opening a trade:

ticket=OrderSend(......);
if(ticket>=0)Print("ticket #",ticket," Spread=",doubleToStr(Ask-Bid,Digits)); 
Your spread is in the log.
 
Sepulca:

Immediately after the opening of the transaction:

Your spread is in the log.



Thank you very much! Made an EA, on the tester it makes money, on the demo it's worse. It will probably do even worse on the real. I have not seen how many times I have looked at the visuals.

When I was watching the spread visually I did not see more than three pips. My idea is that during the strongest moves it is not shown at all or it widens so I do not have enough time to notice it.

Alpari has a low spread, but I assume it increases significantly during strong moves. At DucasCopi the spread is even smaller but large commissions, they get smaller if the account is several million dollars.

Have you done any research on spread size, with movements over 50 pips per minute? To what value does the average spread increase with these movements?

I asked Alpari, they didn't say.

 
FAQ:


When you pass a variable (array) into a function by value, a local variable is created inside the function and you declare it in the header: myFunct(int my_var). This way, changes of this variable cannot be seen outside the function. And in the case of an array, the compiler will remind you of this.

If you want the changes in the variable value to be visible outside (outside the function), pass the variables by reference : myFunct(int & my_var)


But yes. After all, an array is declared globally. But the change inside the function is local. This is why there are functions as microstructures. In order to locally implement micro-problems.
 

Good Profit to all! Please tell me how to make OrderOpenPrice() return the price with five decimal places. If the terminal returns 4 digits, if it's 5, it still returns 4, rounding off the fifth.

 
ivan180976:

Good Profit to all! Please tell me how to make OrderOpenPrice() return the price with five decimal places. If the terminal returns 4 digits, if it's 5, it still returns 4, rounding off the fifth.


DoubleToStr(number, precision)
 

Forexman77:
Forexman77:



Thank you very much! Made an EA, it makes money on the tester, it's worse on the demo. It will probably do even worse on the real. I've been watching the visuals for three times and I've seen three different spreads.

When I was watching the spread visually I did not see more than three pips. My idea is that during the strongest moves it is not shown at all or it widens so I do not have enough time to notice it.

Alpari has a low spread, but I assume it increases significantly during strong moves. At DukasCopi the spread is even smaller but large commissions, they get smaller if the account is several million dollars.

Have you done any research on spread size, with movements over 50 pips per minute? To what value does the average spread increase with these movements?

I asked Alpari, they did not say.


I was analysing the spread just on Friday, by the way it was on Alpari:

The thin yellow ones represent maximum spread per bar (I used a minute). Bold red - minimum spread per bar. As you can see, during the day spread ranges from 5 to 14 pips in five digits. But after 21:00 server time spread does not fall lower than 10 points, and at the end of the day it generally rises up to 52 points. I have caught an interesting moment before the sharp price change, the spread rises sharply:

 
artmedia70:

It's a bit of a pile-up...

right there:

for(i=0; i<p; i++)
      {
         if (OrderSelect(a[i][1], SELECT_BY_TICKET, MODE_TRADES)) // выделенное красным лишнее, тут pool не имеет значения
         {
             if (OrderCloseTime() == 0) ClosePosBySelect();
         }
      }

That's just for ease of perception. When I was writing, but otherwise, yeah, you don't have to. But it won't disturb me either.

It won't print any array values at all:

artmedia70:

Unprint the value of all cells of an array before the loop - maybe the doggy is digging there?



//+-------------------------------------------------------------------------------------+
//| Закрытие ордеров, отсортированных по размеру лотов                                  |
//+-------------------------------------------------------------------------------------+
void ClosePosBySortLots()
{
   double a[][2];
   int p = 0;
   
   for (int i=OrdersTotal()-1; i>=0; i--)
   {
      if (!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue;
      if (OrderMagicNumber() != i_magic) continue;
      if (OrderSymbol() != Symbol()) continue;
      if (OrderType() < 2)
      {
         p++;
         ArrayResize(a, p);
         a[p-1][0] = OrderLots();
         a[p-1][1] = OrderTicket();
      }
   }
//   pr ("ClosePosBySortLots(): " + "p = " + p);
   if (p > 0)
   {
      ArraySort(a, WHOLE_ARRAY, 0, MODE_DESCEND);
      
      for(i=0; i<=p; i++)
      {
          pr("a[i][1] = " + a[i][1]);
          i++;
      }
      
      for(i=0; i<p; i++)
      {
         if (OrderSelect(a[i][1], SELECT_BY_TICKET, MODE_TRADES))
         {
             if (OrderCloseTime() == 0) ClosePosBySelect();
         }
      }
   }
}

The output is empty at all...

 
hoz:

It doesn't output any array values at all:


It outputs nothing at all...

How empty? Does it print nothing at all, or are there still zeros in the array cells?
 

Why do you increase i in the body of the loop?

 for(i=0; i<=p; i++)
      {
          pr("a[i][1] = " + a[i][1]);
          i++;    // ??????????????????????????????????????
      }

and this: i<=p, why "or equal to" ?

 
Sepulca:


Yesterday the statistics came out at 15:30, "Change in Non-FarmEmployment ", "Unemployment Rate", the market reacts strongly to this statistic and spreads widen before it.

So before 3:30pm the spread widened to 28 pips on the five digits? If so, the opinion is that it was actually bigger.

For example, I put 5 pips in the tester and there is a profit. I set the current one (it is 33 pips now). Or should we select 50 pips in the tester instead of 5 pips as it is a five-digit value?