MarketSeries.Open.LastValue from Indicator and cbot differ

Created at 20 Mar 2018, 01:52
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!
CE

ceakuk

Joined 19.03.2018

MarketSeries.Open.LastValue from Indicator and cbot differ
20 Mar 2018, 01:52


Could anybody please help. Im using the code MarketSeries.Open.LastValue  or MarketSeries.Open.Last(0)  in both Cbot and the Indicator. However the  values are totally different with the indicator  value  being wrong. Thanks a lot


@ceakuk
Replies

PanagiotisCharalampous
20 Mar 2018, 11:13 ( Updated at: 21 Dec 2023, 09:20 )

Hi ceakuk,

I have tried this but does not seem to be true. See my examples below

Indicator

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

namespace cAlgo
{
    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class LastValueIndicator : Indicator
    {
        [Output("Main")]
        public IndicatorDataSeries Result { get; set; }


        protected override void Initialize()
        {
            // Initialize and create nested indicators
        }

        public override void Calculate(int index)
        {
            // Calculate value at specified index
            Result[index] = MarketSeries.Close.LastValue;
        }
    }
}

cBot

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

        private LastValueIndicator _ind;
        protected override void OnStart()
        {
            _ind = Indicators.GetIndicator<LastValueIndicator>();
        }

        protected override void OnTick()
        {
            Print("cBot Last Value: " + MarketSeries.Close.LastValue);
            Print("Indicator Last Value:" + _ind.Result.LastValue);
        }

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

Results

Let me know if I am missing something.

Best Regards,

Panagiotis


@PanagiotisCharalampous

ceakuk
21 Mar 2018, 17:42

RE:

Panagiotis Charalampous said:

Please help I completely don't trust cAlgo back testing

After many months of  coding, I can't tell if my Robots could have worked or not. All lost money on back testing but now I can see the problem is the platform. This backtesting business is not right,

 

I'm using Renko of 10 pips. I buy when  renko chart gets red and buy when its green. I expect no position can loose 10pips+  some small  number. unfortunately I loose  even 75 pips which is crazy see image https://imgur.com/a/p02Bl

but when I print logs for Symbol.Bid, Symbol.Ask,  and Renko Position, none shows a loosing position. Infact the pisition  should be +25pips and counting but  calgo closes the position as -75pips.

What exactly is wrong with calgo.

I try both1M bar data and Ticks data

Open buy position and closs all sell positions  when renko turns green and
Open sell position and close all buy positions  when renko turns red
https://www.tradingacademy.com/lessons/wp-content/uploads/bwendell-20131210-spy-renko.jpg

Thanks and  Best regards,

Kevin


@ceakuk