DataLoader example

User avatar
Stan Bokov
Posts: 963
Joined: 18 Dec 2009
Has thanked: 367 times
Been thanked: 300 times

DataLoader example

Postby Stan Bokov » 06 Aug 2012

In MultiCharts .NET you can access a lot of various data directly from the scripts. It can be real-time ask and bid and level 2 data from various symbols that are not even charted. You can also access all information from the Order and Position Tracker. This is an example for using the DataLoader interface.

Code: Select all

using System;
using System.Drawing;
using System.Linq;
using PowerLanguage.Function;
 
namespace PowerLanguage.Strategy
{
   public class Test_DataLoader : SignalObject
   {
      public Test_DataLoader(object _ctx):base(_ctx){}
      private IOrderMarket buy_order;
            
      protected override void Create()   
      {
      }
      protected override void StartCalc()
      {
         Output.Clear();
      }

    bool isLosded = false;
    protected override void CalcBar()
    {
      if (Bars.CurrentBar > 1)
      {
        isLosded = false;
        InstrumentDataRequest ir1 = Bars.Request;
        ir1.Resolution.Size = 1;
        ir1.Resolution.Type = EResolution.Tick;
        ir1.From = Bars.Time[1];
        ir1.To = Bars.TimeValue;     


        IDataLoaderResult iRes = DataLoader.BeginLoadData(ir1, DataCB, null);
        while (!isLosded)
        {
          System.Threading.Thread.Sleep(100);
        }
      }
     
    }
      
      protected void DataCB(IDataLoaderResult Result)
      {
      if (Result.IsCompleted)
      {
        DataLoader.EndLoadData(Result);
        Output.WriteLine("From {0} To {1} Count Bars is {2}",Result.Request.From,
                          Result.Request.To, Result.Data.Length);
        isLosded = true;
      }
    }
  }
}
Attachments
Test_DataLoader.pln
(1.97 KiB) Downloaded 310 times
These users thanked the author Stan Bokov for the post (total 6):
TJHenry MultiСhartsLaurentiusZolialex522JoshM

alex522
Posts: 42
Joined: 31 May 2010
Has thanked: 20 times
Been thanked: 2 times

Re: DataLoader example

Postby alex522 » 31 Oct 2012

I have tried to run this sample but got the error popup:

<<EXCEPTION>>
Code: 0xFFFFFFFFC0000005 ( -1073741819 )
Continuable: 0x0000000000000000 ( 0 )
Description: The instruction at 0x
ErrorCode: 0xFFFFFFFFC0000005 ( -1073741819 )
ExceptionType: 0x0000000000000000 ( 0 )
Module: {unknown}
Process: C:\Program Files\TS Support\MultiCharts .NET64\MultiCharts64.exe
Thread ID: 0x0000000000000F84 ( 3972 )
Time: 01.11.2012 - 03:03:07.640

Do you all run this samples correctly. Or do you have any idea what might have gone wrong.

User avatar
Henry MultiСharts
Posts: 8508
Joined: 25 Aug 2011
Has thanked: 1213 times
Been thanked: 2733 times

Re: DataLoader example

Postby Henry MultiСharts » 01 Nov 2012

Alex522, for MultiCharts .Net 8.1 beta 1 please use the code from attachment.
Attachments
Test_DataLoader_MC_8.1.pln
(2.01 KiB) Downloaded 417 times
These users thanked the author Henry MultiСharts for the post:
alex522

alex522
Posts: 42
Joined: 31 May 2010
Has thanked: 20 times
Been thanked: 2 times

Re: DataLoader example

Postby alex522 » 02 Nov 2012

It works! Thanks a lot.

DasBoot
Posts: 6
Joined: 11 Feb 2013
Has thanked: 2 times

Re: DataLoader example

Postby DasBoot » 14 Feb 2013

Please provide code example for realtime subscribe and data load.

User avatar
Henry MultiСharts
Posts: 8508
Joined: 25 Aug 2011
Has thanked: 1213 times
Been thanked: 2733 times

Re: DataLoader example

Postby Henry MultiСharts » 21 Feb 2013

DasBoot wrote:Please provide code example for realtime subscribe and data load.

A sample code that subscribes to realtime data and outputs the realtime bar values in Output tab of PLEditor window can be found here.

bomberone1
Posts: 159
Joined: 02 Nov 2010
Has thanked: 13 times
Been thanked: 10 times

Re: DataLoader example

Postby bomberone1 » 14 Nov 2017

Henry,
Is it possible do it also in multicharts easylanguage?

I would like to collect all tick data from all symbols that I trade. more or less are 120
I have a list into market scanner of 120 symbol and i do not open chart.
Is it possible to do a reload with backfill of all data tick at 12.30 and at 23.30.
My purpose is to collect all data and to avoid hole in database.
What is the best solution?

Regards.


Return to “User Contributed Studies”