[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 943

 
         OrderClose(OrderTicket(),OrderLots(),Ask,3,Red);    

And we also need to put a check on such closing code, that if it closed FALSE - then it will close again???

initially there is an IF check if it passes the OrderClose, maybe it is enough to put something like return(1);???

 

Do me a favour:

check the StopLoss and TakeProfit (not in pips, but in absolute prices) set for the pending BuyStop I write it down as follows:

if ((Bid-StopLoss)/Point < MarketInfo(Symbol(),MODE_STOPLEVEL))
      SL = NormalizeDouble((Bid - (MarketInfo(Symbol(),MODE_STOPLEVEL)*Point)),Digits); // устанавливаем SL на минимально возможном уровне
         else SL = StopLoss;              // StopLoss - изначально заданный ценовой уровень
   if ((TakeProfit - Ask)/Point < MarketInfo(Symbol(),MODE_STOPLEVEL))
      TP = NormalizeDouble((Ask + (MarketInfo(Symbol(),MODE_STOPLEVEL)*Point)),Digits); // устанавливаем ТР на минимально возможном уровне
         else TP = TakeProfit;            // TakeProfit - изначально заданный ценовой уровень
Is it done correctly?
 

How do I make the script ask for input parameters? :)

That is, I want the user to be able to set the required parameters in the relevant box when launching the script, just can't find how to do it yet.

 
Mathers:

How do I make the script ask for input parameters? :)

That is, I want the user to be able to set the required parameters in the relevant box when launching the script, just can't find how to do it yet.

#property show_inputs
 
Thank you
 
Good afternoon, I'm new to mql programming, I can't get the algorithm right. I am new to mql programming and i can't write it correctly. I need to enter the market, let's say, at the price of X to buy and put two buy orders at X + 50 points and X + 100 points relatively. I would like to see how to write such a program code. I'm spending a lot of time studying by myself with mql4, but I don't know how to program it, it's very difficult. But there is a mad desire :).
 
Here's a simple example...
Files:
lywqkt.mq4  1 kb
 

Please advise who knows how to set a timer - for example event A happened and after 5 seconds for example event B happens...

Thank you!

 
Lim1:

Please advise who knows how to set a timer - for example event A happened and after 5 seconds for example event B happens...

Thank you!

the sleep() function is interactive, if you don't understand it, type anywhere in the code, put your cursor on it and press F1 (very useful)
 
if (OrderType() == OP_SELL) 
          {
            diff = OrderStopLoss()-Ask-Point*TrailingStop;
            if (diff>0) 
              {
                if (!OrderModify(OrderTicket(), OrderOpenPrice(), Ask+Point*TrailingStop,0,0))
                       Print("Error ", GetLastError(), ": Start()->OrderModify() [trailing stop]");
                else 
                       Print("Trailing stop on #", OrderTicket()," [place stop loss at ", 
                               Ask+Point*TrailingStop, "]");
              }
            return(0);
          }        
   if (OrderType() == OP_SELL) 
          {
            diff = OrderStopLoss()-Ask-Point*TrailingStop;
            if (diff>0) 
              {
                if (!OrderModify(OrderTicket(), OrderOpenPrice(), Ask+Point*TrailingStop,0,0))
                       Print("Error ", GetLastError(), ": Start()->OrderModify() [trailing stop]");
                else 
                       Print("Trailing stop on #", OrderTicket()," [place stop loss at ", 
                               Ask+Point*TrailingStop, "]");
              }
            return(0);
          }  
Found the code for TrailingStop, but it doesn't work correctly, i.e. Trailing is constantly moving relative to the Tick chart... It doesn't pull up to the required value, but swings up - up, and if it went down - down...
Reason: