Here is how the downloader works: - It takes the URL that is specified in the settings or executes a URL-Script to get that URL dynamically. - It downloads data from the URL(s) and sends it to Pre-Script (If it is defined). This script can then modify the content or add custom rows. - Before the data is inserted into the database(s), it is sent to the Post-Script (If it is defined). This script lets you update the parsed data before it is inserted. The Post-Script is executed for every symbol/security. It contains a variable "Data" that has the following fields: SymbolInfo: Information about the security, such as the ticker name, market, index, address... Rows: An array of elements where each element references a date and an array of values. These values refer to the columns you have specified in the parser settings form. Here is a sample data example: (Symbol, Date, Close, Open, High, Low and Volume), MSFT;04-01-2010;12.5;12.6;12.6;12.5;2554 MSFT;03-01-2010;-;-;-;-;- A;04-01-2010;12.5;12.6;12.6;12.5;2554 A;03-01-2010;12.5;12.6;12.6;12.5;2554 After the above data is parsed, the Post-Script is executed twice. One time for the symbol "MSFT" and another time for the symbol "A". For each symbol, the variable "Rows" will contain two elements. The first element references the first date "03-01-2010" and the second one references "04-01-2010". In the first element (Data.Rows[0]), you can access the close, open, high, low and volume prices using the property "Data". To access the close price of the first date for example, you should type: double close = (double)Data.Rows[0].Data[0]; The value returned by the "Data" property is of type "Object". This is because the value could be numeric or text, depending on the associated database/field. Therefore, if the value is numeric then it should be casted to double by preceding it with "(double)" and if the value is a text then it should be casted to string by preceding it with "(string)". Ignore a specific date You can ignore a specific date by accessing the element pointing to it and then setting the "IsIgnoreLine" property to true. Example: for(int i=0;i < Data.Rows.Length;i++) { if((double)Data.Rows[i].Data[0] == 0) { Data.Rows[i].IsIgnoreLine = true; } } The above script ignores dates if the corresponding close price is equal to zero. "Close" is the first element; consequently, it has an index of zero. Recent posts about the downloader plug-in Trading Items: Data Download using .Net Scripts Download Trading Data using the URL-Script Download Trading Data using the Pre-Script
|