QuickStart - Print

Spotware's avatar

Spotware since: 23 Sep 2013;

  15 Jan 2014, 12:19
QuickStart - Print
// -------------------------------------------------------------------------------------------------
//
//    This code is a demonstration of the different syntax that can be used to print messages to the log
//
// -------------------------------------------------------------------------------------------------

using cAlgo.API;

namespace cAlgo.Indicators
{
    [Indicator]
    public class PrintToLog:Indicator
    {
        protected override void Initialize()
        {
            Print("Initializing PrintToLog Indicator");
        }

        public override void Calculate(int index)
        {            
            Print("index {0}", index);

            var close = MarketSeries.Close.LastValue;
            var high = MarketSeries.High.LastValue;
            var low = MarketSeries.Low.LastValue;
            
            Print("Current close {0}, high {1}, low {2}", close, high, low);
            
            Print("Account info:");
            Print(Account.Balance);
            Print(Account.Equity);            
            Print(Account.Margin);
            Print("Open Positions: " + Positions.Count + "position(s)");
            Print("Pending Orders: " + PendingOrders.Count + "order(s)");
        }
    }
}
TRADERS FIRSTâ„¢ Vote for your favorite features: https://ctrader.com/forum/suggestions