[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 679

 


Dear programmers,
Please answer the following question:

Outputs with 8 decimal places. Why isn't it normalised?

double open_sss=NormalizeDouble(iOpen(Symbol(),PERIOD_M5,elapsed_bar),Digits);
Print("open_sss= "+open_sss);

http://savepic.ru/1435355.gif

 
Hedin:


Dear programmers,
please answer the following question:

Outputs with 8 decimal places. Why is it not normalized?

http://savepic.ru/1435355.gif


If it is written in the help about function NormalizeDouble() that it rounds to a specified precision and returns type double, you have everything right, and if you need a text string with specified precision after a decimal point, then you should use DoubleToStr()
 
IgorM:


I must have misunderstood the meaning of int startH = Hour(); - it will give the current server time - hour, I would look for zero hours, or any other hour:


Thanks, it works now.

But why it didn't work with the Hour() function, I still don't understand.

It gave us the current hour of northern time. For example, let it be 5.

Therefore, when we call open[i+5], we get the opening price of the candle which opened at the beginning of the day, i.e., at 0:00 AM.

Please explain what exactly I do not understand?

 
webgreck:


Thank you, it works now.

But why it didn't work with the Hour() function I still don't understand.

It gave us the current hour of northern time. For example, let it be 5.

Therefore, when we call open[i+5], we get the opening price of the candle which opened at the beginning of the day, i.e., at 0:00 AM.

Please explain what exactly I do not understand?


The server time is server time ( TimeCurrent() ), you have it on your PC ( TimeLocal(); ), the function Hour() :

"Returns the current hour (0,1,2,...23) of the last known server time at program start (this value does not change during program execution ).Note: the last known server time is simulated during testing. "

I don't even know what to do with it myself if it doesn't change - maybe it's only needed for the tester.

 
webgreck:

Can you please tell me what I did wrong?

I need to find the opening price of the first candle on the hour chart, i.e. the one at 0:00 and from this candle to the current one to find the maximum price value.

Why do I always get the high of the first candle of the current day.

This is how I do it:

Cycle through Time[] and find the desired bar, then cycle from that bar to find an extremum.
 

Colleagues, does anyone know how to make the tester not deduct commission for a trade? Maybe there is a file in MT4, where the amount of commission for a contract for a particular instrument is specified?

Let me explain what I need it for. Apart from currencies, I am also interested in futures of the Uber and the RTS Index. Quick is not suitable for robot development. For example, my brokerage firm has a commission for one contract - CFD on futures on the rts index (as it sounds, but ...:)) - it is a racket ... costs 10 green papers. That's why even a trade with a profit of 250p gives a $1 loss in the tester. It's unbelievable, I have tools and quotes, but it's impossible to test and optimize it.

Help!

 
Blaid73:

Colleagues, does anyone know how to make the tester not deduct commission for a trade? Maybe there is a file in MT4, where the amount of commission for a contract for a particular instrument is specified?

Let me explain what I need it for. Apart from currencies, I am also interested in futures of the Uber and the RTS Index. Quick is not suitable for robot development. For example, my brokerage firm has a commission for one contract - CFD on futures on the rts index (as it sounds, but ...:)) - it is a racket ... costs 10 green papers. That's why even a trade with a profit of 250p gives a $1 loss in the tester. It's unbelievable, I have tools and quotes, but it's impossible to test and optimize it.

Help!


probably this: https://www.mql5.com/ru/forum/119830

 

Please advise how and what you can do to replace the code to do the same thing but work faster:

if (BB_1>BB_2 && BB_2<=BB_3 && BB_1<0)                               // Найден разворот BB вверх
      {
      switch (tf)
         {
            case 1:     TrBBTurnUP_M1 =true;  TrBBTurnDN_M1=false;      // Флаг разворота вверх на М1
            case 5:     TrBBTurnUP_M5 =true;  TrBBTurnDN_M5=false;      // Флаг разворота вверх на М5
            case 15:    TrBBTurnUP_M15=true;  TrBBTurnDN_M15=false;     // Флаг разворота вверх на М15 
            case 30:    TrBBTurnUP_M30=true;  TrBBTurnDN_M30=false;     // Флаг разворота вверх на М30 
            case 60:    TrBBTurnUP_H1 =true;  TrBBTurnDN_H1=false;      // Флаг разворота вверх на H1
            case 240:   TrBBTurnUP_H4 =true;  TrBBTurnDN_H4=false;      // Флаг разворота вверх на H4
            case 1440:  TrBBTurnUP_D1 =true;  TrBBTurnDN_D1=false;      // Флаг разворота вверх на D1
            case 10080: TrBBTurnUP_W1 =true;  TrBBTurnDN_W1=false;      // Флаг разворота вверх на W1
            case 43200: TrBBTurnUP_MN =true;  TrBBTurnDN_MN=false;      // Флаг разворота вверх на MN
         }
      }

It's just a piece of one big function, where there are a lot of such checks and it affects performance a lot. I already asked questions here about code optimization, but I didn't get any answers and I didn't find anything in search... Is it really a secret that nobody knows about it or is willing to share it...? At least a link to an article... to read at your leisure... It's impossible to fully test it anyway...

 
How do I get in touch with you? I have a lot of questions and would like some advice.
 
artmedia70:

Please advise how and what you can do to change the code to do the same thing but work faster: ...

I would replace the switch with a ready-made array, why assign predefined values every time?
Reason: