Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1818

 
Artyom Trishkin #:

Is the answer above unsatisfactory?

Well, you answered the wrong question.
I would like a yes/no answer, preferably with a link to the documentation.
 
secret #:
You answered the wrong question.
I would like a yes/no answer, preferably with a link to the documentation.

I have answered the question you asked.

Link to documentation.

Документация по MQL5: Торговые функции
Документация по MQL5: Торговые функции
  • www.mql5.com
Торговые функции - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 

Good time!

I have a question, but I have not found a solution on traders' web sites. The idea is the following, buttons BUY and SELL, lots, TP, SL, current price on the chart, but when I press them I get "magic" depending on modes:

1) we need one more parameter "step back in pips from ASK/BID" from the current price at the moment of BUY/SELL pressing. That is the price jumps and sometimes jumps a little bit higher and a little bit lower, which is comparable to commission, that is sometimes paid by broker (it is important for scalpers), for example, you set 5-8 points and the price may go to this distance, but not, the request is cancelled in some time, for example, you can set this parameter in seconds.

2)This mode is even more complicated and interesting. For example, minimal/navigational price for the last 1 minute is calculated (or you can set it manually - for 2 minutes, for 30 seconds) and at the moment of pressing BUY or SELL button a pending for this price is made.

All this should be registered in some table on a chart for convenience (of course, not in Expert Advisor's parameters).

Who has found, coded or seen something similar?

 

?

There is a need to get a ticket of the first open order that is still open.

Thought I could go through the ticket number and time=the oldest one by time, or I could just go through the tickets and choose the one with the lowest value.

Who has done this?

Maybe I'm not thinking correctly and there are good options
 
Alexander Avksentyev a ticket of the first open order that is still open.

Thought I could go through the ticket number and time=the oldest one by time, or I could just go through the tickets and choose the one with the lowest value.

Who has done this?

Maybe I'm not thinking straight at all and there are right options
//+----------------------------------------------------------------------------+
int FindTicketOrder()
  {
   datetime t=TimeCurrent();
   int result=-1;
   for(int i = OrdersTotal()-1; i>=0; i--)
     {
      if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
        {
         if(OrderSymbol() == Symbol() && OrderMagicNumber() == Magic)
           {
            if(t>OrderOpenTime())
              {
               t=OrderOpenTime(); result=OrderTicket();
              }
           }
        }
     }
   return(result);
  }
 
Порт-моне тв #:

Good afternoon!

Who has found, coded or seen anything like this?

Like this?


 

Good afternoon all !!!

Help to fix the code.

Here is a command to open first orders in EA's grid:

//-------------------------------------------------------------------+  Команда на открытие первых ордеров в сетке
   if((UseHour==1&&Hour()>=StartTime&&Hour()<=StopTime)||UseHour==0)
     {
      if(ObjectFind(0,"Начало торговли" + TimeToString(Time[0],TIME_DATE))!=0)
        {
         ObjectCreate(0,"Начало торговли"+TimeToString(Time[0],TIME_DATE),OBJ_VLINE,0,Time[0]+((StartTime - 1)*3600),0);
         ObjectSetInteger(0,"Начало торговли"+TimeToString(Time[0],TIME_DATE),OBJPROP_COLOR, clrBlue);
         ObjectCreate("signal1",OBJ_LABEL,0,0,0,0,0);
         ObjectSet("signal1",OBJPROP_XDISTANCE,100);
         ObjectSet("signal1",OBJPROP_YDISTANCE,300);
         ObjectSetText("signal1","| Начало торговли",14,"Times New Roman",clrBlue);
         ObjectCreate(0,"Окончание торговли"+TimeToString(Time[0],TIME_DATE),OBJ_VLINE,0,Time[0]+(StopTime*3600),0);
         ObjectSetInteger(0,"Окончание торговли"+TimeToString(Time[0],TIME_DATE),OBJPROP_COLOR, clrYellow);
         ObjectCreate("signal2",OBJ_LABEL,0,0,0,0,0);
         ObjectSet("signal2",OBJPROP_XDISTANCE,100);
         ObjectSet("signal2",OBJPROP_YDISTANCE,320);
         ObjectSetText("signal2","| Окончание торговли",14,"Times New Roman",clrYellow);
        }
      if(CountTrade(0)==0 && CountTrade(1)==0 && TradeSignal()==0 && Drawdown < TotalDrawdown)
         SendFirsOrder(0);
      if(CountTrade(1)==0 && CountTrade(0)==0 && TradeSignal()==1 && Drawdown < TotalDrawdown)
         SendFirsOrder(1);
     }

The code defines time of start and end of the first orders opening, but because of the difference in the Hour() function that takes part in calculation of trade time and Time[] array that takes part in visualization of start and end of trade on the chart

there is a discrepancy between estimated trade time and visualization on a chart.

Thanks for your help!

 
EVGENII SHELIPOV of trading on the chart

there is a discrepancy between estimated trade time and visualization on a chart.

Thanks for your help!

      if((UseHour==1&&TimeHour(Time[0])>=StartTime&&TimeHour(Time[0])<=StopTime)||UseHour==0)
 
Tretyakov Rostyslav #:
Like this?


So we have to try it. Where do you get it? Can you give me a link? And I think you've confused it with the breakeven point.

I'd appreciate it.

 
Порт-моне тв #:

So we have to try it. Where do you get it? Can you give me a link? And I think you've confused it with the breakeven point.

I'd appreciate it.

This is not what you wanted - this is an example. I was making an EA for semi-automated trading.


What you want to do is write it yourself.)

If you need my help.

Reason: