Live chart data export to CSV

Here you can post and download custom indicators. PLEASE: Do not start topics unless you are posting your own indicator, they will be moved to appropriate section even if you do.

Moderator: admin

Live chart data export to CSV

Postby chimpy » Fri Jun 10, 2011 11:30 am

For my style of trading its important for me to use the chart data from the broaker I am using.
However if you use an external charting package or something like Ninja trader or EWAVE for short term trading then what can you do??
Well as it stands at the moment there is good and bad news as far as Tradstation is concerned.

The good news: is that someone had already thought of this problem and coded a standard Tradestation 8/2000i *.ELD, *.ELA format indicatior addon that you can add to any timeframe chart TICK, 1min, 5min, 1hour, 4 hour etc, and as soon as the chart is updated in tradstation then a CSV file is updated with that bar information in a folder you chose so, that all you have to do is read that file with your external charting package and you have exactly the same live data as you have in tradstation... great. (I have attached the indicator and source code to this post)

The bad news: is that for some reason fxcm's version of tradestation does not the standard ELD, ELA indicator addon that all the other tradestation platform brokers use. fxcm's tradestation uses lua format I am told...

I dont know if anyone on this forum is capable for recoding this indicator into lua but I am sure it woudl be very valuable to the tradestation uses of this site...

out of interest, metatrader has an indicator addon called Historydata.mq4 that does much the same job as dttsutility.eld attached to this thread

Greatful for any help

Chimpy

UPDATE:
DOWNLOAD THE LATEST VERSION HERE
viewtopic.php?f=17&t=4685&start=100#p105245
Last edited by chimpy on Wed Apr 13, 2016 1:10 am, edited 1 time in total.
chimpy
 
Posts: 98
Joined: Fri Jun 10, 2011 10:32 am

Re: Live chart data export to CSV

Postby chimpy » Sat Jun 11, 2011 9:06 am

sorry, here are the files mentioned above, attached
Attachments
DTTSUtility.txt
source
(2.95 KiB) Downloaded 841 times
chimpy
 
Posts: 98
Joined: Fri Jun 10, 2011 10:32 am

Re: Live chart data export to CSV

Postby chimpy » Mon Jun 13, 2011 12:44 pm

the ELD Tradestation addon attached
chimpy
 
Posts: 98
Joined: Fri Jun 10, 2011 10:32 am

Re: Live chart data export to CSV

Postby sunshine » Tue Jun 14, 2011 8:20 am

If I understand you correctly, you have an indicator on EasyLanguage for TradeStation. And you would like to use it with FXCM .
1) you can post request on this forum for fxcodebase developers and ask them to convert your indicator from EasyLanguage to Lua. And they develop the indicator for free in the order of a queue. You will be able to use the indi in Marketsope.
2) if you really need live chart data from FXCM, you should use our trading API to develop your own application which receives prices.
sunshine
 

Re: Live chart data export to CSV

Postby chimpy » Wed Jun 15, 2011 5:58 pm

sunshine,

Thanks for you reply. Yes you are correct. The file I posted above is in easylanguage and I understand this section of the website is the right place to post indicator conversion requests.. so I will I be given some queue number at some point or just wait for a reply from one of the developers?

Your idea about using the API is interesting. I am not a developer so are not sure how to go about that, could you show me? What I need is a bunch of CSV files that are updated each time their respective bar is updated. Or alternatively some kind of polling sequence, say every 25 seconds, that checks the current price and adjusts the data in the CSV files accordingly. The HISTORYDATA.mq4 indicator for metatrader works that way. I have posted a requestto convert that as well, but the easylanguage file in this post may be somewhat easier for the developers to deal with.

If you can tell me how to achieve this kind of functionality from the API then all the better

Thanks
chimpy
 
Posts: 98
Joined: Fri Jun 10, 2011 10:32 am

Re: Live chart data export to CSV

Postby Nikolay.Gekht » Fri Jun 17, 2011 10:26 am

