Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 339

 
Nauris Zukas:

I output Print in Expert Advisor and it shows that the prices are there, which means that the bars have been recalculated.

Maybe I did not express myself correctly. I have calculated but may not have time to display the chart.

Nauris Zukas:

I haven't tested this yet, but I'm still thinking about how to do it.

You take any indicator from CodeBase and see how it's done.

 
Nauris Zukas:

Changed it but it doesn't work either.


works for me)

took your code and put close[0].

ps. for an Ask write close[0]+spread*_Point

 
Andrey Ilinykh:

Hello Artiom, could you please tell me how to write an EA so that it does not open orders until the price has passed a certain level and then continues to open orders even after the price has moved back above the level? Regards Andrei.

Hello. The first thing that comes to mind is to use a flag in the global variables of the terminal.


When launching the Expert Advisor, we check if the global variable is available (point 1)

  1. In OnInit() it checks if the variable and
    1. if it does not exist yet, create such a variable and set its value to 0
    2. if it already exists, go to step 2
  2. In OnTick() it checks the variable and
    1. if it is 0, and
      1. price has not yet crossed the specified level - go to step 2
      2. price has crossed the given level - set the variable to 1
    2. if 1, then we can trade - item 3
    3. if it is 0, then go to step 2.
  3. Trade is allowed

Approximately like this.
 
Alexey Viktorov:

There's nothing to think about, just take any indicator from CodeBase and see how it's done.

The problem is that other indicators move on every bar and I need it on every tick.

 
Taras Slobodyanik:

works for me)

took your code and put close[0].

ps. for an Ask write close[0]+spread*_Point

If I call it through iCustom in Expert Advisor, will it show up? Show me a picture! :)

 
Nauris Zukas:

And if you call the indicator through iCustom in Expert Advisor ? Just give us a picture! :)


is there even one indicator displayed through iCustom ?

ps. are you trying to catch ticks through iCustom ?

 
Nauris Zukas:

And if you call the indicator through iCustom in Expert, is it visible? Picture please! :)

The indicator, that is called in the Expert Advisor through iCustom(), does not have to display its buffers on the chart, until you apply it to the chart with the same parameters that are used in the Expert Advisor. The only exceptions are those indicators that do not draw via a buffer, but via graphical objects.

 
Taras Slobodyanik:

is any indicator displayed via iCustom ?

The indicator window opens after the tests are completed.

Taras Slobodyanik:

ps. are you trying to catch ticks through iCustom?

I am trying to catch ticks for tests but in general the purpose is to display prices from files at certain times in an indicator window.

 
Nauris Zukas:

When the tests are completed, the indicator window opens.

Only if HideTestIndicators() is not used in the EA

 
Artyom Trishkin:

The indicator that is called in the Expert Advisor through iCustom() does not have to display its buffers on the chart until you apply it to the chart with the same parameters that are used in the Expert Advisor. The only exceptions are those indicators that do not draw through the buffer, but through graphical objects.

After the tests are completed, the indicator window opens.