MarketData.GetBars(TimeFrame.Minute, "HONG KONG 50").ClosePrices.LastValue returns NaN value

Created at 10 Apr 2023, 14:49
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!
YS

ys2310

Joined 03.12.2021

MarketData.GetBars(TimeFrame.Minute, "HONG KONG 50").ClosePrices.LastValue returns NaN value
10 Apr 2023, 14:49


I'm backtesting from 2022/12/01 to 2023/4/10 using Symbol "HONG KONG 50" with Fondex cTrader v.4.6.5

All other symbol returns correct values except the following,

MarketData.GetBars(TimeFrame.Minute, "HONG KONG 50").ClosePrices.LastValue

The returned values are all NaN. Is this a broker issue or cTrader problem?

Thank you very much in advance.


@ys2310
Replies

firemyst
10 Apr 2023, 15:36

Have you looked up the actual Indicie symbol name for HONG KONG 50 on your platform?

On most other cTrader platforms, it's known as "HK50"


@firemyst

ys2310
10 Apr 2023, 15:54

RE:

firemyst said:

Have you looked up the actual Indicie symbol name for HONG KONG 50 on your platform?

On most other cTrader platforms, it's known as "HK50"

Yeah, I confirmed it's "HONG KONG 50" on Fondex cTrader. Otherwise, I'll get a Null Reference exception error at runtime.


@ys2310

PanagiotisChar
10 Apr 2023, 17:04

Hi there,

Can you share the complete cBot code so that we can run it and reproduce this behavior?

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

 


@PanagiotisChar

ys2310
10 Apr 2023, 19:29 ( Updated at: 10 Apr 2023, 19:36 )

RE:

PanagiotisChar said:

Hi there,

Can you share the complete cBot code so that we can run it and reproduce this behavior?

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

 

Yes, here is the code.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;

namespace cAlgo.Robots
{
    [Robot(AccessRights = AccessRights.None)]
    public class NewcBot15 : Robot
    {
        [Parameter(DefaultValue = "Hello world!")]
        public string Message { get; set; }

        protected override void OnStart()
        {
            // To learn more about cTrader Automate visit our Help Center:
            // https://help.ctrader.com/ctrader-automate            
            Print(Message);
        }

        protected override void OnTick()
        {
            // Handle price updates here
            Print((MarketData.GetBars(TimeFrame.Minute, "HONG KONG 50").MedianPrices.LastValue));
        }

        protected override void OnStop()
        {
            // Handle cBot stop here
        }
    }
}

 


@ys2310

PanagiotisChar
11 Apr 2023, 07:46

Hi,

I tried this and works fine for me. Are you using tick data as a source?

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

 


@PanagiotisChar

ys2310
11 Apr 2023, 11:40 ( Updated at: 21 Dec 2023, 09:23 )

RE:

It's not working for me somehow. It seems cTrader internally converts something using HKDJPY which doesn't exist.

Btw, my account currency setting is JPY and this is a Fondex Demo account.

Can you try again and reproduce this?

PanagiotisChar said:

Hi,

I tried this and works fine for me. Are you using tick data as a source?

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

 

 


@ys2310