Missing method - cAlgo.API.Asset.Convert(cAlgo.API.Asset, Double)

Created at 10 Feb 2023, 00:08
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!
CT

ctid5752082

Joined 09.02.2023

Missing method - cAlgo.API.Asset.Convert(cAlgo.API.Asset, Double)
10 Feb 2023, 00:08


Good Morning,

I am trying to code some code, using

- 'cTrader 4.5.9'

- '.NET6.0'

- 'VS2022'

 

The code compiles.  See note after 'code snippet'.

 

 The code I am using is -


Asset baseAssetForNewOrder = Assets.GetAsset("GBP");
Asset quoteAssetForNewOrder = Assets.GetAsset("JPY");
double newOrderVolume = baseAssetForNewOrder.Convert(quoteAssetForNewOrder, 1000.00);
ExecuteMarketOrder(TradeType.Buy, SymbolName, newOrderVolume);
Print($"New order has been executed with {newOrderVolume} as its volume");

This is sourced from - https://help.ctrader.com/ctrader-automate/guides/currency-conversion/?utm_source=ctrader_com&utm_medium=news&utm_campaign=desktop_4_6

 

Note - while I can see from the URL that it is referring to 'desktop_4.6', the code does compile.

If this is the issue, shouldn't the code fail to compile?

 

Regardless, there is a message in the 'Log' section of the 'cTrader Desktop' application stating -

"09/02/2023 21:48:20.601 | CBot instance [whatever, EURUSD, m1] crashed with error "Crashed in OnStart with MissingMethodException: Method not found: 'Double cAlgo.API.Asset.Convert(cAlgo.API.Asset, Double)'."

 

As stated above, the code compiles, but why would the code compile if the "Method is missing" (from the 'API library (.dll)')?

The 'auto suggest' in 'VS2022' also has the method(s) listed.

If the method(s) are non existent in the 'API library (.dll)', resulting in the 'Method Not Found' error, then why are they in 'auto suggest'?

Back to the first point, why does it compile?

It should fail to compile, if the method is non existent.

 

What is the issue here?

 

Thank you for your time,

 

 


@ctid5752082
Replies

ctid5752082
10 Feb 2023, 13:34 ( Updated at: 10 Feb 2023, 13:37 )

PanagiotisChar said:

Hi there,

Convert method is only available in 4.6.

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

Thank you for your reply.

 

I understand the answer.

 

However -

- why does it compile?

- why does 'VS2022' 'autosuggest' have the method listed?

 

 

For example -

If I was to code 'this.whatever();' (where there is NO 'user defined' method called 'whatever'), there would be a compile error stating -

 


Error    CS1061    'projectExample' does not contain a definition for 'whatever' and no accessible extension method 'whatever' accepting a first argument of type 'projectExample' could be found (are you missing a using directive or an assembly reference?)

 

 

This is the error 'VS2022' would produce.

Conversely, the 'auto suggest' also has no idea of any method for 'whatever()'.

 

 

However (back to 'Double cAlgo.API.Asset.Convert(cAlgo.API.Asset, Double)')-

- why does it compile?

- why does 'VS2022' 'autosuggest' have the method listed?

 

 

Why does 'cTrader 4.5.9' know about 'Double cAlgo.API.Asset.Convert(cAlgo.API.Asset, Double)', if it is not exist until 'cTrader 4.6'?

That doesn't make any sense.

 

 

I accept the answer that 'Convert method is only available in 4.6.'.  That is fine.

 

 

However -

- why does it compile?

- why does 'VS2022' 'autosuggest' have the method listed?

 

 

Thank you for your time,

 


@ctid5752082

ctid5752082
10 Feb 2023, 14:58

An update -

I installed the latest 'cTrader' 'Desktop' (4.6.3.13401), direct from the ctrader.com website.

I previously was using my broker 'cTrader' download (4.5.9).  I didn't realize that I could use the 'non broker' 'cTrader'.

 

They always seem to be a couple of 'minor version' numbers back from the version numbering from 'cTrader' directly.  (About 2 weeks behind?).

 

Because this solution worked, and the issue originally discussed in this thread is dealt with.

Otherwise, I have to wait for my broker to catch up with there releases.

 

Can you confirm that there is no issues with using the 'cTrader' 'Desktop' platform downloaded from ctrader.com directly, instead of using the download available from my broker website?

Can you confirm there is no issue with accounts, and trading?

 

Thank you for your time,

 


@ctid5752082

PanagiotisChar
10 Feb 2023, 16:07

Hi there,

- why does it compile?

- why does 'VS2022' 'autosuggest' have the method listed?

Because you are using a newer API in an older version. So the interface is there but the implementation is missing from the application.

Can you confirm that there is no issues with using the 'cTrader' 'Desktop' platform downloaded from ctrader.com directly, instead of using the download available from my broker website?

Can you confirm there is no issue with accounts, and trading?

I can't confirm anything. I am just a user like you.

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us


@PanagiotisChar