Real Ticks historic Data

Created at 19 Mar 2018, 16: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!
CE

ceakuk

Joined 19.03.2018

Real Ticks historic Data
19 Mar 2018, 16:26


I find historical data using MarketSeries.Close.LastValue is totally different from using Symbol.Bid and Symbol.Ask.

Is there a way I can  use  real historic data using symbol.Ask, symbol.Bid or any other way. I'm looking for real  accurate data. Thanks a lot


@ceakuk
Replies

PanagiotisCharalampous
19 Mar 2018, 16:36

Hi ceakuk,

MarketSeries.Close.LastValue has the Close value of the last bar. Symbol.Ask and Symbol.Bid contain the latest tick prices. Values included in MarketSeries are constructed from past tick data therefore they are accurate. Would you like to give us some more information on what you are doing, maybe by sharing a cBot, so that we can advise further?

Best Regards,

Panagiotis


@PanagiotisCharalampous

ceakuk
19 Mar 2018, 17:06

Thanks for reply.

im creating a Cbot using this renko /algos/indicators/show/1086

I'm expecting  to buy everytime it Turns Bullish and Sell everytime it turns Bearish.

I'm expecting that if my Bricksize is say 50Pips, then the maximum loss should be 2X= 100pips +- small value. So 1 brick stoploss However I'm seeing upto 4X in Loss whenever I buy and it turns bearish and vice versa. Any Ideas will be highly appreciated

 

using System;
using System.Linq;
using System.Collections.Generic;
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 RenkoBot : Robot
    {

        [Parameter("Renko Pips", DefaultValue = 10, MinValue = 0.5, Step = 2)]
        public double RenkoPips { get; set; }


        [Parameter("Number Of Bricks", DefaultValue = 100, MinValue = 10, Step = 100)]
        public int BricksToShow { get; set; }

        [Parameter("Zoom Level", DefaultValue = 3, MinValue = 0, MaxValue = 5, Step = 1)]
        public double ZoomLevel { get; set; }

        [Parameter("Bullish bar color", DefaultValue = "SeaGreen")]
        public string BullishBarColor { get; set; }

        [Parameter("Bearish bar color", DefaultValue = "Tomato")]
        public string BearishBarColor { get; set; }

        [Parameter("Quantity", DefaultValue = 1000, MinValue = 1000, Step = 1000)]
        public int Quantity { get; set; }


        private Renko renko;

        protected override void OnStart()
        {
            object[] parameterValues = 
            {
                RenkoPips,
                // Bar size
                BricksToShow,
                // Show number of bricks
                ZoomLevel,
                //ZoomLevel
                BullishBarColor,
                // Bullish bar color
                BearishBarColor
                // Bearish bar color
            };
            renko = Indicators.GetIndicator<Renko>(parameterValues);
        }

        protected override void OnTick()
        {

            var buyPosition = Positions.Find("Renko", Symbol, TradeType.Buy);
            var sellPosition = Positions.Find("Renko", Symbol, TradeType.Sell);

            bool isLastBrickBullish = renko.Open.Last(0) < renko.Close.Last(0);


            if (isLastBrickBullish && buyPosition == null)
            {
                if (sellPosition != null)
                    ClosePosition(sellPosition);
                //Print("buying");
                ExecuteMarketOrder(TradeType.Buy, Symbol, Quantity, "Renko");
            }

            else if (!isLastBrickBullish && sellPosition == null)
            {
                if (buyPosition != null)
                    ClosePosition(buyPosition);
                //Print("Selling");
                ExecuteMarketOrder(TradeType.Sell, Symbol, Quantity, "Renko");
            }
        }
    }
}


@ceakuk

ceakuk
19 Mar 2018, 17:09

RE:

ceakuk said:

Thanks for reply.

im creating a Cbot using this renko/algos/indicators/show/1086

I'm expecting  to buy everytime it Turns Bullish and Sell everytime it turns Bearish.

