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

 
Andrey Sokolov:
DodBid anddPoint need to be prescribed separately?
is just Bid, and just Point. It's high time to understand that some people have them separately, some people have them redefined, and some people have them written directly, but the meaning is the same for all. You can write it however you want.
 
I have read the Tutorial for Dummies. I have an algorithm, but I can not properly prescribe it.
So the idea is that I access the data set of the last 86 candles, except 0. Each white candle is 1, each black candle is 0. If the closing price of 1 candle is equal to the opening price of 1 candle, then look at the closing price of 2 candles and if it is higher than the opening price of 1 candle, then put 0. If the closing price of 2 candles is equal to the opening price of 1 candle, then by the same principle, compare the opening price of 2 candles with the closing price of 2 candles.
The cycle runs every 15 min or 60
 
I'll attach what I wrote in the evening. I didn't take into account that there is a code onTime, which repeats the operation after a given period of time.
 

Hello.

Can you tell me how to correctly calculate the date of a future candle.

Let's say today is April 30th.

If (seg. Sunday) {the date of the next candle is May 1};

If (Mon) {the date of the next candle is May 1};

...

...

If (Segment Friday) {the date of the next candle on the 3rd May};

If (segment Saturday) {the date of the next candle on the 2nd of May};

 
Sergey:

Hello.

Can you tell me how to correctly calculate the date of a future candle.

Let's say today is April 30th.

If (seg. Sunday) {the date of the next candle is May 1};

If (Mon) {the date of the next candle is May 1};

...

...

If (Segment Friday) {the date of the next candle on the 3rd May};

If (segment Saturday) {the date of the next candle on the 2nd of May};


To the current date add the required number of seconds, or more precisely, the current time + (24*60*60). I hope you know how to find out what day of the week it is.
 
Sergey Gritsay:

Add the required number of seconds to the current date, or to be more precise, the current time + (24*60*60). How to find out what day of the week I hope you know.

Yes, thank you!
 

Hello.

Please tell me how to find a red horizontal line whose name is unknown.

When there is a name, I do this

   bool CL_R;
   color _Color=ObjectGet("hline", OBJPROP_COLOR);
   if(_Color==clrRed) CL_R =true;

How about without a name?

 
mila.com:

Hello.

Please tell me how to find a red horizontal line whose name is unknown.

When there is a name, I do this

How about without a name?

Try this (abstract example):

   for(uint i=0; i<ObjectsTotal(0,WRONG_VALUE,OBJ_HLINE); i++){
      string line_name=ObjectName(0,i,WRONG_VALUE,OBJ_HLINE);
      color  line_color=(color)ObjectGetInteger(0,name,OBJPROP_COLOR);
      Print("Линия с именем ",name," имеет цвет ",line_color);
      if(line_color==clrRed){
         Print("Найдена линия красного цвета с именем ",name);
         }
      }
 
Artyom Trishkin:

So try it (an abstract example):

Thank you, Artyom.

Always, you help out promptly )

 
Hi. Can you tell me how to make the total number of orders on a pair. At the moment it counts separately buy and sell.
int fMarketOrdersOpen(int type)
   { int c=0,aBuyCount=0,aSellCount=0;
      for(int i=0;i<OrdersTotal();i++)
      {if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
      {if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic_N)
      {switch (OrderType())
      {case OP_BUY:
       aBuyCount++;
       break;
       case OP_SELL:
       aSellCount++;
       break;}}} else{
            return(-1);}}
if(type==OP_BUY)c=aBuyCount+1; else if(type==OP_SELL)c=aSellCount+1;   
   return(c);
}