senkou span a and b gives same vaues??

Created at 25 Feb 2020, 00:13
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!
BA

barancansahin88

Joined 25.02.2020

senkou span a and b gives same vaues??
25 Feb 2020, 00:13


Senkou span A and senkou span b values are always same in my program, I couldnt fix the problem. How can i have true values of senkou span a and b?

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 SampleSARTrailingStop : Robot
    {
        //Ichimoku Settings - NOT BE BE CHANGED UNLESS YOU KNOW WHAT YOU ARE DOING
        [Parameter(DefaultValue = 9)]
        private int tenkansen { get; set; }
        [Parameter(DefaultValue = 26)]
        private int kijunsen { get; set; }
        [Parameter(DefaultValue = 52)]
        private int senb { get; set; }
        public IndicatorDataSeries SenkouSpanB { get; set; }
        public IndicatorDataSeries SenkouSpanA { get; set; }


        IchimokuKinkoHyo ichimoku;


        protected override void OnStart()
        {
            ichimoku = Indicators.IchimokuKinkoHyo(tenkansen, kijunsen, senb);

        }

        protected override void OnBar()
        {
            var index = Bars.ClosePrices.Count;
            if (ichimoku.SenkouSpanB[index - 26] > Symbol.Ask && ichimoku.SenkouSpanB[index - 26] > Symbol.Ask)
            {
               
                    ExecuteMarketOrder(TradeType.Sell, Symbol.Name, 10000, "sat");
                
            }
            else if (ichimoku.SenkouSpanA[index - 26] < Symbol.Ask && ichimoku.SenkouSpanA[index - 26] < Symbol.Ask)
            {

                {
                    ExecuteMarketOrder(TradeType.Buy, Symbol.Name, 10000, "al");
                    Print("SenkouSpanA Value = {0}", ichimoku.SenkouSpanA[index - 26]);
                    Print("SenkouSpanB Value = {0}", ichimoku.SenkouSpanB[index - 26]);
                    Print("ChikouSpan Value = {0}", ichimoku.ChikouSpan.LastValue);
                    Print("KijunSen Value = {0}", ichimoku.KijunSen.LastValue);
                }
            }
        }
    }
}


@barancansahin88
Replies

PanagiotisCharalampous
25 Feb 2020, 08:44

Hi barancansahin88,

I cannot reproduce the problem. The values change on every bar, see below.

Best Regards,

Panagiotis 

Join us on Telegram

 


@PanagiotisCharalampous

barancansahin88
25 Feb 2020, 09:38 ( Updated at: 21 Dec 2023, 09:21 )

RE:

Thank you for answer, but SenkouSpan A and B values are same at every bar. They are supposed to have different values to create kumo cloud.

PanagiotisCharalampous said:

Hi barancansahin88,

I cannot reproduce the problem. The values change on every bar, see below.

Best Regards,

Panagiotis 

Join us on Telegram

 

 


@barancansahin88

srubtsov
26 Feb 2020, 12:11

RE:

barancansahin88 said:

Senkou span A and senkou span b values are always same in my program, I couldnt fix the problem. How can i have true values of senkou span a and b?

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 SampleSARTrailingStop : Robot
    {
        //Ichimoku Settings - NOT BE BE CHANGED UNLESS YOU KNOW WHAT YOU ARE DOING
        [Parameter(DefaultValue = 9)]
        private int tenkansen { get; set; }
        [Parameter(DefaultValue = 26)]
        private int kijunsen { get; set; }
        [Parameter(DefaultValue = 52)]
        private int senb { get; set; }
        public IndicatorDataSeries SenkouSpanB { get; set; }
        public IndicatorDataSeries SenkouSpanA { get; set; }


        IchimokuKinkoHyo ichimoku;


        protected override void OnStart()
        {
            ichimoku = Indicators.IchimokuKinkoHyo(tenkansen, kijunsen, senb);

        }

        protected override void OnBar()
        {
            var index = Bars.ClosePrices.Count;
            if (ichimoku.SenkouSpanB[index - 26] > Symbol.Ask && ichimoku.SenkouSpanB[index - 26] > Symbol.Ask)
            {
               
                    ExecuteMarketOrder(TradeType.Sell, Symbol.Name, 10000, "sat");
                
            }
            else if (ichimoku.SenkouSpanA[index - 26] < Symbol.Ask && ichimoku.SenkouSpanA[index - 26] < Symbol.Ask)
            {

                {
                    ExecuteMarketOrder(TradeType.Buy, Symbol.Name, 10000, "al");
                    Print("SenkouSpanA Value = {0}", ichimoku.SenkouSpanA[index - 26]);
                    Print("SenkouSpanB Value = {0}", ichimoku.SenkouSpanB[index - 26]);
                    Print("ChikouSpan Value = {0}", ichimoku.ChikouSpan.LastValue);
                    Print("KijunSen Value = {0}", ichimoku.KijunSen.LastValue);
                }
            }
        }
    }
}

The problem is in private properties. Parameters can't be with `private` access modifier, it should be with `public`. So default value isn't applied to properties and they all contain zero value.


@srubtsov