I'm expecting that if my Bricksize is say 50Pips, then the maximum loss should be 2X= 100pips +- small value. So 1 brick stoploss However I'm seeing upto 4X in Loss whenever I buy and it turns bearish and vice versa. Any Ideas will be highly appreciated

 

    using System;
    using System.Linq;
    using System.Collections.Generic;
    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 RenkoBot : Robot
        {

            [Parameter("Renko Pips", DefaultValue = 10, MinValue = 0.5, Step = 2)]
            public double RenkoPips { get; set; }


            [Parameter("Number Of Bricks", DefaultValue = 100, MinValue = 10, Step = 100)]
            public int BricksToShow { get; set; }

            [Parameter("Zoom Level", DefaultValue = 3, MinValue = 0, MaxValue = 5, Step = 1)]
            public double ZoomLevel { get; set; }

            [Parameter("Bullish bar color", DefaultValue = "SeaGreen")]
            public string BullishBarColor { get; set; }

            [Parameter("Bearish bar color", DefaultValue = "Tomato")]
            public string BearishBarColor { get; set; }

            [Parameter("Quantity", DefaultValue = 1000, MinValue = 1000, Step = 1000)]
            public int Quantity { get; set; }


            private Renko renko;

            protected override void OnStart()
            {
                object[] parameterValues = 
                {
                    RenkoPips,
                    // Bar size
                    BricksToShow,
                    // Show number of bricks
                    ZoomLevel,
                    //ZoomLevel
                    BullishBarColor,
                    // Bullish bar color
                    BearishBarColor
                    // Bearish bar color
                };
                renko = Indicators.GetIndicator<Renko>(parameterValues);
            }

            protected override void OnTick()
            {

                var buyPosition = Positions.Find("Renko", Symbol, TradeType.Buy);
                var sellPosition = Positions.Find("Renko", Symbol, TradeType.Sell);

                bool isLastBrickBullish = renko.Open.Last(0) < renko.Close.Last(0);


                if (isLastBrickBullish && buyPosition == null)
                {
                    if (sellPosition != null)
                        ClosePosition(sellPosition);
                    //Print("buying");
                    ExecuteMarketOrder(TradeType.Buy, Symbol, Quantity, "Renko");
                }

                else if (!isLastBrickBullish && sellPosition == null)
                {
                    if (buyPosition != null)
                        ClosePosition(buyPosition);
                    //Print("Selling");
                    ExecuteMarketOrder(TradeType.Sell, Symbol, Quantity, "Renko");
                }
            }
        }
    }


 


@ceakuk

PanagiotisCharalampous
19 Mar 2018, 17:20

Hi ceacuk,

Thank you. Where in the cBot are you using MarketSeries.Close.LastValue? I see only renko.Close.Last(0).

Best Regards,

Panagiotis


@PanagiotisCharalampous

ceakuk
19 Mar 2018, 17:24

RE:

Panagiotis Charalampous said:

Hi ceakuk,

MarketSeries.Close.LastValue has the Close value of the last bar. Symbol.Ask and Symbol.Bid contain the latest tick prices. Values included in MarketSeries are constructed from past tick data therefore they are accurate. Would you like to give us some more information on what you are doing, maybe by sharing a cBot, so that we can advise further?

Best Regards,

Panagiotis

Thanks for reply.

im creating a Cbot using this renko/algos/indicators/show/1086

I'm expecting  to buy everytime it Turns Bullish and Sell everytime it turns Bearish.

I'm expecting that if my Bricksize is say 50Pips, then the maximum loss should be 2X= 100pips +- small value. So 1 brick stoploss However I'm seeing upto 4X in Loss whenever I buy and it turns bearish and vice versa. Any Ideas will be highly appreciated

using System;
using System.Linq;
using System.Collections.Generic;
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 RenkoBot : Robot
    {
 
        [Parameter("Renko Pips", DefaultValue = 10, MinValue = 0.5, Step = 2)]
        public double RenkoPips { get; set; }
 
 
        [Parameter("Number Of Bricks", DefaultValue = 100, MinValue = 10, Step = 100)]
        public int BricksToShow { get; set; }
 
        [Parameter("Zoom Level", DefaultValue = 3, MinValue = 0, MaxValue = 5, Step = 1)]
        public double ZoomLevel { get; set; }
 
        [Parameter("Bullish bar color", DefaultValue = "SeaGreen")]
        public string BullishBarColor { get; set; }
 
        [Parameter("Bearish bar color", DefaultValue = "Tomato")]
        public string BearishBarColor { get; set; }
 
        [Parameter("Quantity", DefaultValue = 1000, MinValue = 1000, Step = 1000)]
        public int Quantity { get; set; }
 
 
        private Renko renko;
 
        protected override void OnStart()
        {
            object[] parameterValues = 
            {
                RenkoPips,
                // Bar size
                BricksToShow,
                // Show number of bricks
                ZoomLevel,
                //ZoomLevel
                BullishBarColor,
                // Bullish bar color
                BearishBarColor
                // Bearish bar color
            };
            renko = Indicators.GetIndicator<Renko>(parameterValues);
        }
 
        protected override void OnTick()
        {
 
            var buyPosition = Positions.Find("Renko", Symbol, TradeType.Buy);
            var sellPosition = Positions.Find("Renko", Symbol, TradeType.Sell);
 
            bool isLastBrickBullish = renko.Open.Last(0) < renko.Close.Last(0);
 
 
            if (isLastBrickBullish && buyPosition == null)
            {
                if (sellPosition != null)
                    ClosePosition(sellPosition);
                //Print("buying");
                ExecuteMarketOrder(TradeType.Buy, Symbol, Quantity, "Renko");
            }
 
            else if (!isLastBrickBullish && sellPosition == null)
            {
                if (buyPosition != null)
                    ClosePosition(buyPosition);
                //Print("Selling");
                ExecuteMarketOrder(TradeType.Sell, Symbol, Quantity, "Renko");
            }
        }
    }
}

 

 


