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

 
Vitaly Muzichenko #:

Put a flag if there is an open window, then draw, if there is no open window, then skip it. There is no point in opening and drawing if it is not known to be open/closed

Whether or not to open a new one if the symbol is not open is up to the customer. For me, with opening it is a more complete account of the customer's situation. From the search you need the window id of the symbol you are looking for.Then draw in the window you are looking for.

int FcurrChartSimbol(symbol){   
long currChart=ChartFirst();
    int i=0;
    while(i<CHARTS_MAX) {
      if(ChartSymbol(currChart)==symbol)
      return(currChart);
      currChart=ChartNext(currChart);i++;
      if(currChart==-1)return(-1);
      
    }}

Zy corrected. This is a function)))

 
Valeriy Yastremskiy #:

Whether or not to open a new one, if the symbol is not open, is up to the customer. For me, opening is a more comprehensive account of the customer's situation. From the search, you need the window id of the symbol you are looking for.Then draw in the window you are looking for.


Zy corrected. It is a function)))

Optimally, fill in a globally visible array of open charts and then work with the array

int FcurrChartSimbol(symbol) {   
   long currChart=ChartFirst();
    int i=0;
    while(i<CHARTS_MAX) {
      i++;
      mass[i-1]=currChart;
      currChart=ChartNext(currChart);
      if(currChart==-1)
        break;
    }
   return(i); // количество графиков
}

Next, run it on an event to update the filling, for example when number of positions changes

int OT=OrderTotal();
if(OT != pOT) {
 FcurrChartSimbol(symbol);
 pOT=OT;
}

This will reduce the load, there will be no need to run a useless loop

 
Vitaly Muzichenko #:

Optimally, fill in a globally visible array with open charts and then work with the array

Next, run it on an event to refresh the filling, for example when the number of positions changes

This will reduce the load, and there will be no need in useless looping

Maybe I'm missing something, but I don't understand why you don't use SYMBOL_SELECT and SYMBOL_VISIBLE to determine if the chart is open

When going through the orders, do the check

    if(!SymbolInfoInteger(Order_Symbol, SYMBOL_SELECT) || !SymbolInfoInteger(Order_Symbol, SYMBOL_VISIBLE))
      SymbolSelect(Order_Symbol, true);
 
Alexey Viktorov #:

Maybe I'm missing something, but I don't understand why you don't use SYMBOL_SELECT and SYMBOL_VISIBLE to determine the chart openness

Go through the orders and do the check

Well this is from a different opera and has to do with Market Watch, not open charts. Or is it?

P.S. If there is an open position, the symbol inMarket Watch will be visible anyway.
 
Vitaly Muzichenko #:

Well that's from another thread and has to do with Market Watch, not open charts. Or is it?

P.S. If there is an open position, the symbol inMarket Watch will be visible anyway.

SYMBOL_SELECT yes, but SYMBOL_VISIBLE is not necessary.

And yes, I agree, it doesn't have to be an open chart.

 
Vitaly Muzichenko #:

Optimally, fill in a globally visible array with open charts and then work with the array

Next, run it on an event to refresh the filling, for example when the number of positions changes

This will reduce the load, no need to run a useless loop

I do not understand the logic. The events of opening a position, modification of SL, closing a position are monitored for a few symbols. When opening a position, we search whether a window with the given symbol is open (look for the window id); if it is open, we draw levels and then monitor the SL trawl. If not, we either open a window with the required symbol and timeframe and draw levels or do not open it. The event of modification, find the required symbol window, levels have already been drawn and change the level colour or delete it and draw the level again.

In general, to exclude the client's influence, at the beginning of work we should analyse positions and windows and open windows for symbols with open positions and not open windows.

 
Valeriy Yastremskiy #:

I don't understand the logic a bit. Events of position opening, SL modification, position closing on several symbols are monitored. Position opening - search if a window with the given symbol is open (look for the window id), if it is open, then we draw levels and then monitor the SL trawl. If not, we either open a window with the required symbol and timeframe and draw levels or do not open it. The event of modification, find the required symbol window, levels have already been drawn and change the level colour or delete it and draw the level again.

Generally, to exclude the client's influence, at the beginning of work we should analyze positions and windows and open windows for symbols with open positions and not open windows.

The important thing in all this is a properly working trawl algorithm, i.e. trading operations themselves.

Drawing is in the background, it is informational and has nothing to do with the system profitability.

Therefore, if there is a position but the chart is closed and it did not close by itself, there is no need to open anything, the trawl algorithm will work and stops will be moved over. A much worse situation is when the chart is obviously closed, but the program has opened it again literally for drawing of the chart - this is already bad.

 

Colleagues - exported an optimisation cache file to the cloud, how do I use it on another computer to select a variant for bidding?


Answer:

If anyone needs it - here.


Оптимизация стратегий - Алгоритмический трейдинг, торговые роботы - Справка по MetaTrader 5
Оптимизация стратегий - Алгоритмический трейдинг, торговые роботы - Справка по MetaTrader 5
  • www.metatrader5.com
Тестер стратегий позволяет тестировать и оптимизировать торговые стратегии ( советники ) перед началом использования их в реальной торговле. При...
 
Vitaly Muzichenko #:

The important thing in all of this is a properly working trawling algorithm, i.e. the trades themselves.

Drawing is in the background, it is informational and has nothing to do with the system profitability.

Therefore, if there is a position but the chart is closed and it did not close by itself, there is no need to open anything, the trawl algorithm will work and stops will be moved over. It is much worse, when the chart is closed, but the program has opened it again literally to draw the chart - this is bad.

We can do it that way as well. But in this case, if there is an open chart based on the event, it can be drawn. In general, we can redraw levels every time to avoid confusion. We have all the data for that. The trigger level for the trawl, trawl step, position price. The level number and number of triggered levels for the position are easily calculated.

 
Valeriy Yastremskiy #:

This is also possible. But then we draw if there is an open chart for the event. In general, the levels can be redrawn every time to avoid confusion. We have all data for this. Trigger level for the trawl, trawl step, position price. The level number and number of triggered levels for a position are easily calculated.

I would say that if there is a position, we should draw levels in advance that will trigger a trawl. If an additional position appeared, redraw the lines to the new levels also forward.

I don't see the point in changing the colour after passing/modification. After closing positions all lines can be deleted.

On the example showed how it should be

The objects where the positions will be opened are drawn here, it's just informative, that's all


---

P.S. At the moment I can not do the math, unfortunately