Replies

agent.xzxz
08 Apr 2020, 19:52

RE:

PanagiotisCharalampous said:

Hi agent.xzxz,

You need to change 

double openPriceByIndex = Bars.OpenPrices.Last(index);

to

 double openPriceByIndex = Bars.OpenPrices[index];

Best Regards,

Panagiotis 

Join us on Telegram

Thank you!


@agent.xzxz

agent.xzxz
06 Apr 2020, 16:14

RE:

Hi,

 

Can you run this code on your side? Select Monthly Timeframe.

 

using System;
using cAlgo.API;

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class IndexByTimeIssue : Robot
    {
        protected override void OnStart()
        {
            double lastBarOpenPrice = Bars.OpenPrices.LastValue;
            DateTime lastBarOpenTime = Bars.OpenTimes.LastValue;

            int index = Bars.OpenTimes.GetIndexByTime(lastBarOpenTime);

            double openPriceByIndex = Bars.OpenPrices.Last(index);
            Print("Equal?: ", lastBarOpenPrice == openPriceByIndex);
        }

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

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

 

Why lastBarOpenPrice is not equal to openPriceByIndex?

 

I only get the index by time right? They should be equal.


@agent.xzxz