Referencing an custom indicator - Could not load file or assembly

Created at 04 Sep 2016, 07:56
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!
AD

adheer

Joined 13.05.2014

Referencing an custom indicator - Could not load file or assembly
04 Sep 2016, 07:56


I am building a cBot which uses an indicator pzSupportResistance (in cFractals.algo). This pzSupportResistance internally uses another indicator ZigZag (in ZigZag.algo). I do not have the source code of either, I use the .algo files, so I am using the #reference directive.

In my code, I can initialize and use the ZigZag indicator without any issues. (I do not need the ZigZag indicator, but I tried to make sure dependencies are fine).

However, when I try to initialize the pzSupportResistance indicator, using the following statement :

_cf = Indicators.GetIndicator<pzSupportResistance>(6, 24); 

I get the following error :

Crashed in Initialize with FileNotFoundException: Could not load file or assembly 'ZigZag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

It does not crash, continues execution but obviously the _cf indicator is not initialized.

1) I have verified that both the indicator algo files exist in the Indicators folder.
2) I can successfully load the ZigZag indicator, so there is some issue with referencing in cFractals.algo of the ZigZag.algo file.
3) I have set the AccessRights to AccessRights.FullAccess, but still no luck.

I would appreciate if anyone can point out the cause of this issue ?

cBot code (bare bones);

//#reference: C:\Users\HP\Documents\cAlgo\Sources\Indicators\ZigZag.algo
//#reference: C:\Users\HP\Documents\cAlgo\Sources\Indicators\cFractals.algo

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.FullAccess)]
    public class MyBot : Robot
    {
        private ZigZag _zz = null;
        private pzSupportResistance _cf = null;
        protected override void OnStart()
        {
            Print("Initializing ZigZag ...");
            _zz = Indicators.GetIndicator<ZigZag>(12, 5, 3);  // INITIALIZES FINE
            Print("ZigZag initialized.");
            Print("ZigZag = {0}", _zz.Result.LastValue);  // RESULT IS CORRECT
            Print("Initializing pzSupportResistance ..."); 

            _cf = Indicators.GetIndicator<pzSupportResistance>(6, 24);  // CRASHES

            Print("pzSupportResistance initialized.");
            Print("pzSupportResistance Support = {0}", _cf.Support.LastValue);
        }

        protected override void OnTick()
        {
        }

        protected override void OnStop()
        {
        }
    }
}

 

Log Result :

 

04/08/2016 00:00:00.000 | Initializing ZigZag ...
04/08/2016 00:00:00.000 | ZigZag initialized.
04/08/2016 00:00:00.000 | ZigZag = 1.11407
04/08/2016 00:00:00.000 | Initializing pzSupportResistance ...
04/08/2016 00:00:00.000 | Crashed in Initialize with FileNotFoundException: Could not load file or assembly 'ZigZag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
04/08/2016 00:00:00.000 | pzSupportResistance initialized.

 


@adheer
Replies

brunoamancio.ti
07 Sep 2016, 06:49 ( Updated at: 21 Dec 2023, 09:20 )

Is the .algo file defined as Reference like this?

 


@brunoamancio.ti

adheer
07 Sep 2016, 08:54 ( Updated at: 21 Dec 2023, 09:20 )

RE:

brunoamancio.ti said:

Is the .algo file defined as Reference like this?

 


I have tried that, it does not help. 
In the Code Editor, I right-click, and select the Add Reference in the drop-down context menu. Next, I select the two algo files, ZigZag.algo and cFractals.algo.
What it actually does is add the following reference entries at the top of the code. 
 

//#reference: ..\Indicators\cFractals.algo
//#reference: ..\Indicators\ZigZag.algo

The only difference is that, the Add Reference step adds the references as relative path, whereas I had it as absolute paths. But it does not solve the problem. I still get the same error.


@adheer

adheer
07 Sep 2016, 09:27 ( Updated at: 21 Dec 2023, 09:20 )

When I try to add the references using the Manage References button, both the indicators are grayed-out in the list of indicators.

When I move the mouse over those two grayed-out indicators I see a message "This indicator cannot be referenced, because it doesn't contain Source Code."

Does it mean I cannot reference an indicator (.algo file) which does not have source code using the Manage References feature ?

 


@adheer