Indicators: Setka (grid) - page 2

 
Prival:
posted a new version 3.09 on Code Base, you can download it.

You can improve it a bit more.

if(ObjectFind(0,nm)<0) ObjectCreate(0,nm,OBJ_VLINE,0,t1,2);

In such constructions ObjectFind() is obviously unnecessary. When creating by ObjectCreate() will be similar search in the list by name and either create a new object, or change the parameters of anchor points of the existing one.
.

ObjectSetInteger(0,nm,OBJPROP_SELECTABLE,false);

For objects created from MQL programme this property is forced to false.

Similarly, there is no point in changing the value of OBJPROP_WIDTH, it will be equal to 1 anyway.

According to my measurements these edits reduce the build time by about 10%.

 

Thanks. I'll keep that in mind. I'm working on something right now. There's a glitch.

I have 8 charts open with only the grid on them.

I simulate disconnection from the net for 5 minutes. This is the picture after switching on the net. 2 charts are crashing.

I attach a new version of the grid version 4.01.

Files:
setka__1.mq5  15 kb
 
Prival:

Thanks. I'll keep that in mind. I'm working on something right now. There's a glitch.

I have 8 charts open with only the grid on them.

I simulate disconnection from the net for 5 minutes. This is the picture after switching on the net. 2 charts are crashing.

I attach a new version of the grid version 4.01.

This is a consequence of the terminal architecture and the indicator algorithm. The indicator is executed in the symbol stream, i.e. during its calculation many operations with history are impossible: processing of ticks, calculation of other indicators, history synchronisation with the server, building or loading history by symbol timeframes, etc.

Since the Grid indicator is calculated for a long time and uses data from other symbol timeframes, it is desirable to interrupt its calculation in case of any error. If seriously not to rewrite the code, you can do it this way:

