Get List of Supported Time Frames (O2GO, CS)

From FxCodeBaseWiki
Jump to: navigation, search

The example shows how to retrieve all available price history periods.

using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;

namespace Sample.HistoryPeriods
{
    class Program
    {
        static FXCore.CoreAut mCore;
        static FXCore.TradeDeskAut mDesk;        

        static void Main(string[] args)
        {
            try
            {
                if (args.Length < 2)
                {
                    Console.WriteLine("usage: sample.HistoryPeriods user password");
                    return;
                }

                //create o2go object and login
                mCore = new FXCore.CoreAut();
                mDesk = (FXCore.TradeDeskAut)mCore.CreateTradeDesk("trader");                
                mDesk.Login(args[0], args[1], "http://www.fxcorporate.com", "Demo");

                //create the price history helper object
                FXCore.PriceHistoryHelperAut priceHelper = (FXCore.PriceHistoryHelperAut)mDesk.PriceHistoryHelper;

                //request the avialable eriods for the current connection and print it
                FXCore.StringEnumAut periods = (FXCore.StringEnumAut)priceHelper.GetPeriods();
                Console.WriteLine("The available periods are:");
                foreach (string period in periods)
                {
                    Console.WriteLine(period);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("{0}", e.ToString());
            }

             //finalizing
             mDesk.Logout();
        }        
    }
}

This Article in Other Languages

Language: English  • español