IchimokuKinkoHyo ChikouSpan Data Incorrect

Created at 09 Oct 2017, 10:15
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
ClickAlgo's avatar

ClickAlgo

Joined 05.02.2015

IchimokuKinkoHyo ChikouSpan Data Incorrect
09 Oct 2017, 10:15


Hi, Spotware Team,

I am running a back-test to store the values from the IchimokuKinkoHyo indicator and all the values are correct apart from the ChikouSpan, could you please assist, the code snippet is below.

var r = workSheet.CreateRow(rowNum);
var index = MarketSeries.Close.Count - 1;

// create columns
r.CreateCell(0).SetCellValue(MarketSeries.OpenTime.Last(1).ToShortDateString());
r.CreateCell(1).SetCellValue(MarketSeries.OpenTime.Last(1).ToShortTimeString());
r.CreateCell(2).SetCellValue(MarketSeries.Open.Last(1));
r.CreateCell(3).SetCellValue(MarketSeries.High.Last(1));
r.CreateCell(4).SetCellValue(MarketSeries.Low.Last(1));
r.CreateCell(5).SetCellValue(MarketSeries.Close.Last(1));
r.CreateCell(6).SetCellValue(ihk.TenkanSen[index]);
r.CreateCell(7).SetCellValue(ihk.KijunSen[index]);

// Read this cTDN support thread
// /forum/cbot-support/3093

r.CreateCell(8).SetCellValue(ihk.SenkouSpanA[index]);
r.CreateCell(9).SetCellValue(ihk.SenkouSpanB[index]);

// Invalid
r.CreateCell(10).SetCellValue(ihk.ChikouSpan[index]);

r.CreateCell(11).SetCellValue(MarketSeries.TickVolume.Last(1));

Paul Hayes
Sales & Marketing
Emailcontact@clickalgo.com
Phone: (44) 203 289 6573
Websitehttps://clickalgo.com


@ClickAlgo
Replies

PanagiotisCharalampous
09 Oct 2017, 10:41

Ηι Paul,

What made you conclude that the ChikouSpan value is wrong? Do you have any expected vs real values? Could we have a fully working example of the export to check that? This information would make it easier for us to assist you.

Best Regards,

Panagiotis

 


@PanagiotisCharalampous

ClickAlgo
09 Oct 2017, 10:47 ( Updated at: 21 Dec 2023, 09:20 )

Good point, I should have added this information, the value coming out is undefined (NaN)


@ClickAlgo

ClickAlgo
09 Oct 2017, 11:00

Hi, Panagiotis,

I will create a simple cBot example that prints to the log file before you guys investigate any further.


@ClickAlgo

ClickAlgo
09 Oct 2017, 11:16 ( Updated at: 21 Dec 2023, 09:20 )

here is the simple code example

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 IchimokuKinkoHyoTest : Robot
    {
        IchimokuKinkoHyo ihk;

        protected override void OnStart()
        {
            ihk = Indicators.IchimokuKinkoHyo(9, 26, 32);
        }

        protected override void OnBar()
        {
            var index = MarketSeries.Close.Count - 1;


            Print(ihk.TenkanSen[index]);
            Print(ihk.KijunSen[index]);
            Print(ihk.SenkouSpanA[index]);
            Print(ihk.SenkouSpanB[index]);

            // Invalid
            Print(ihk.ChikouSpan[index]);
        }

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

 

here is the output to the log display


@ClickAlgo

PanagiotisCharalampous
09 Oct 2017, 14:21 ( Updated at: 21 Dec 2023, 09:20 )

Hi Paul,

The behavior is correct. ChikouSpan is a line that plots recent prices n periods ago. On current bar it's value is NaN. See below

In order to get the last ChikuSpan value, you need to use the following code.

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 IchimokuKinkoHyoTest : Robot
    {
        IchimokuKinkoHyo ihk;

        protected override void OnStart()
        {
            ihk = Indicators.IchimokuKinkoHyo(9, 26, 32);
        }

        protected override void OnBar()
        {
            var index = MarketSeries.Close.Count - 1;
            Print(ihk.TenkanSen[index]);
            Print(ihk.KijunSen[index]);
            Print(ihk.SenkouSpanA[index]);
            Print(ihk.SenkouSpanB[index]);          
            Print(ihk.ChikouSpan[index - 26]);
        }

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

Hope this helps.

Best Regards,

Panagiotis


@PanagiotisCharalampous

ClickAlgo
09 Oct 2017, 14:24

Hi, Panagiotis,

That is fantastic, thank you very much for a prompt response.

Paul.


@ClickAlgo