[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 308

 
What time is it now in the US? What time does it open/close in the US? What time does it open/close in Japan? Just with the abolition of winter time it's a bit unclear...and are Europe, Asia, USA setting their clocks ?
 
Elenn:
The solution is really original, we should try it. But when the array is re-initialised, won't the data be lost due to re-initialisation?

If you increase the size of the array, the data previously entered will not be lost. And the "captured" (new) cells will contain RAM rubbish. And if you shrink the array, the data that was in the shrinking cells will be irretrievably lost. This is the basics of programming.
 
vilard:

How long does it take for a MODE_TRADE pending order to become a MODE_HISTORY order?

In no time at all. Pending orders are not stored in the history.

As soon as it is transformed into a market order and is closed - then it will become history, but with a market order type.

For example:

If there was OP_BUYSTOP, then it was converted to OP_BUY. After its closing, it will be placed in the history.

BUT, after conversion from OP_BUYSTOP to OP_BUY, the original OP_BUYSTOP will not be in history.

 
001:

Good evening, please advise. There are two indicator values on different bars. How to draw a line through them and how to work with it in the indicator? Thank you!

The line between them can be drawn using the OBJ_TREND object. The first coordinate is the time and price of the first bar, the second coordinate is the time and price of the second bar.

Function:

//+----------------------------------------------------------------------------+
void SetTLine(color cl, string nm, datetime t1=0, double p1=0, datetime t2=0, double p2=0, int st=0, int sz=0) {
   if (ObjectFind(nm)<0) ObjectCreate(nm, OBJ_TREND, 0, 0, 0, 0, 0);
   ObjectSet(nm, OBJPROP_TIME1    , t1);
   ObjectSet(nm, OBJPROP_PRICE1   , p1);
   ObjectSet(nm, OBJPROP_TIME2    , t2);
   ObjectSet(nm, OBJPROP_PRICE2   , p2);
   ObjectSet(nm, OBJPROP_COLOR    , cl);
   ObjectSet(nm, OBJPROP_STYLE    , st);
   ObjectSet(nm, OBJPROP_WIDTH    , sz);
   ObjectSet(nm, OBJPROP_RAY      , 0);
}
//+----------------------------------------------------------------------------+

I hope everything is clear in it.

cl - object colour, nm - object name, t1, p1 - origin coordinates, t2, p2 - end coordinates, st - line style, sz - size.

You can also add ray: 1 - ray, 0 - segment. The last line of this function contains a segment. Instead of 0 you can put the name of the parameter to be passed.

As for how to work with it (this line) in the indicator - you need to know what you need from it. But the data on it (the line) can be obtained using the standard function

ObjectGet("object name",required object property);

 
artmedia70:

You can draw a line between them using the OBJ_TREND object. The first coordinate is the time and price of the first bar, the second coordinate is the time and price of the second bar.

Function:

I hope that everything is clear in it.

cl - colour of the object, nm - object name, t1, p1 - origin coordinates, t2, p2 - end coordinates, st - line style, sz - size.

You can also add ray: 1 - ray, 0 - segment. The last line of this function defines a segment. Instead of 0 you can put the name of the parameter to be passed.

As for how to work with it (this line) in the indicator - you need to know what you need from it. However, the data on it (the line) can be obtained using the standard function

ObjectGet("object name", the necessary object property);


Thank you very much! Another question, if I may. How to work (I need to know what value the trend takes on a certain bar), how to work the trend in the EA. I want to transfer a part of the indicator to the Expert Advisor (calculations).
 
Good morning!!! Can't get into the account! What the fuck is this "common error"?
 
Is there something wrong with the computer again?
 
Elenn:
The solution is really original, we should try it.


I'll just quote you a little text from Delphi tutorial. It won't hurt to know it.

"Dynamic arrays" are dynamic data structures, so the program should provide for explicitly removing them from computer memory when you are finished with them. The process of removing unnecessary dynamic variables from computer memory is sometimes called rubbish collection."

A variant that will work in MQL4 is to resize a dynamic array to zero length using the ArrayResize() function https://docs.mql4.com/ru/array/ArrayResize when the program finishes working with it.

 
drknn:


I think I will quote you a little piece of text from the Delphi tutorial. It's good to know.

"Dynamic arrays" are dynamic data structures, so the program should provide for explicitly removing them from computer memory when you are finished with them. The process of removing unnecessary dynamic variables from computer memory is sometimes called rubbish collection."

A variant that is suitable for the MQL4 language is to resize a dynamic array to zero length using the ArrayResize() function https://docs.mql4.com/ru/array/ArrayResize after you finish working with it.

That's all true: cleaning up trash is a good rule of thumb...

But in this context how to determine whether we should clean up "trash" now or vice versa: it's not trash but necessary data for further calculations.

As I understand it, deinit() should be used to clean up the trash, but... it is executed not only when chart of a trade instrument is deleted, when Expert Advisor is removed from it, but also when TF is changed. In this case, all of the accumulated data for the TF will be lost and the Expert Advisor will start working over with a zero array when it returns to the previous timeframe. The same will happen if we change any of the EA parameters.

It turns out that in some situations 'scavenging' is a complex logical process, rather than simply changing the size of an array.

 
001:

Thank you very much! Another question, if I may. How to work(I need to know what value the trend takes on a certain bar), how to work with the trend in the EA. I want to transfer a part of the indicator to the Expert Advisor (calculation).

ObjectGetValueByShift() to help you

And how you are going to work with it - only you know...

Reason: