Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Export time of the bar in the right format

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Export time of the bar in the right format

    Hi, I'm trying to export historical data from NT to metastock.

    If I use standard NT export option, the format of the text file is not understandable by metastock.

    So I created a simple strategy to export data from each bar in the right format

    Code:
    Print(Instrument.FullName+",5,"+Time[0]+","+Open[0]+","+High[0]+","+Low[0]+","+Close[0]);
    And the result is:

    ES 12-12,5,11/29/2012 12:55:00 AM,1406.5,1406.75,1406.5,1406.75

    The problem is, I need to split Time[0] into 2 parts:

    1) date in YYYYMMDD format, followed by
    2) time in HHMMSS format.

    The result should look like

    ES 12-12,5,20121129,125500,1406.5,1406.75,1406.5,1406.75

    How do I exctract those separately from Time[0] ?

    #2
    Hi kosmipt,

    Well, there is a C# method:
    string[] words = text.Split(delimiterChars);

    Clearly Time[0] can be split into three parts: 11/29/2012, 12:55:00, and AM based on the space delimeter. So,

    string[] time = Time[0].Split(' ');

    time[0] will have the 11/29/2012
    time[1] will have 12:55:00
    time[2] will have AM

    Then repeat for the first part using the delimeter /
    string[] date = time[0].Split('/ ');

    So date[0] will have 11
    date[1] will have 29
    date[2] will have 2012

    And do the same for the time.

    string[] actualTime = time[1].Split(': ');
    actualTime[0] will be 12
    actualTime[1] will be 55
    actualTime[2] will be 00

    Then reassemble into the format you want and send then to Metastock.

    string newDate = date[2]+date[0]+date[1];
    string newTime =actualTime[0}+actualTime[1]+actualTime[2];

    There probably is a cleaner way to do this but this should get you started.

    Comment


      #3
      Thanks a lot, it worked!

      Comment


        #4
        Great. Glad it worked for you.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by timmbbo, Today, 08:59 AM
        1 response
        2 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by KennyK, 05-29-2017, 02:02 AM
        2 responses
        1,281 views
        0 likes
        Last Post marcus2300  
        Started by fernandobr, Today, 09:11 AM
        0 responses
        3 views
        0 likes
        Last Post fernandobr  
        Started by itrader46, Today, 09:04 AM
        1 response
        6 views
        0 likes
        Last Post NinjaTrader_Clayton  
        Started by bmartz, 03-12-2024, 06:12 AM
        5 responses
        33 views
        0 likes
        Last Post NinjaTrader_Zachary  
        Working...
        X