A bug in the OrderSend() function ?

 

I've been struggling for 4 days now, and I can't seem to implement a seemingly simple thing. I have done similar things before with different indicators and candlesticks. I can't do it with a wristwatch.

The essence is primitive! As soon as the price approaches the mask of a certain period at a certain distance from i_thresholdFromMa (in this EA it is only one!), a pendentive is set. I have already removed all functions and filters that used to be available.

Here is the Buy function:

//+-------------------------------------------------------------------------------------+
//| Открытие длинной позиции                                                            |
//+-------------------------------------------------------------------------------------+
bool OpenBuy()
{
   int ticket = -1;
   double OOP = fastMa + buyHear * pt;             // Получаем значение цны открытия
   
   if ((ND(OOP) - Ask) >= g_stopLevel)             // Проверка цену открытия на стоплевел          
   {
       if (ND(OOP) > Ask)           // Проверка что цена открытия выше Ask, т.к. у нас вход отложенником
       {
           Print("Bid = ", Bid);
           Print("Ask = ", Ask);
           Print("fastMa = ", fastMa);
           Print("Цена покупки = ", fastMa + buyHear * pt);
           Print("i_thresholdFromMa * pt = ", i_thresholdFromMa * pt);
           ticket = OrderSend(Symbol(), OP_BUYSTOP, 0.1, ND(OOP), 3, 0, 0, NULL, i_magic, 0);
       }
   }
   if (ticket > 0)
   {
       return (true);
   }
   else
    
   Alert (GetLastError());
}

We can see that the OrderSend() has an opening price equal to the sum of variables fastMa + buyHear * pt

In the screenshot, we can see that there is NO such price!

The joint is in the mashka

Also you can see that there are no entries, where the price touched fastMa (red marker)

I deliberately took the 1st buffer, i.e. the penultimate bar, to know for sure that the penultimate bar has already closed and there won't be another close... I want to avoid that the last zero bar will not be re-recorded.

So that is the message of the order:

ticket = OrderSend(Symbol(), OP_BUYSTOP, 0.1, ND(OOP), 3, 0, 0, NULL, i_magic, 0);

IT IS OOP:

double OOP = fastMa + buyHear * pt;             // Получаем значение цны открытия
How is this possible?
Files:
test_ma_1.mq4  9 kb
 
hoz:

I've been struggling for 4 days now, and I can't seem to implement a seemingly simple thing. I have done similar things before with different indicators and candlesticks. I can't do it with a wristwatch.

The essence is primitive! As soon as the price approaches the mask of a certain period at a certain distance from i_thresholdFromMa (in this EA it is only one!), a pendentive is set. I have already removed all functions and filters that used to be available.

Here is the Buy function:

We can see that the OrderSend() has an opening price equal to the sum of variables fastMa + buyHear * pt

We can see on the screenshot that there is NO such price!

Also you can see that there are no entries, where the price touched fastMa (red marker)

I deliberately took the 1st buffer, i.e. the penultimate bar, to know for sure that the penultimate bar has already closed and there won't be another close... I want to avoid that the last zero bar will not be re-recorded.

So here is the message of the order:

A OOP:

How is this possible?

Are you still not going to bring in the logs?
 
Vinin:

Are you still not going to give me the logs?


Here's what's in the logs:

2013.02.06 17:54:05     2011.01.13 07:00  test_Ma_1 EURUSD,H1: open #3 buy stop 0.10 EURUSD at 1.31074 ok
2013.02.06 17:54:05     2011.01.13 07:00  test_Ma_1 EURUSD,H1: i_thresholdFromMa * pt = 0.0005
2013.02.06 17:54:05     2011.01.13 07:00  test_Ma_1 EURUSD,H1: Цена покупки = 1.3107
2013.02.06 17:54:05     2011.01.13 07:00  test_Ma_1 EURUSD,H1: fastMa = 1.3097
2013.02.06 17:54:05     2011.01.13 07:00  test_Ma_1 EURUSD,H1: Ask = 1.3099
2013.02.06 17:54:05     2011.01.13 07:00  test_Ma_1 EURUSD,H1: Bid = 1.3099
2013.02.06 17:54:05     2011.01.12 14:32  Tester: order #2, buy 0.10 EURUSD is opened at 1.29876
2013.02.06 17:54:05     2011.01.12 14:00  test_Ma_1 EURUSD,H1: open #2 buy stop 0.10 EURUSD at 1.29876 ok
2013.02.06 17:54:05     2011.01.12 14:00  test_Ma_1 EURUSD,H1: i_thresholdFromMa * pt = 0.0005
2013.02.06 17:54:05     2011.01.12 14:00  test_Ma_1 EURUSD,H1: Цена покупки = 1.2988
2013.02.06 17:54:05     2011.01.12 14:00  test_Ma_1 EURUSD,H1: fastMa = 1.2978
2013.02.06 17:54:05     2011.01.12 14:00  test_Ma_1 EURUSD,H1: Ask = 1.2978
2013.02.06 17:54:05     2011.01.12 14:00  test_Ma_1 EURUSD,H1: Bid = 1.2978
2013.02.06 17:54:05     2011.01.12 12:11  Tester: order #1, buy 0.10 EURUSD is opened at 1.29953
2013.02.06 17:54:05     2011.01.12 12:00  test_Ma_1 EURUSD,H1: open #1 buy stop 0.10 EURUSD at 1.29953 ok
2013.02.06 17:54:05     2011.01.12 12:00  test_Ma_1 EURUSD,H1: i_thresholdFromMa * pt = 0.0005
2013.02.06 17:54:05     2011.01.12 12:00  test_Ma_1 EURUSD,H1: Цена покупки = 1.2995
2013.02.06 17:54:05     2011.01.12 12:00  test_Ma_1 EURUSD,H1: fastMa = 1.2985
2013.02.06 17:54:05     2011.01.12 12:00  test_Ma_1 EURUSD,H1: Ask = 1.2987
2013.02.06 17:54:05     2011.01.12 12:00  test_Ma_1 EURUSD,H1: Bid = 1.2986
2013.02.06 17:54:04     test_Ma_1 inputs: i_TF=0; i_fastMaPeriod=10; i_magic=3333021; i_thresholdFromMa=5; buyHear=10; SellHear=10; 

