[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 191

 
eddy:

the wrong price is 1.37197000.

the correct price is 1.37197 or 1.3719, depending on which DNS.

NormalizeDouble() is used to set the number of digits after the decimal point


Added NormalizeDouble() to the price in OrderSend(), no error now, thanks!
 
artmedia70:

This is as easy as it gets:

Place the functions themselves outside of the start() function, or at the very end of the whole code.



Thank you!
 
eddy:

I need to remember GetTickCount on the first tick after starting the indicator, but the code below does not work - the terminal hangs. maybe RefreshRates does not work at all in init()...?

while(true){ if(RefreshRates()) { tik=GetTickCount(); break; } Sleep(1 ); }

Anybody have any ideas how to implement this? I would like to do it in init, because if I set a flag in start - it will be checked every time
 
eddy:
Who has any ideas how to implement it? I want to do it in init, because if you make a flag at start, it will be checked every time
When declaringa global variable, assign a value to it and reset it at start. Then it will have initial value only on the first tick, before assigning, and on all subsequent ticks - the value assigned at start. Then you can transfer to the start all actions, which are performed once at start of Expert Advisor.
 
eddy:

Could you please advise how to load indicator on a chart programmatically?

There is the function bool ServiceLoadCustomIndicator(int hwndChart,...); //hwndChart- System descriptor of the chart window, where the indicator is loaded.

I don't know how to know the chart window descriptor.

I just need to memorize GetTickCount on the first tick after the start of the indicator, but the code below doesn't work - the terminal hangs. Maybe in init() RefreshRates doesn't work at all...?

https://docs.mql4.com/ru/windows/WindowHandle
 
granit77:
Assign a value to the global variable in the declaration and reset it at start. Then it will have the original value only on the first tick, before assigning, and on all subsequent ticks - the value assigned at start. Then all actions, which are performed once at start of EA, can be transferred to start.

I don't need to assign anything to this variable at startup.

i decided to create a separate indicator to memorize ticks in a global variable, the value of which will be known to the main indicator on startup

Zhunko, what if there are several windows with the same TF and symbol?

 
eddy:

I don't need to assign anything to this variable at startup. only once to remember the tick.

i decided to create a separate indicator to memorize ticks in a global variable, the value of which will be evaluated by the main indicator on startup

Zhunko, what if there are several windows with the same timeframe and symbol?

Checked a long time ago (you can do it too) it returns the last one or the active one.
 
Zhunko: Returns the last one or the active one.

i.e. if none of them is active, it returns the last one?

However, it doesn't matter, I think when adding it, the one where it should be added is always active anyway.

 
eddy:

However, it doesn't matter, I think it's always active when you add it anyway, where you want to add it

Yes. Exactly. I have a function that returns descriptors of all the same chart windows in Z order. Didn't include it in the library. But it won't help much.
 
eddy:

I don't need to assign anything to this variable at startup. only once to remember the tick.

I decided to make a separate indicator to memorize ticks in a global variable, the value of which the main indicator recognizes on startup

What I meant was this:
bool FirstStart=true;

int start(){

    if(FirstStart){
      if(RefreshRates()) tik=GetTickCount();
      FirstStart=false;
    } 
}
Reason: