[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 779

 
ToLik_SRGV:

The OrderSend function has the wrong open/setting prices. This error makes it impossible to place orders correctly, which means that the EA wants to place more orders for some reason, and cannot do so because of this error. Please check if the prices of pending orders are normalised and if all orders are in place.

If you don't mind looking at it with your professional eye, there is nothing else there

Files:
test_21_3.mq4  16 kb
 
FoxUA:

If you don't mind looking at it with your professional eye, there is nothing else there.

The unpacking shows that the error occurs in the block for pending orders, you are trying to put them at a negative price.

 
ToLik_SRGV:

The unpacking showed that the error occurs in the pending order setting block, you are trying to put them at a negative price.


how do you fix it, except for knocking your head against the wall ;) where did i go?

 
ToLik_SRGV:

Not according to the idea. Here's an excerpt from a textbook:

P.S.
About Petyka, a hundred years old, and still funny :)))


"... as well as the stated stop-order prices of market orders that are in the freeze zone...".

It turns out, however, that this has an effect... and you have to take it into account - I just need to remove the announced stop order level on an open position... And if you have already entered the freeze zone, you just have to wait for the close... or a pullback...

Thanks, buddy!!!

ZS. And about Petya - here the situation is the same... - I say I put 1.6 - it works, I put 1.8 - it doesn't work... And even 1.9 doesn't help!!! What a mess!!! It's horrible. Ooh!
What are the numbers? Litres or something.

 
FoxUA:

Um, how do you fix it, apart from slamming your head against the wall ;) where did I get lost?

I recognise the prints from Kim's functions... Go to his thread - he has a script after each function to check it. It doesn't get any clearer than that...
 
artmedia70:
I recognise the prints from Kim's functions... Go to his branch - he has a script after each function to check it. It doesn't get any clearer than that...


yes it's from his library which they gave me here, so it's the same scripts that are in the post box. and i added it so there's no reaction

{SetOrder(sy, OP_BUYLIMIT, Lot*3, NormalizeDouble(PrAskLim, Digits), PrAskLim-StopLoss*po, PrAskLim+TakeProfit*po,mn);
    SetOrder(sy, OP_BUYSTOP,  Lot,   NormalizeDouble(PrAskSt, Digits),  PrAskSt-StopLoss*po,  PrAskSt+TakeProfit*po,mn);
    SetOrder(sy, OP_SELLLIMIT,Lot*3, NormalizeDouble(PrBidLim, Digits), PrBidLim+StopLoss*po, PrBidLim-TakeProfit*po,mn);
    SetOrder(sy, OP_SELLSTOP, Lot,   NormalizeDouble(PrBidSt, Digits),  PrBidSt+StopLoss*po,  PrBidSt-TakeProfit*po,mn);
     } 
 
FoxUA:

Um, how do you cure this, apart from banging your head against the wall ;) where did I get lost?

Let's move on.
Negative numbers get into variables from StopLossLastPos() and TakeProfitLastPos() functions. There they appear due to failure of their work, i.e. -1 is a sign of failure to get the last value of StopLoss and TakeProfit. You don't check success of getting the last values, so -1 gets into your work as a price, then from it you count values for setting pending orders... and so on.

The result is a snowball effect and a sea of bugs. Now in the tester I'll see how it works and I'll report back...


 
ToLik_SRGV:

Moving on.
Negative numbers get into variables from StopLossLastPos() and TakeProfitLastPos() functions. They appear there due to failure, i.e. -1 is a sign of failure to get the last value of StopLoss and TakeProfit. You don't check success of getting the last values, so -1 gets into your work as price, then from it you count values for setting pending orders... and so on.

The result is a snowball effect and a sea of errors. Now I'm going to watch it in the tester and report back...




I wonder how it's like that.

 
FoxUA:

Yeah, I wonder how it is.

I'll sign off.
The error is in the logic. It's built around two market orders. But here we have a subtle point: function OrdersTotal() returns not the total number of open market orders, but all of them that are in the market, along with pending orders that are set.
As a result, during a trade, there happens a time when there are no market orders, at the time when pending orders continue to hang, that is, OrdersTotal() returns more than 0, accordingly, your block opening market orders if(total_order==0), they can not open, But new pending orders may (in the moment when OrdersTotal() returns 2), but since there are no market orders, the StopLossLastPos() and TakeProfitLastPos() functions return -1, while the condition for opening pending orders is if(total_order==2), so they catch -1 and use it as the price.

 
ToLik_SRGV:

I'll sign off.
There's an error in the logic. It is built around two market orders. But here we have a subtle point: function OrdersTotal() returns not the total number of open market orders, but all of them that are in the market, along with pending orders that are set.
As a result, during a trade, there happens a time when there are no market orders, at the time when pending orders continue to hang, that is, OrdersTotal() returns more than 0, accordingly, your block opening market orders if(total_order==0), they can not open, But new pending orders may (in the moment when OrdersTotal() returns 2), but since there are no market orders, the StopLossLastPos() and TakeProfitLastPos() functions return -1, while the condition for opening pending orders is if(total_order==2), so they catch -1 and use it as the price.


i got it, i'll change it now. thanks a lot.