@ceakuk

ceakuk
19 Mar 2018, 17:33

RE:

Panagiotis Charalampous said:

Hi ceacuk,

Thank you. Where in the cBot are you using MarketSeries.Close.LastValue? I see only renko.Close.Last(0).

Best Regards,

Panagiotis

Here it is :Renko

/algos/indicators/show/1086

 


@ceakuk

ceakuk
19 Mar 2018, 17:34

RE:

/algos/indicators/show/1086

 

 


@ceakuk

PanagiotisCharalampous
19 Mar 2018, 17:37

Hi ceakuk,

In the original post you said 

MarketSeries.Close.LastValue is totally different from using Symbol.Bid and Symbol.As

however you are not using anywhere MarketSeries.Close.LastValue. You are using renko.Close.Last(0). This is a third party indicator. If you think that this indicator returns wrong values, you should contact the creator of the indicator.

Best Regards,

Panagiotis


@PanagiotisCharalampous

ceakuk
19 Mar 2018, 17:45

RE:

Panagiotis Charalampous said:

The indicator uses  MarketSeries.Close.LastValue
When I change that to Symbol.Bid or Symbol.Ask or the mean, its totally different. There are other Renko indicators that also use  MarketSeries.Close.LastValue
namely /algos/indicators/show/457 and  /algos/indicators/show/1332 and /algos/indicators/show/1086
so its not the indicator. all are producing the same results. When I open on Bullish then when it turns Bearish from the MarketSeries.Close.LastValue, the Symbol.Bid or Symbol.Ask show something totally different.
 
So you said Symbol.Bid or Symbol.Ask can't be used for historic data or  it can?

 


@ceakuk

PanagiotisCharalampous
19 Mar 2018, 17:54

Hi ceakuk,

MarketSeries.Close.LastValue should always be equal to Symbol.Bid.  However this is not the case with renko.Close.Last(0). See below.

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
    {
        [Parameter(DefaultValue = 0.0)]
        public double Parameter { get; set; }
        private Renko renko;
        [Parameter("Renko Pips", DefaultValue = 10, MinValue = 0.5, Step = 2)]
        public double RenkoPips { get; set; }


        [Parameter("Number Of Bricks", DefaultValue = 100, MinValue = 10, Step = 100)]
        public int BricksToShow { get; set; }

        [Parameter("Zoom Level", DefaultValue = 3, MinValue = 0, MaxValue = 5, Step = 1)]
        public double ZoomLevel { get; set; }

        [Parameter("Bullish bar color", DefaultValue = "SeaGreen")]
        public string BullishBarColor { get; set; }

        [Parameter("Bearish bar color", DefaultValue = "Tomato")]
        public string BearishBarColor { get; set; }
        protected override void OnStart()
        {
            object[] parameterValues = 
            {
                RenkoPips,
                // Bar size
                BricksToShow,
                // Show number of bricks
                ZoomLevel,
                //ZoomLevel
                BullishBarColor,
                // Bullish bar color
                BearishBarColor
                // Bearish bar color
            };
            renko = Indicators.GetIndicator<Renko>(parameterValues);
        }

        protected override void OnTick()
        {
            Print("Last Close Price:" + MarketSeries.Close.LastValue);
            Print("Last Bid Price:" + Symbol.Bid);
            Print("Last Close Renko Price:" + renko.Close.Last(0));
        }

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

Therefore I don't see any issue with MarketSeries.Close.LastValue.

Best Regards,

Panagiotis


@PanagiotisCharalampous

ceakuk
20 Mar 2018, 01:48

RE:

Panagiotis Charalampous said:

Hi Panagiotis,

Thanks a lot. I now know where the problem lies

In the Robot im using 

MarketSeries.Open.LastValue  or MarketSeries.Open.Last(0)

and it is as accurate as Symbol.Ask, Symbol.Bid.

However within the Indicator, MarketSeries.Open.LastValue  or MarketSeries.Open.Last(0)  is totally different

Thanks With kind regards,

Kevin

 


@ceakuk