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

 
AlexeyVik:

Because you have to read the documentation all the way through. And there is an example in it

Thanks! In the example this"ArrayResize" messed up my head. :)

In the documentation, I think these brackets "array[]" are unnecessary because you may understand from the word itself that it is an array. :)

int  ArrayInitialize( 
   int     array,     // инициализируемый массив 
   int     value        // значение, которое будет установлено 
   );
 
AlexeyVik:

So subtract the elapsed time from the number of seconds in a period...



Thanks a lot, I've been using mql4 for five years and didn't know there was such a function, thanks a lot again ))

Alas, it did not help, on the fifth this check does not work...((

 
if(id==CHARTEVENT_MOUSE_MOVE)
                                       {
                                       // получ и преобраз координ мыши
                                       ChartXYToTimePrice(0,lparam,dparam,huin,timeVline,priceVline);
                                       // переместить нa них линию
                                       ObjectSet(stockname+"timeVline",OBJPROP_TIME1,timeVline);                                     
                                              
                                        } 
this piece. on a real chart, where the indicator is running from scratch, it works as it should.
I can't see what's wrong with it, but if I run the indicator in the tester, the line does not move after the mouse.
i also don't know what does the variable i called huin do?
 
ara66676:

Thanks a lot, I've been using mql4 for five years and didn't know there was such a function, thanks a lot again ))

Alas, it did not help, on the fifth this check does not work...((

So you should have specified... The principle is the same.

TimeCurrent() - (datetime) SeriesInfoInteger(_Symbol, PERIOD_M5, SERIES_LASTBAR_DATE);


You can also use CopyTime()...


No... It's not like that.

(datetime) SeriesInfoInteger(_Symbol, PERIOD_M5, SERIES_LASTBAR_DATE) + PeriodSeconds(PERIOD_M5) - TimeCurrent():
 

GURUS TELL ME!!!! Why does a Sell order not open????

//+------------------------------------------------------------------+

//| ProjectName |

//| Copyright 2012, CompanyName |

//| http://www.companyname.net |

//+------------------------------------------------------------------+

#property strict

//+------------------------------------------------------------------+

//| Expert initialisation function |

//+------------------------------------------------------------------+


input double L=0.01;

input int TakeProfit = 150;

input int StopLoss = 150;

input int Magic = 0;

//+------------------------------------------------------------------+

int b=0;

int s=0;

//+------------------------------------------------------------------+

int OnInit()

{

return(0);

}

//+------------------------------------------------------------------+

//| Expert tick function |

//+------------------------------------------------------------------+

void OnTick()

{

//+------------------------------------------------------------------+

//| Open a Buy order ||

//+------------------------------------------------------------------+

if(b==0)

{

b=My_Fun_b();

}

//+------------------------------------------------------------------+

//| Open a Sell order |

//+------------------------------------------------------------------+

if(s==0)

{

double priceb=My_Fun_p();

Comment("The price of the Buy order",priceb);

if(priceb==Bid) /*NOT EXECUTED WHY*/.

{

s=My_Fun_s(priceb);/*NOT EXECUTED, WHY//

}

}

}

//+------------------------------------------------------------------+

//| expert deinitialization function |

//+------------------------------------------------------------------+

void OnDeinit(const int reason)

{


}

//+------------------------------------------------------------------+

//| Custom function for opening the first order (buy) |

//+------------------------------------------------------------------+

int My_Fun_b()

{

b=OrderSend(_Symbol,0,0.01,Ask,0,0,",414,0,clrBlue);

return(b);

}

//+------------------------------------------------------------------+

//| User-defined function for determining the price of the first order (buy) |

//+------------------------------------------------------------------+

double My_Fun_p()

{

double pb=0;

if(OrderSelect(0,SELECT_BY_POS,MODE_TRADES)==true)

if(OrderMagicNumber()==414)

{

pb=OrderOpenPrice();

}

return(pb);

}

//+------------------------------------------------------------------+

//| Custom function to open first order (sell) |

//+------------------------------------------------------------------+

int My_Fun_s(double priceb)

{

s=OrderSend(_Symbol,1,0.01,priceb,0,0,",0,0,clrRed);

return(b);

}

//+------------------------------------------------------------------+


Files:
test.mq4  2 kb
 
AlexeyVik:

Well, you should have specified... The principle is the same


You can also use CopyTime()...


No... It's a little different.

Thank you, it worked. Correct variant:

(TimeCurrent() - (datetime) SeriesInfoInteger (NULL , PERIOD_M5 , SERIES_LASTBAR_DATE))>290

Thanks again, now we can remove mountains of code and use this line!!! ))

 
ara66676:

Thank you, it worked. Correct variant :

(TimeCurrent() - (datetime) SeriesInfoInteger (NULL , PERIOD_M5 , SERIES_LASTBAR_DATE))>290

Thanks again, now we can remove mountains of code and use this line!!! ))

Apparently it didn't matter if it was the elapsed time from the bar opening or the time to the end of the bar. This variant will give exactly the elapsed time from the start of the bar and not the time to the end of the bar.

And what is the number 290? Why do we need to check for more than 290?

 
AlexeyVik:

Apparently it didn't matter if it was the elapsed time from the start of the bar or the time to the end of the bar. This option would give exactly the elapsed time from the start of the bar, not the time to the end of the bar.

What is the number 290? Why do we need to check for more than 290?

IN THIS CASE, THE NUMBER 290 SHOWS THAT MORE THAN 290 SECONDS HAVE PASSED SINCE THE BAR OPENED. SORRY FOR THE CAPTION, IT'S STUCK ))))
 

Compile Error (2): Magic - undeclared identifier

Please help me to correct

bool CheckExists(int Type)
{
bool Result = True;
for(int i = 0; i < OrdersTotal(); i++)
if(OrderSelect(i, SELECT_BY_POS))
if(OrderType() == Type && OrderMagicNumber() == Magic && OrderSymbol() == Symbol())
if(OrderOpenTime() >= Time[0])
Result = False;
for(i = 0; i < OrdersHistoryTotal(); i++)
{
if(OrderSelect(i, SELECT_BY_POS, MODE_HISTORY))
if(OrderType() == Type &&& OrderOpenTime() >= Time[0]
&& OrderMagicNumber() == Magic && OrderSymbol() == Symbol())
Result = False;
}

return(Result);
}

 
ara66676:

Please help me, I can't find an answer to a simple question.

intTimeSeconds(,,,,,)Returns the number of seconds elapsed since the beginning of the minute of the specified time.

If I insert the bar open time into the function

TimeSeconds(iTime(NULL,PERIOD_M5,0))

how can I know that there is 10 seconds left before the bar closes?

You can't. It can consist of a single tick or of tens or hundreds of ticks. It may not take place at all due to the lack of ticks. You can estimate the time of the bar interval finishing, but it will be closed only at the moment of the next bar opening.