[ARCHIVE]Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Can't go anywhere without you - 5. - page 285

 
gyfto:

Right. I think I've finished. Here's the reworked tick collector with its packing them into second candles.

It was:

Became:

Comments on the code.

1. Didn't make switch-case in virtual candlestick selection to save CPU time, instead commented out sections with selection (since selection is done for specific needs once before compilation).

2. On work with local time (off-line that is) not brought to mind. In the"while(time==TimeLocal()){//until one second has passed" loop, I suspect there must beMarketInfo in FileWriteDouble (sounds like the top of an idiot to me). If you tell me what would look more logical there, I will be grateful.

3. An author's construct

I've declared it at the very end of init().

4. At the beginning of init() dynamic arrays

instead of used variables.

5. For optimization, you can theoretically use WinAPI file functions and write to the history at once in block 44 bytes (length of MarketInfo structure or whatever it is in .hst).

6. Completely removed author's modeling of time for writing to the Time[] cell. For the same reason, in head while loop there is no check for TimeLocal(), only for TimeCurrent().

7. What else do you suggest to optimize the code?

From point 4 it must be understood that you were making an indicator, then such actions are not clear:

ArrayResize (bid, 1);//урезаем и обнуляем использованные массивы
ArrayResize (ask, 1);

ArrayInitialize() is most likely suitable?!

And most likely, you should refuse to use indicator arrays.

 
TarasBY:

ArrayInitialize() probably works?!

ArrayInitialize(ask, EMPTY_VALUE); you mean? I didn't. Why did I cut it down exactly, I was afraid of such a case:

(a, b, c)//values in ask after three ticks per second (fantastic, but let's suppose).

ArrayInitialize(ask, 0);//be (0, 0, 0)

FileWriteDouble(hand1e, ask[ArraySize(ask)-1], DOUBLE_VALUE);//Close[]

- The Close cell will get 0. That's why I'm re-defining the size to prevent this from happening. Check ArrayInitialize(ask, EMPTY_VALUE);.

TarasBY:

You have to stop using indicator arrays.

They're dynamic, that's what I fell for. Fewer commands, fewer number of processor cycles. You have to do 500 milliseconds of processing at any theoretically possible f... ...to get it done.

 
do you know if it is possible to replace Send and Close orders in an EA with a manual window and enter the market through this window, it is necessary for those brokers who do not allow using EAs
 
gyfto:

ArrayInitialize(ask, EMPTY_VALUE); you mean? I didn't. I was afraid of such a case, that's why I started to cut it down:

(a, b, c)//values in ask after three ticks per second (fantastic, but suppose).

ArrayInitialize(ask, 0);//be (0, 0, 0)

FileWriteDouble(hand1e, ask[ArraySize(ask)-1], DOUBLE_VALUE);//Close[]

- The Close cell will get 0. That's why I'm re-defining the size to prevent this from happening. ArrayInitialize(ask, EMPTY_VALUE);; check them.


They are dynamic, that's what I fell for. Fewer commands, fewer number of processor cycles. You have to manage 500 milliseconds of processing at any theoretically possible bottleneck... ...to get it done.

That's not what I mean: something tells me that you won't manage to shrink the indicator array. Besides, if there are unfilled cells in such array, there's ALWAYS some value there: 0 or EMPTY_VALUE, and what do you get in these calculations:

bid[ArrayMaximum(bid)];
ask[ArrayMinimum(ask)];
And by general logic: I would run the whole tick collection in a loop and separately control the time and, as soon as the "new bar" time has passed, write it to the file, zeroing and clipping the working arrays in the process.
 
ex_kalibur:
If i know, is it possible to change Send and Close orders in advisor to call up trade window manually and enter the market through this window, it is necessary for those brokers who do not allow using of advisors
Window "Properties" of the adviser -> tab "General" -> "Automatic trading". -> Put a checkbox on "Manual confirmation" - I don't know another way.
 
