Topics
13 Sep 2024, 11:59
 234
 1
25 Sep 2023, 10:29
 453
 1
13 Aug 2023, 00:45
 463
 0
14 Mar 2023, 13:21
 872
 3
Replies

ys2310
03 Mar 2023, 10:14

Hello Panagiotis,

Thank you for the indicator! But when I tried use it from cBot like below, I got a run-time error: 

26/10/2020 07:00:00.210 | Crashed in OnStart with NullReferenceException: Object reference not set to an instance of an object.

26/10/2020 07:00:00.210 | CBot instance [Test, XAUUSD, m1] crashed with error "Crashed in OnStart with NullReferenceException: Object reference not set to an instance of an object."

---

 private MovingAverage _emaSignal;
 private NewIndicator7 _emaDiff;

 protected override void OnStart()
 {
      _emaSignal = Indicators.MovingAverage(_emaDiff.Result, 9, MovingAverageType.Exponential);
 }

---

What might be wrong in here?

Thank you gain in advance.


@ys2310

ys2310
11 Oct 2022, 13:25

RE:

I just sent it as an attachment to you from my gmail .

Please take a look at it and let me know!

Thank you again,

y

Spotware said:

Dear trader,

Send it to us at community@ctrader.com

Best regards,

cTrader Team

 


@ys2310

ys2310
11 Oct 2022, 12:14 ( Updated at: 11 Oct 2022, 12:15 )

RE:

Yes, not a problem. It's 17.2 MB big in size. How do you want me to share it with you?

Spotware said:

Dear trader,

Can you share the file with us so that we can check it?

Best regards,

cTrader Team

 


@ys2310

ys2310
11 Mar 2022, 05:49

RE: RE:

Hi amusleh,

 

I'm trying the following code and the index is -1

DateTime dt = Server.Time.AddMinutes(-128160);
int index = MarketData.GetBars(TimeFrame.Minute).OpenTimes.GetIndexByTime(dt);
Print("{0} {1}", index, MarketData.GetBars(TimeFrame.Minute).ClosePrices[index]);

if I instead use the code below the index has a value.

DateTime dt = Server.Time.AddMinutes(-1);
int index = MarketData.GetBars(TimeFrame.Minute).OpenTimes.GetIndexByTime(dt);
Print("{0} {1}", index, MarketData.GetBars(TimeFrame.Minute).ClosePrices[index]);

Is this because I'm referring way back in the past and there is no data with it?

How can I work around this problem? I want to get a correct value with the specified date and time.

Best  regards,

 


@ys2310

ys2310
14 Feb 2022, 12:05

The following code returns index of two different time stamp. The two index show identical number. Why is this?

index1, index2 are supposed to be different numbers, no?

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.None)]
    public class NewcBot : Robot
    {
        [Parameter(DefaultValue = 0.0)]
        public double Parameter { get; set; }

        protected override void OnStart()
        {
            // Put your initialization logic here
            var series5 = MarketData.GetBars(TimeFrame.Minute);
            long index1 = series5.OpenTimes.GetIndexByTime(DateTime.Parse("2022-02-14 18:50:00"));
            long index2 = series5.OpenTimes.GetIndexByTime(DateTime.Parse("2022-02-14 18:54:15"));
            Print("{0} {1}", index1, index2);
        }        
    }
}


@ys2310

ys2310
12 Feb 2022, 00:38

RE:

Thank you for the code, it seems bar.OpenTime creates identical results and I know this.

Discrepancies happen when I use MarketData.GetBars(TimeFrame.Minute, "SP") as a second symbol for data feed.

Can you also please try this on your side and check the difference?

Best regards,

 


@ys2310

ys2310
10 Feb 2022, 09:27

RE: RE: RE: RE:

Hello amusleh

I'm seeing this with one minute bar as,

MarketData.GetBars(TimeFrame.Minute, Symbol.Name)

Best regards,


@ys2310

ys2310
10 Feb 2022, 01:37

RE: RE:

I'm seeing this data discrepancies with broker called Axiory. For example, the date between 2022/Feb/06 to 2022/Feb/09.

I can see a bit large differences with symbols like SP, CL, and a bit more small differences with EURUSD, USDJPY. 

Best regards, 

 


@ys2310

ys2310
09 Feb 2022, 09:06

CADJPY, GBPJPY data seems exactly the same between backtesting and Live data.

but SP, CL and EURUSD, volatile symbols seem different in decimal between backtesting and Live data.

Can you confirm this on your side? I see difference on my end.

Best regards,


@ys2310

ys2310
09 Feb 2022, 00:52

Hello amusleh, LoadMoreHistory method solved my problem.

though, I see there are small discrepancies in data obtained from backtesting and data obtained from Live.

Is there any method for this problem? backtesing results are different from Live results because of this data gap.

Best regards,

 


@ys2310

ys2310
03 Jan 2022, 09:13 ( Updated at: 21 Dec 2023, 09:22 )

RE:

ys2310 said:

In my first screen shot, why do I see 5, 5, 6, 6 instead of 4, 5, 6, 7?

The last number is the number of opened position. it 4, 4, 4, 4, 4, 6, 6, 4, 4

positions.Count increments by 2 and the same number appears multiple times instead of 

1, 2, 3, 4, 5... Am I misunderstanding anything here?

Hi,

I'm trying to count how many positions are open at each OnPositionsOpened() event inside of 

this OnPositionsOpened() function. the num_of_open_position variable increment like 1,1, 2,2, 

3, 3, 4, 4, 5, 5, 6, 6, instead of 1, 2, 3, 4, 5, 6. Anyone understands what's happening in this case? 

---

 private void OnPositionsOpened(PositionOpenedEventArgs args)
        {            
            int num_of_open_position = 0;
            foreach (var p in Positions)
                num_of_open_position++;

            var position = args.Position;
            Print("OnPositionOpened: {0} {1} {2} {3} {4}", position.Id, position.EntryTime, position.TradeType, position.Comment, num_of_open_position);
        }
        

 


@ys2310