Question: As far as I see, this indicator recreates the file every specified timeout. How the 3rd-party packages deal with file locking during re-creation process?
Nikolay.Gekht
FXCodeBase: Base Builder
 
Posts: 1222
Joined: Wed Dec 16, 2009 6:39 pm
Location: Cary, NC

Re: Live chart data export to CSV

Postby chimpy » Thu Jun 23, 2011 3:57 pm

I have two 3rd party apps which both check the file with timeouts. I usually set the timeout to be slightly less that the timeout of the indicator output file just to make sure I get updated with the latest version. Seems like my apps just skip an update if they ever clash or perhaps the OS (vista in my case) just queues requests to that file...?
chimpy
 
Posts: 98
Joined: Fri Jun 10, 2011 10:32 am

Re: Live chart data export to CSV

Postby chimpy » Sun Jun 26, 2011 1:54 pm

does anyone have a rough idea how long the request will take to resolve. I know you guys are busy but are we talking weeks or months??!?

Chimpy
chimpy
 
Posts: 98
Joined: Fri Jun 10, 2011 10:32 am

Re: Live chart data export to CSV

Postby allpin » Mon Jul 18, 2011 12:51 pm

Hi! Here is an application which would load required price histories with predefined number of bars, and then continue to build price histories based on incoming offers. It would periodically write the results to the output files.
You have to create a file Configuration.xml to provide arguments (password is provided via command line).
This is a sample of configuration file.
Code: Select all
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <Settings>

    <UserID>GBD76837005</UserID>
    <URL>www.fxcorporate.com/Hosts.jsp</URL>
    <Connection>demo</Connection>
    <SessionID></SessionID>
    <Pin></Pin>
    <TradingDayOffset>-7</TradingDayOffset>
    <TradingWeekOffset>0</TradingWeekOffset>
    <Delimiter>;</Delimiter>
    <Timeout>60</Timeout>
    <OutputDir>c:\fxcmdata</OutputDir>
    <SeparateDateAndTime>N</SeparateDateAndTime>
    <FormatDecimalPlaces>Y</FormatDecimalPlaces>
    <NeedLastCompletedCandle>N</NeedLastCompletedCandle>
    <TimeZone>EST</TimeZone>
    <History>
      <Instrument>USD/JPY</Instrument>
      <TimeFrame>m5</TimeFrame>
      <File>USD_JPY_min5</File>
      <NumBars>1000</NumBars>
    </History>
     
    <History>
      <Instrument>EUR/USD</Instrument>
      <TimeFrame>m1</TimeFrame>
      <File>EUR_USD_min1</File>
      <NumBars>1000</NumBars>
    </History>
       
    <History>
      <Instrument>USD/JPY</Instrument>
      <TimeFrame>m1</TimeFrame>
      <File>USD_JPY_min1</File>
      <NumBars>1000</NumBars>
    </History>
   
  </Settings>
</configuration>