TarasBY:

And by general logic: I would run the whole tick collection in a loop and separately control the time and, once the time for the "new bar" has passed, write it to the file, zeroing and clipping the working arrays in the process.


Strange... I have it that way... The only thing is that the time is controlled in the tick collection cycle itself, and the working array is not clipped until a copy of the tick has been drawn as many times as there have been no ticks minus one second. One second passed - a new tick is drawn, two - a copy of the previous tick and a new tick, three - two copies of the previous tick and a new tick, etc. Instead of copies of the previous tick it is possible to draw a dash by the Close level, this variant is commented in the code.
 
gyfto:

Strange... I have it like this... The only thing is that the time is controlled in the loop itself, and the working array is not clipped until a copy of the tick is drawn as many times as there were no ticks minus one. One second passed - a new tick is drawn, two - a copy of the previous tick and a new tick, three - two copies of the previous tick and a new tick, etc. Instead of copies of the previous tick it is possible to draw a dash by the Close level, this variant is commented in the code.

You and I are talking about different cycles. I'm talking about this:

    while (!IsStopped() && IsExpertEnabled())
    {
        //---- Сбор тиков
    }
 
Can anyone tell me how to remove the zeros after the decimal point? I have 4 decimal places in my code for some reason. Here is the code. string l_dbl2str_12 = DoubleToStr(g_ibuf_140[0] - g_ibuf_144[0],3);
 
Demon2057:
Can anyone tell me how to remove the zeros after the decimal point? I have 4 decimal places in my code for some reason. Here is the code. string l_dbl2str_12 = DoubleToStr(g_ibuf_140[0] - g_ibuf_144[0],3);
https://docs.mql4.com/ru/strings/StringSubstr
 

Can you tell me what I'm doing wrong...

I need a variable of double type to contain the date as 0,20130429164459 (meaning 2013.04.29 16:44:59)

Part of the EA code:

#include <stdlib.mqh>
bool once=false;
int start()
  {
  if (once==false)
     {
    double DTM; // дата и время в формате 0,20130429164459
    int YY=TimeYear(   TimeCurrent());   // Year
    int MN=TimeMonth(  TimeCurrent());   // Month         
    int DD=TimeDay(    TimeCurrent());   // Day
    int HH=TimeHour(   TimeCurrent());   // Hour         
    int MM=TimeMinute( TimeCurrent());   // Minute
    int SS=TimeSeconds(TimeCurrent());   // Second
    DTM = YY*0.0001+MN*0.000001+DD*0.00000001+HH*0.0000000001+MM*0.000000000001+SS;
    
   Alert ("Значение переменной DTM с 06 знаками равно ", DoubleToStrMorePrecision(DTM,6));
   Alert ("Значение переменной DTM с 07 знаками равно ", DoubleToStrMorePrecision(DTM,7));
   Alert ("Значение переменной DTM с 08 знаками равно ", DoubleToStrMorePrecision(DTM,8));
   Alert ("Значение переменной DTM с 09 знаками равно ", DoubleToStrMorePrecision(DTM,9));
   Alert ("Значение переменной DTM с 10 знаками равно ", DoubleToStrMorePrecision(DTM,10));
   Alert ("Значение переменной DTM с 11 знаками равно ", DoubleToStrMorePrecision(DTM,11));
   Alert ("Значение переменной DTM с 12 знаками равно ", DoubleToStrMorePrecision(DTM,12));
   Alert ("Значение переменной DTM с 13 знаками равно ", DoubleToStrMorePrecision(DTM,13));
   Alert ("Значение переменной DTM с 14 знаками равно ", DoubleToStrMorePrecision(DTM,14));
   Alert ("Значение переменной DTM с 15 знаками равно ", DoubleToStrMorePrecision(DTM,15));
   once=true;
      }
   return(0);
  }

Event log for Precision 12,13 and 14 gives wrong result, see picture