[ARCHIVE]Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Can't go anywhere without you - 5. - page 52

 

Here is my modify pending order function. When modifying, I set a new price and a new stoploss. The function works partially, but for some reason the tester is getting errors 1.

Is my function written correctly?

void MovingPendingOrders(/*int ticket, double newPrice*/)
{
  double priceS = NormalizeDouble((Low[1] - i_thresholdFromInput*pt),Digits);           // Новая цена открытия для OP_SELLSTOP
  double priceB = NormalizeDouble((High[1] + i_thresholdFromBasedSL*pt),Digits);        // Новая цена открытия для OP_BUYSTOP
  bool b_mod, s_mod;
  
  int total = OrdersTotal() - 1;
  int s_ticket, b_ticket;

  for(int i=total; i>=0; i--)
  {
    if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) continue;
      if(OrderMagicNumber() != i_myMagic) continue;
      {
        if(OrderType() == OP_BUYSTOP)
        {
          b_ticket = OrderTicket();
          b_mod = true;
        }
        if(OrderType() == OP_SELLSTOP)
        {
          s_ticket = OrderTicket();
          s_mod = true;
        }
      }
  }
  
  if(IsTradeAllowed())
  {
    if((b_mod) && (priceB > Ask)) OrderModify(b_ticket,priceB,priceS,0,0,Brown);
    if((s_mod) && (priceS < Bid)) OrderModify(s_ticket,priceS,priceB,0,0,Brown);
  }
  Print("MovingPendingOrders переоткрыл ордер по новой цене");
}
 
hoz:

Is my function written correctly?

 bool b_mod = false; 
 bool s_mod = false;
 
hoz:

Here is my modify pending order function. When modifying, I set a new price and a new stoploss. The function works partially, but for some reason the tester is getting errors 1.

Is my function written correctly?

...and on every tick you modify over and over again. ?!
 
BeerGod:

Please advise how to make an EA output a comment on top of a frame that covers the chart to make it easier to read.

I do not know how to do it now:

It should be like this:

We should use some kind of font. Maybe even create your own.
 
silatyt:
...and on every tick you modify over and over again. ?!

I didn't know where to put it, I messed up the Expert Advisor's logic by inexperience. To check the function, I put it in the start... Yes, it was on every tick, that's why the error. Then, after the function defining a new bar, I put it in and corrected the code asTheXpert told me and everything went as it should.
 

Good afternoon. Could you please tell me what a piece of EA code should look like, which is responsible for the following:

1. Goes through the parameters one by one (in a given range, eg from 10 to 20) of the indicator, on which the EA is based, until the condition to open the trade is not met.

2. If the condition after the search is not fulfilled - wait 5 minutes.

 
Good afternoon. Do you know if it's possible to send code execution from line 35 to line 18 (lines for example) with the standard mql4 tools. A kind of jumping in the code.
 
tpg_k156:
Good afternoon. Do you know if it's possible to send code execution from line 35 to line 18 with the standard mql4 tools (lines for example). A kind of jumping in the code.

Operators switch / if - else

and functions

 
sergeev:

switch / if - else operators

and functions



so it is possible to force the same function body to execute itself again? such as
int Gipo()                   // Пользовательская функция  
{
всякая фигня
if(получили-что-надо)
 {
 return(что-надо);
 }
else
 {
 Gipo();
 }
}
???
 
tpg_k156:

so it is possible to force the same function body to execute itself again? like


Yes. It's called recursion.



Reason: