IchiMoku Senkou Values Wrong

Created at 02 Jul 2014, 05:40
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!
FX

fxkaiten

Joined 04.10.2013

IchiMoku Senkou Values Wrong
02 Jul 2014, 05:40


Hello,

I am using the Ichimokukinkyohyo indicator exactly like it is in the example.

The parameters are 9,26,52

Regardless of the time frame, the values that I am getting for the SenkouSpanA

and SenkouSpanB are wrong.  They are much higher than the values show on

the indicator on screen.  The values are up where the Tenkan and Kijun are when

they should be much lower (as the price is rising).  Has anyone seen this or have

any ideas?

 

Thanks,

FXK


@fxkaiten
Replies

Spotware
02 Jul 2014, 10:13

Regarding to our tests IchimokuKinkoHyo indicator provides correct values. Please post the code that you use to access indicator values. Probably you have a mistake in indices calculation.


@Spotware

fxkaiten
02 Jul 2014, 18:21

RE:

Spotware said:

Regarding to our tests IchimokuKinkoHyo indicator provides correct values. Please post the code that you use to access indicator values. Probably you have a mistake in indices calculation.

Thanks for the reply.  To make it easy, I just used your example code and I am able to replicate the problem.

When I run this now 23:17 GMT+8 hours using a 15 minute chart, I get prints from the code:

Senkou B 101.597

Senkou A 101.667

When I look at the values on the screen with the indicator overlayed, I get:

Senkou B 101.558

Senkou A 101.534

Appreciate if you could help me see why I am getting different values.  I must be just overlooking something obvious.

Thanks,

FXK

 

 

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 NewIchimokuTest : Robot
    {


        private IchimokuKinkoHyo ichimokuKinkoHyo;

        protected override void OnStart()
        {

            ichimokuKinkoHyo = Indicators.IchimokuKinkoHyo(9, 26, 52);
        }

        protected override void OnTick()
        {

            Print("ChikouSpan Value = {0}", ichimokuKinkoHyo.ChikouSpan.LastValue);
            Print("KijunSen Value = {0}", ichimokuKinkoHyo.KijunSen.LastValue);
            Print("SenkouSpanA Value = {0}", ichimokuKinkoHyo.SenkouSpanA.LastValue);
            Print("SenkouSpanB Value = {0}", ichimokuKinkoHyo.SenkouSpanB.LastValue);
            Print("TenkanSen Value = {0}", ichimokuKinkoHyo.TenkanSen.LastValue);


        }

    }

}

 


@fxkaiten

Spotware
03 Jul 2014, 09:15 ( Updated at: 21 Dec 2023, 09:20 )

The problem is that you use LastValue property of SenkouSpanA and SenkouSpanB dataseries. The difference between last value and current value is shown on this image:

You can use the following code snippet to access current values:


        protected override void OnTick()
        {
            var index = MarketSeries.Close.Count - 1;
            Print("Span A: ", ichimoku.SenkouSpanA[index]);
            Print("Span B: ", ichimoku.SenkouSpanB[index]);
        }

 


@Spotware

fxkaiten
03 Jul 2014, 18:35

RE:

Ah yes, that totally clears it up.  Thanks very much.  I completely forgot that Ichimoku looks ahead.

Thanks again for the quick response and the code to fix it.

Best,

FXK

 

 


@fxkaiten