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

 

Poor little guy.

 
simpleton:
Not you.
 
Hello. Any advice? I'm trying to calculate StopLoss from the low and high of the 1st bar, after placing pending order, for buy and sell respectively. But i got no result, only 130 error, that's all. Thanks in advance.
if(ticket>0)
           {
            SL = NormalizeDouble(Low[1] - StopLoss*Point, Digits);
            {
               if(OrderModify(ticket, OrderOpenPrice(), SL, 0, 0))
...
//+-------------------------------------------------------------------------+
if(ticket>0)
           {
SL = NormalizeDouble(High[1] + StopLoss*Point, Digits);
            {
               if(OrderModify(ticket, OrderOpenPrice(), SL, 0, 0))
...                     																							
 
You're normalising the wrong thing.
 
Petiyashaket:
If you can explain it in a line of code and with comments, as in my previous code, I'll be extremely grateful.

"I have doubts", and I can't help feeling that it's all about the caching mechanism of the market environment.

So that the terminal doesn't have to "run to the server" for every occasion, such as OrdersTotal(), OrderSymbol() etc., the market environment is copied into some cache, and it seems to be different for each script, but the script deals only with this cache. The cache is NOT automatically updated during the entire runtime of the main script function even after successful execution of functions like OrderSend() changing the market environment on the server, therefore, the order appearing in the script "is not visible", i.e. it makes an illusion of its absence. It simply cannot be detected in the for loop, which is why OrderModify() is not called. This is a hypothesis that arose on the basis of vague doubts and incomprehensible feelings.

The described cache can be forcibly updated using RefreshRates() call, for example, immediately after OrderSend() is called. Check if the hypothesis is correct.

If, among other things, RefreshRates() returns true, then this is an additional indirect confirmation of the hypothesis.

 
Petiyashaket:
If you explain it to me in a line of code and with comments, as in my previous code, I will be extremely grateful.
If you don't understand it, read it here. And here. Then make the variables not lose their meaning on each tick and organize the loop in a proper way.
 
simpleton:

"I have doubts", and I can't help feeling that it's all about the caching mechanism of the market environment.

So that the terminal doesn't have to "run to the server" for every occasion, such as OrdersTotal(), OrderSymbol() etc., the market environment is copied into some cache, and it seems to be different for each script, but the script deals only with this cache. The cache is NOT automatically updated during the entire runtime of the main script function even after successful execution of functions like OrderSend() changing the market environment on the server, therefore, the order appearing inside the script "is not visible", i.e. it makes an illusion of its absence. It simply cannot be detected in the for loop, which is why OrderModify() is not called. This is the hypothesis that arose based on vague doubts and unconvincing feelings.

The described cache can be forcedly updated using RefreshRates() call, for example, immediately after OrderSend() call. Check if the hypothesis is correct.

If, among other things, RefreshRates() returns true, this is an additional indirect confirmation of the hypothesis.

Do you take drugs?
 
noob1:
Hello. Please advise, if i know, i am trying to calculate a StopLoss from low and high of 1st bar, after a pending order is placed, for buy and sell respectively. But i got nothing, only 130 error and nothing else. Thank you in advance.

Check if OrderOpenPrice() is too close to SL, and if stops are "on the right side of price". You can read about it here:

StopLoss and TakeProfit prices cannot be too close to the market. The minimum stop distance in pips can be obtained using the MarketInfo() function with the MODE_STOPLEVEL parameter. Error 130 (ERR_INVALID_STOPS) will be generated in case of wrong or non-normalized stops.

In this case, that is, for a pending order, the "market" is its "pending open price".

 
tara:
You are normalising the wrong thing.
From the documentation:
 
noob1:
Hello. Any advice? I'm trying to calculate StopLoss from the low and high of the 1st bar, after placing pending order, for buy and sell respectively. But i got no result, only 130 error, that's all. Thank you in advance.
Is it the same ticket? And the distance to stoploss may be too small.