bool isNewBar_i(datetime date,ENUM_TIMEFRAMES timeFrame,bool& error)

  {

...

   else
     {
      Print("Timeframe ",fTimeFrameName(timeFrame)," is not ready");
      error=true;

     }

and so:

      //--- определимся с цветом линии
      if(_Period<PERIOD_H1) if(isNewBar_i(time[i],PERIOD_H1,error) && _Period<PERIOD_M30) line_color=new_hour;
      if(_Period<PERIOD_D1) if(isNewBar_i(time[i],PERIOD_D1,error) && _Period<PERIOD_H4 ) line_color=new_day;
      if(_Period<PERIOD_W1) if(isNewBar_i(time[i],PERIOD_W1,error) && _Period<PERIOD_D1 ) line_color=new_week;
      if(_Period<PERIOD_MN1)if(isNewBar_i(time[i],PERIOD_MN1,error)&& _Period<PERIOD_MN1) line_color=new_mon;
      //---
      if(error) return(0);

Files:
setka.mq5  15 kb
 
antt:

This is a consequence of the terminal architecture and indicator algorithm. The indicator is executed in the symbol stream, i.e. in the process of its calculation many operations with history are impossible: processing ticks, calculation of other indicators, synchronisation of history with the server, building or loading history by symbol timeframes, etc.

I can't get this notion of a stream, and I have read the help about data access 50 times (( the script is given there as an example. And it takes about a minute to execute (a long time), but it seems that I started to get it. Did I understand correctly that while the indicator is being calculated, i.e. the function has started to execute

int OnCalculate () {
all resources of the computer (terminal) are given to this task, and until it is executed (completed)

return(rates_total); }

You must not do any of the following:

- try to read history by this symbol if it is missing

- request a different timeframe

- request another symbol

I think I understand how to redo the program, you need to set all lines at the first call and forget about it until if(prev_calculated==0).

antt right ?

S.Y.

  1. Trader - a person who steps on rakes.
  2. Dummy - a beginner trader who has never stepped on a rake and therefore is sure that there is no rake.
  3. sucker - a trader who regularly steps on rakes but is still sure that rakes do not exist.
  4. Narrow specialist - a trader who is fluent in the technology of stepping on the same rake.
  5. Wide specialist is a trader stepping on more than two rakes in parallel.
  6. Mechsystems specialist - a trader who is able to automate rake hits.

According to Renat's assessment I have level 5 :-)) , https://www.mql5.com/ru/forum/1165/page3 went to step further )))

 

completely rewritten the code. No other timeframes are requested.

if you don't mind. Set the mac. bars in the Unlimit window and go through M15, M5 and M1. post the result in the log here. I have something wrong on M1 - I wrote to the service. I just want to see if it's just me or everyone.

here is my log.

2010.06.17 11:39:55 Grid (EURUSD,M1) Failure or first run Time= 1.2 sec for 1293476 bars ObjectsTotal= 48010 _time= 2002.10.25 06:41:00
2010.06.17 11:39:52 Grid (EURUSD,M5) Failure or first run Time= 0.0 sec for 847192 bars ObjectsTotal= 423 _time= 2010.06.02 21:35:00
2010.06.17 11:39:48 Grid (EURUSD,M15) Failure or first run Time= 0.0 sec for 285186 bars ObjectsTotal= 962 _time= 2010.05.04 22:00:00

thanks in advance. grid version 4.11

 
Prival:

I can't get this notion of thread, and I have read the help about data access 50 times (( the script is given there as an example. And it takes about a minute to execute (a long time), but I think I'm starting to get it. Do I understand correctly that while the calculation of the indicator is in progress, i.e. the function has started to execute

http://ru.wikipedia.org/wiki/Thread


int OnCalculate () {
all computer (terminal) resources are given to this task, and until it is executed (finished)

return(rates_total); }

Not all resources. But most of the calculations related to this symbol will wait until OnCalculate() is completed.


You must not do any of the following:

- try to read the history for this symbol if it is missing

Yes. If there is not enough history for the current symbol, the OnCalculate() execution will definitely not get better.


- request another timeframe

You can request it, but if the data is missing or insufficient, it makes no sense to wait in OnCalculate(). Similarly with the data of other indicators for the current symbol.

- request another symbol

You can request, theoretically you can even wait in the loop for all the necessary data to appear, because the processing of data of another symbol (history, indicators) is done in another thread. But it is better not to do so, the waiting loop in OnCalculate() will stop the processing of data of the current symbol.

.

I think I understand how to redo the programme you need to set all lines at the first call and forget about it if(prev_calculated==0).

The general recommendation when writing custom indicators: if any error is detected, any lack of data, immediately stop execution of OnCalculate() with return(0). On the next tick make a new attempt to calculate on if(prev_calculated==0).
 
Prival:

if it's not too much trouble. Set the mac. bars in the Unlimit window and go through M15, M5 and M1. The result that will be in the log, post here. I have something wrong on M1 - wrote to the service. I just want to see if it is me or everyone.

2010.06.17 11:58:59 6op0k (EURUSD,M1) Failure or first run Time=0.1sec for 4009008 bars ObjectsTotal=403_time=2010.06.15 07:45:00
2010.06.17 11:58:54 6op0k (EURUSD,M5) Failure or first run Time=0.0sec for 847196 bars ObjectsTotal=605_time=2010.06.02 21:55:00
2010.06.17 11:58:44 6op0k (EURUSD,M15) Failure or first run Time=0.0sec for 285187 bars ObjectsTotal=1108_time=2010.05.04 22:15:00
 
antt:
2010.06.17 11:58:59 6op0k (EURUSD,M1) Failure or first run Time=0.1sec for 4009008 bars ObjectsTotal=403_time=2010.06.15 07:45:00
2010.06.17 11:58:54 6op0k (EURUSD,M5) Failure or first run Time=0.0sec for 847196 bars ObjectsTotal=605_time=2010.06.02 21:55:00
2010.06.17 11:58:44 6op0k (EURUSD,M15) Failure or first run Time=0.0sec for 285187 bars ObjectsTotal=1108_time=2010.05.04 22:15:00

Thank you. it means that I finally wrote everything correctly and the "indicator" really works as I intended. the failure I had is a problem of the terminal (you have everything normal). _time=2010.06.15 07:45:00). it's a pity that the developers are silent in the service dex. at least they would write a couple of words (( like

problem reproduced...we think...thanks

 
Prival:

thanks. it means that I finally wrote everything correctly and the "indicator" really works as I intended. the failure I had is a problem with the terminal (you are doing fine. _time=2010.06.15 07:45:00). it is a pity that the developers are silent in service dex. at least they would write a few words (( like

problem reproduced...we think...thank you.

and can be corrected:

if on H1 gravfik to carry a vertical or horizontal line, then switch to another time interval, the lines not related to the indicator are deleted.

This is a very convenient indicator for checking history to visually determine the price step, but due to the fact that the marks (vertical and horizontal lines) put on the older time intervals disappear when switching to a smaller time interval, it becomes uncomfortable.

 

The indicator perfectly solved the problem of usable display of the price scale in the terminal windows.

Compilation in builds up to 3021 inclusive shows no errors and everything is drawn OK (and even if you throw the previously compiled version into a new build of the terminal).

Compilation in subsequent builds does not show any errors, but in the terminal, the adder does not draw vertical markup and in the logs writes: 1 leaked strings left

Having commented out the line:

StringConcatenate(line_name,IntegerToString(str.hour,2,'0'),":":",IntegerToString(str.min,2,'0'),"_N",line_counter);

the error in the terminal logs disappears (although the lines are not drawn).

Which way to dig? How to reanimate a great tool?