That is, if you believe the logs, the purchase is where it should be. If you look at the screenshot, it's not there at all... The above screenshot shows that the pending order is in the wrong place. 10 from fastMa is not even close...

 

Hello, Victor! It opens for me, but it leaks. It opens when I tweak one line a bit:

   if ((ND(OOP) - Ask) >= MathMax(g_stopLevel,g_spread))// Проверка цену открытия на стоплевел          
Add the same for sall! Good luck!
 
borilunad:

Hello, Victor! It opens for me, but it leaks. And it opens when I tweaked one line a bit:

I would like to add the same for sall! Good luck!


Hello, Boris. Well, it opens in the same places it did before. Where it didn't open, it still doesn't open. It works very strangely on H1.

I switched to M15 and set the mask to MODE_OPEN on 0(zero) bar.

In general, if we observe it, the pending orders are placed where needed (I mean at M15 TF ), but the pending orders are not placed where they should obviously open. Here is a screenshot for example:

A joint with the shelves

borilunad:

Hello Victor! I have it open, but it pisses me off.

Boris, and it will... I mean, it's only the first stage... It's a long way to the finish line. All the conditions will come later, and will be decided gradually. For now, we just need to work out the current nuances.
 
hoz:


Hi Boris. Well, it opens in the same places it did before. Where it did not open, it still does not open. It works very strangely on H1.

I switched to M15 and set the wrist to MODE_OPEN on 0(zero) bar.

In general, if we observe it, the pending orders are placed where needed (I mean on M15 TF ), but the pending orders are not placed in the places where they should obviously open. For example, here is a screenshot:

Boris, and he will... I mean, it's only the first stage... It's a long way to the finish line. All the conditions will come later, and they'll be decided gradually. For now, we just need to work out the current nuances.

Victor, we should study the indicators and methods of their use in the EA. It seems to me that you want something that you do not know how to implement.

And another thing, you should not get hung up on very strict conditions, because price will certainly not behave the way you want it to in half of cases. So you have to imagine what you could do in the worst cases.

Frankly speaking, I still do not understand why it is important for you to enter on this bar and not on the other one. In my opinion, the main thing is to identify and use the trend that has started in time, rather than a certain entry point. Try and compare different Mashkeys, and then learn to use them as filters of unwanted entries rather than signals to enter, which often fails, and the other indicators are not better!

 
Try to plot the value of i_thresholdFromMa and t and observe in the tester, and the result of the comparison can also be plotted there
 
hoz:


Here's what's in the logs:

That is, if you believe the logs, the purchase is where it should be. If you look at the screenshot, it's not there at all... Above I gave a screenshot, you can see that the pending order is in the wrong place. The 10 from fastMa is nowhere near there...


Judging by the log, the OrderSend() function places the order correctly, at the price you passed it
 

PapaYozh:



Judging by the log, the OrderSend() function places the order correctly, at the price you pass it

Yes!!!

10 from fastMa is nowhere near there...

You have a 100 pips set.

More screenshot, it is correct.

 
r772ra:

Yes!!!

10 from fastMa is nowhere near there...

You have 100 p's set.

another screenshot, that's it.


Relative to the 4 digit it is 10pp. And on the 5-digit it's 100pp. What's wrong with that?
 
PapaYozh:

Judging by the log, the OrderSend() function places the order correctly, at the price you pass to it


Judging by the log, it is correct. But if you try to use the tester with the same settings, the orders are not being placed correctly periodically, which I have already said... That's what I wrote. I read the log, everything's nice and clear... Looking at the screenshot... (When I look at the chart, Inotice that the buy entry is lower than the buy entry... and this is contrary to the condition.

But it's also strange that I haven't noticed this on M5, BUT it has been noticed that some entries are missed.

Reason: