Different values on chart and in cBot

Created at 17 Aug 2020, 19:26
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!
LU

lukasztrader

Joined 25.12.2019

Different values on chart and in cBot
17 Aug 2020, 19:26


Hi,

I am using indicator "Sample Envelopes Cloud" and the values on chart and in cBot's logs are different.

I saw the similar thread but it doesn't answer to my qeustion.

Both the chart and the bot have the same indicator settings.

Could you please tell why there is a difference on real market? As it happens I have observed this differences on BTCUSD, other tests on WTI, EURUSD seems to have proper values.

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

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
    public class Envelopes : Robot
    {
        [Parameter("EnvelopeOne", DefaultValue = 0.8)]
        public double EnvelopeOne { get; set; }
        [Parameter("EnvelopeTwo", DefaultValue = 1.5)]
        public double EnvelopeTwo { get; set; }

        SampleEnvelopesCloud _envOne;
        SampleEnvelopesCloud _envTwo;

        protected override void OnStart()
        {
            _envOne = Indicators.GetIndicator<SampleEnvelopesCloud>(20, EnvelopeOne);
            _envTwo = Indicators.GetIndicator<SampleEnvelopesCloud>(20, EnvelopeTwo);

            Print("Env1 Up: " + _envOne.UpperBand.LastValue);
            Print("Env1 Lo: " + _envOne.LowerBand.LastValue);
            Print("Env2 Up: " + _envTwo.UpperBand.LastValue);
            Print("Env2 Lo: " + _envTwo.LowerBand.LastValue);
        }

        protected override void OnBar()
        {
            Print("Env1 Up: " + _envOne.UpperBand.LastValue);
            Print("Env1 Lo: " + _envOne.LowerBand.LastValue);
            Print("Env2 Up: " + _envTwo.UpperBand.LastValue);
            Print("Env2 Lo: " + _envTwo.LowerBand.LastValue);
        }
    }
}

 


@lukasztrader
Replies

PanagiotisCharalampous
18 Aug 2020, 07:37

Hi Lukasz,

Most probably the problem is that you print the indicator's last value on bar opening. The indicator's value will probably change until the bar closes. If you want to compare finalized values, you should check Last(1).

Best Regards,

Panagiotis 

Join us on Telegram

 


@PanagiotisCharalampous

lukasztrader
18 Aug 2020, 17:24

RE:

PanagiotisCharalampous said:

Hi Lukasz,

Most probably the problem is that you print the indicator's last value on bar opening. The indicator's value will probably change until the bar closes. If you want to compare finalized values, you should check Last(1).

Best Regards,

Panagiotis 

Join us on Telegram

 

Thanks Panagiotis!


@lukasztrader