You always have to provide UserID, URL, Connection, and Password. You may need to provide SessionID and Pin.
You can provide TradingDayOffset (default=-7) and TradingWeekOffset (default=0).
You have to provide Delimeter for you .csv file (usually ',' or ';').
You have to provide Timeout (in seconds) for writing to .csv file.
You can provide OutputDir (deafult is current directory).
You can provide SeparateDateAndTime (if the value is 'y' or 'Y', separate fields for date and time would be created;
default is one field for DateTime).
You can provide FormatDecimalPlaces (if the value is 'y' or 'Y', all prices will have the same number of decimal places
(trailing zeroes will be added if needed), default is 'N' ('Do not format decimal places').
You can provide TimeZone (valid values are "UTC", "EST", and "Local"). The default value is "EST".
You can provide NeedLastCompletedCandle (if the value is 'y' or 'Y', the last completed candle will be shown on the screen, and offers would not be shown),
default is 'N' ('User needs forming candles as well').
For each price history you would like to get, you have to provide
Instrument, TimeFrame, File (name of the output file), NumBars (number of bars loaded from the start).
If you would like just get the last candle use <NumBars>2</NumBars>.

This application uses ForexConnect API.

These are main classes used by application:
ProgramMain.png

The main class Program reads configuration XML file and validates input. Program creates a session, creates an instance of session status listener, and subscribes it to the session. Then it creates ResponseQueue (for storing a queue of O2GResponses) and an instance of response listener. The instance of response listener is subscribed to the session. Then application logs in. EventListener catches asynchronous events (“connected”, "reconnecting", “status changed”, “got a response”) and calls HistoryMgr for action.

Please see the class HistoryMgr and supporting classes:
Candles.png

Class HistoryMgr is a heart of the application. It keeps a list of CandleHistories. CandleHistory keeps a price history required by configuration XML file. It contains input parameters (instrument, timeframe, initial number of candles, name of the output file) as well as a list of Candles ready to be written to output file and new Ticks to be added to the candles. It also contains last request ID for getting MarketDataSnapshot. Each CandleHistory contains BinaryWriter for writing output file and Timer for firing writing event (initially timer is disabled). It also contains the start position of the last line of the output file. Candle contains information about one candle (time, OHLC bid and ask prices, and volume) while Tick contains information about one tick (time, bid and ask prices, and volume of current minute). Helper class Timeframe is used to find a candle incoming tick belongs to.
When onConnected event occurs, function StartGettingData of HistoryMgr is called. HistoryMgr gets all available instruments and subscriptions. Price histories would be gathered for valid and subscribed instruments only. Function SendMarketDataSnapshotForHistory fills and sends request for MarketdataSnapshot. This function can be called several times until the required number of initial candles would be received. So when using using createMarketDataSnapshotRequestInstrument
O2GRequest createMarketDataSnapshotRequestInstrument (string instrument, O2GTimeframe timeframe, int maxBars)
initially maxBars equals to the required number of bars, and is reduced for the amount of candles in the history for subsequent calls.
When using fillMarketDataSnapshotRequestTime
void fillMarketDataSnapshotRequestTime (O2GRequest request, DateTime timeFrom, DateTime timeTo)
timeFrom equals 01/01/1900 while timeTo initially equals to ZERODATE (which means “up to now”), and during subsequent calls timeTo equals the date of the earliest candle.
The request ID for MarketDataSnapshot would be kept with a history.
Function ProcessMarketDataSnapshot is called when onResponse event occurs, and the type of response is MarketDataSnapshot.
It adds candles to the history with corresponding request ID and makes another call to SendMarketDataSnapshotForHistory if there not enough candles.
Function ProcessOffer is called when onResponse event occurs and the type of response is either GetOffers or TablesUpdates.
If candles are ready, the new ticks would be added to the candles’ collection, otherwise they would be added to the ticks’ collection.
When candles are ready (application got required number of initial candles), timer is launched. On event “Timer elapsed” output file is updated. The last candle written to output file is exchanged for the candle from the CandleHistory (which could be updated with new ticks), and new candles are added.
Should "reconnect" event happen CandleHistories are reset (ticks' and candles' collections are cleared, application sends new requests for price histories, and output files are rewritten.
You can download project exporting live chart data to .csv file here:
The attachment ProgramMain.png is no longer available

1.png

2.png
Last edited by allpin on Mon Sep 19, 2011 2:52 pm, edited 11 times in total.
allpin
FXCodeBase: Confirmed User
 
Posts: 21
Joined: Thu Aug 19, 2010 3:29 pm

Re: Live chart data export to CSV

Postby chimpy » Thu Jul 21, 2011 9:07 pm

allpin,

Thanks a lot for your help in resolving this request. I will try out your solution over the next four weeks and let you know how I get on.

Thanks again

Chimpy
Last edited by chimpy on Mon Aug 01, 2011 2:50 pm, edited 1 time in total.
chimpy
 
Posts: 98
Joined: Fri Jun 10, 2011 10:32 am

Next

Return to Custom Indicators

Who is online

Users browsing this forum: No registered users and 14 guests