Replies

egi.messito
03 Aug 2016, 17:08

Solved:

Need to pass (this) in the custome class to get the Printing function into the log. 

this is the easier way other then using reflection...

public class CustomClass
{
    private MyRobot _robot;
  
    public CustomClass(MyRobot robot)
    {
        _robot = robot;
    }
  
    public void Print(string message)
    {
         _robot.PrintToLog(message)
    }
}

So in my code:

StrategyTest st = new StrategyTest(MarketData.GetSeries(TimeFrame), this);
            st.doSomething();

 


@egi.messito

egi.messito
03 Aug 2016, 16:51

Solved by passing 

StrategyTest st = new StrategyTest(MarketData.GetSeries(TimeFrame));

But i can still not Print(""); from another class

 

what do i need to initiate in the other class to be able to Print?


@egi.messito

egi.messito
03 Aug 2016, 15:49

anybody?


@egi.messito

egi.messito
02 Aug 2016, 21:24

RE:

At a more basic level 

using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;

namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class NewcBot : Robot
    {
        [Parameter(DefaultValue = 0.0)]
        public double Parameter { get; set; }

        public Testami t;

        protected override void OnStart()
        {
            // Put your initialization logic here
            t = new Testami();
        }

        protected override void OnTick()
        {
            // Put your core logic here
        }

        protected override void OnStop()
        {
            // Put your deinitialization logic here
        }
    }

    public class Testami : Robot
    {
        public Testami()
        {
            var index = MarketSeries.Close.Count - 1;

            double high = MarketSeries.High[index - 3];

            Print("test");
        }
    }
}

this would crash - why i cannot use Print and MarketSeries in the custom class?


@egi.messito