Discussion of article "Timeseries in DoEasy library (part 39): Library-based indicators - preparing data and timeseries events"

To add comments, please log in or register
MetaQuotes
Moderator
222482
MetaQuotes  

New article Timeseries in DoEasy library (part 39): Library-based indicators - preparing data and timeseries events has been published:

The article deals with applying DoEasy library for creating multi-symbol multi-period indicators. We are going to prepare the library classes to work within indicators and test creating timeseries to be used as data sources in indicators. We will also implement creating and sending timeseries events.

Compile the indicator and launch it on the symbol chart we have not worked with for a long time (while setting working with the current symbol in the settings beforehand) and select working with the specified timeframe list. Launching the indicator on long unused symbols makes the indicator to download missing data and inform of that in the journal and on the chart:


Here we can see that each next empty timeseries has been synchronized and created at each new tick. The following entries have been displayed in the journal:

Account 8550475: Artyom Trishkin (MetaQuotes Software Corp.) 10425.23 USD, 1:100, Hedge, MetaTrader 5 demo
--- Initializing "DoEasy" library ---
Working with the current symbol only: "USDCAD"
Working with the specified timeframe list:
"M1"  "M5"  "M15" "M30" "H1"  "H4"  "D1"  "W1"  "MN1"
USDCAD symbol timeseries: 
- Timeseries "USDCAD" M1: Requested: 1000, Actual: 0, Created: 0, On the server: 0
- Timeseries "USDCAD" M5: Requested: 1000, Actual: 0, Created: 0, On the server: 0
- Timeseries "USDCAD" M15: Requested: 1000, Actual: 0, Created: 0, On the server: 0
- Timeseries "USDCAD" M30: Requested: 1000, Actual: 0, Created: 0, On the server: 0
- Timeseries "USDCAD" H1: Requested: 1000, Actual: 0, Created: 0, On the server: 0
- Timeseries "USDCAD" H4: Requested: 1000, Actual: 0, Created: 0, On the server: 0
- Timeseries "USDCAD" D1: Requested: 1000, Actual: 0, Created: 0, On the server: 0
- Timeseries "USDCAD" W1: Requested: 1000, Actual: 0, Created: 0, On the server: 0
- Timeseries "USDCAD" MN1: Requested: 1000, Actual: 0, Created: 0, On the server: 0
Library initialization time: 00:00:01.406
"USDCAD" M1 timeseries created successfully:
- Timeseries "USDCAD" M1: Requested: 1000, Actual: 1000, Created: 1000, On the server: 5001
"USDCAD" M5 timeseries created successfully:
- Timeseries "USDCAD" M5: Requested: 1000, Actual: 1000, Created: 1000, On the server: 5741
"USDCAD" M15 timeseries created successfully:
- Timeseries "USDCAD" M15: Requested: 1000, Actual: 1000, Created: 1000, On the server: 5247
"USDCAD" M30 timeseries created successfully:
- Timeseries "USDCAD" M30: Requested: 1000, Actual: 1000, Created: 1000, On the server: 5123
"USDCAD" H1 timeseries created successfully:
- Timeseries "USDCAD" H1: Requested: 1000, Actual: 1000, Created: 1000, On the server: 6257
"USDCAD" H4 timeseries created successfully:
- Timeseries "USDCAD" H4: Requested: 1000, Actual: 1000, Created: 1000, On the server: 6232
"USDCAD" D1 timeseries created successfully:
- Timeseries "USDCAD" D1: Requested: 1000, Actual: 1000, Created: 1000, On the server: 5003
"USDCAD" W1 timeseries created successfully:
- Timeseries "USDCAD" W1: Requested: 1000, Actual: 1000, Created: 1000, On the server: 1403
"USDCAD" MN1 timeseries created successfully:
- Timeseries "USDCAD" MN1: Requested: 1000, Actual: 323, Created: 323, On the server: 323
New bar on USDCAD M1: 2020.03.19 12:18
New bar on USDCAD M1: 2020.03.19 12:19
New bar on USDCAD M1: 2020.03.19 12:20
New bar on USDCAD M5: 2020.03.19 12:20

Author: Artyom Trishkin

iabbott
7
iabbott  

Hi,

I am trying to print some parameters of the last "complete" bar into the journal, but I would guess I have either not updated the stored series data, or have not sorted it (but I also can't work out how to sort it by time and get the bar I want), my result is always the 2nd bar in the history, never updated realtime data of the previous complete bar... Next I want to compare the most recent complete bar size against the previous 10-20 bars, any push in the right direction will be appreciated!

I am performing this action on the "New Bar" event:

   else if(idx>SERIES_EVENTS_NO_EVENT && idx<SERIES_EVENTS_NEXT_CODE)
     {
      //--- "New bar" event
      if(idx==SERIES_EVENTS_NEW_BAR)
        {
         Print(TextByLanguage("Новый бар на ","New Bar on "),sparam," ",TimeframeDescription((ENUM_TIMEFRAMES)dparam),": ",TimeToString(lparam));

        
//--- printing last complete bar size on every new bar         
         // Get the Symbol object from the passed string param  
         CSymbol *symbol=engine.GetSymbolObjByName(sparam);
         if(symbol==NULL)
            return;
         // Get the last complete bar (current -1 from right of chart) for this timeframe
         CBar *bar=engine.SeriesGetBar(symbol.Name(),(ENUM_TIMEFRAMES)dparam,1);
         if(bar==NULL)
            return;            
         //--- Display the data received from the bar object
         Print(TextByLanguage("Бар \"","Data from Bar \"")+symbol.Name()+"\" "+TimeframeDescription((ENUM_TIMEFRAMES)dparam)+": "+TimeToString(bar.Time(),TIME_DATE|TIME_MINUTES|TIME_SECONDS)+
            " H: "+DoubleToString(bar.High(),symbol.Digits())+
            " L: "+DoubleToString(bar.Low(),symbol.Digits())+
            " Size: "+DoubleToString(bar.Size(),symbol.Digits()));        
        
        }
     }

Attached screenshot of the journal results

Files:
Example.jpg 102 kb
Artyom Trishkin
Moderator
60736
Artyom Trishkin  
iabbott :

Hi,

I am trying to print some parameters of the last "complete" bar into the journal, but I would guess I have either not updated the stored series data, or have not sorted it (but I also can't work out how to sort it by time and get the bar I want), my result is always the 2nd bar in the history, never updated realtime data of the previous complete bar... Next I want to compare the most recent complete bar size against the previous 10-20 bars,  any push in the right direction will be appreciated!

I am performing this action on the "New Bar" event:

Attached screenshot of the journal results

Attach here the source code of the program in which you get such results, please.

What timeframe bars do you want to receive at the opening of a new bar?

iabbott
7
iabbott  

Hi,

I have just added that code block to the new bar event of the Pt39 TestDoEasy EA, no other changes (line 544 in the attached)

On the open of a new bar, I want to check the bar history of the timeframe which triggered the event - since the event is triggered on each timeframe separately, I figured it would be easier to put this check as part of the event

Thanks

Files:
iabbott
7
iabbott  

Hey-any update?

Is it something I'm not doing right? Seems to me that if it was an issue with the library that someone would have found it much earlier than this :)

Thanks!

Artyom Trishkin
Moderator
60736
Artyom Trishkin  
iabbott:

Hey-any update?

Is it something I'm not doing right? Seems to me that if it was an issue with the library that someone would have found it much earlier than this :)

Thanks!

I apologize. I was busy. I'll see what your problem is soon.
To add comments, please log in or register