ScrewTurn

Active Trader Strategies API Community ChartStyles Community Commissions Community Components Community Indicators Community Providers Community Visualizers Knowledge Base Misc Optimizers PosSizers Standard Indicators TASC Traders Tips TASCIndicators Tutorial Videos
RSS

Navigation







Quick Search
»
Advanced Search »

PoweredBy

Syntax


public int FillSeriesFromFile(DataSeries Series, string FileName)
public int FillSeriesFromFile(DataSeries Series, string FileName, char separator, string DateTimeFormat)
public int FillSeriesFromFile(DataSeries Series, string FileName, char separator, string DateTimeFormat, bool exactMatch)
public int FillSeriesFromFile(DataSeries[] SeriesArray, string FileName, char separator, string DateTimeFormat, bool exactMatch)

Parameter Description

Series The resulting Series name
Series[] (optional) The resulting Series name array
FileName Path to the file containing data series
separator (optional) Separator char used to isolate dates from the series
DateTimeFormat (optional) Custom DateTime Format String, according to this Microsoft KB article
exactMatch (optional) If true, returns the precise DateTime value - otherwise, the first bar whose DateTime is greater than or equal to the specified date.

Description

This is a generic procedure (initially written by Glitch for WLD3) that will populate a Price Series with data from a file. The file should contain 1 row of data per bar. The format of each row can be:

Date (as yyyyMMdd),Value

For example, here are the first few lines of a file used in the creation of this script:

20080929,-0.714285714 
20080930,0.5 
20081001,-0.461538462 
20081002,0.876923077 

If the format of your data file differs from our example above, use an override method that provides additional control by specifying custom separator (data type char) and DateTime Format String (according to this Microsoft KB article).

Example

Below is a sample Strategy that uses the procedure. Be sure to create the series first, as is done here:


using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;
using Community.Components;

namespace WealthLab.Strategies { public class FillSeriesFromFile_Demo : WealthScript { protected override void Execute() { // Path to the data file containing external series string path = @"C:\DataSeries.txt"; // Series to fill DataSeries MySeries = new DataSeries( Bars, "MySeries" ); // Create an instance of class that holds the method, passing a WealthScript reference SeriesHelper sh = new SeriesHelper( this ); // Call the FillSeriesFromFile method sh.FillSeriesFromFile( MySeries, path, Char.Parse(","), "yyyyMMdd" ); ChartPane MyPane = CreatePane( 30, true, true ); PlotSeries( MyPane, MySeries, Color.Red, WealthLab.LineStyle.Histogram, 2 ); } } }

This example illustrates importing from a file which contains multiple DataSeries and creating them at once as a DataSeries array.

Before running this example, make sure you've created a file "test.txt" containing the following strings, in C:\temp:
20100301,0.5,0.9
20100302,0.3,0.6



using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;
using Community.Components;

namespace WealthLab.Strategies { public class MyStrategy : WealthScript { protected override void Execute() { //Create an instance of the class that holds the method, passing a WealthScript reference SeriesHelper sh = new SeriesHelper( this ); // Path to the data file containing external series string path = @"C:\temp\test.txt"; // Define two data series to fill DataSeries Series1 = new DataSeries( Bars, "Series1" ); DataSeries Series2 = new DataSeries( Bars, "Series2" ); // Create an array of DataSeries capable of holding 2 series DataSeries[] ds = new DataSeries[2]; ds[0] = Series1; ds[1] = Series2; // Let FillSeriesFromFile fill your series, passing the array created earlier sh.FillSeriesFromFile( ds, path, Char.Parse(","), "yyyyMMdd" ); // Plot it ChartPane MyPane = CreatePane( 20, true, true ); PlotSeries( MyPane, Series1, Color.Blue, LineStyle.Solid, 1 ); PlotSeries( MyPane, Series2, Color.Red, LineStyle.Solid, 1 ); } } }

Important Disclaimer: The information provided by Wealth-Lab is strictly for informational purposes and is not to be construed as advice or solicitation to buy or sell any security.  The owner of Wealth-Lab.com assumes no liability resulting from the use of the material contained herein for investment purposes.

Used under license from FMR Corp. Copyright 2008 FMR Corp. All rights reserved.


ScrewTurn Wiki version 3.0.2.509. Some of the icons created by FamFamFam.