Compilation error
Compilation error
08 Apr 2019, 05:07
Hello,
I have the following compilation error however everything looks fine to me...
The code is in the :
public class BACKTESTING_GOTTAGOFAST : Robot
{
}
brackets with other classes.
Thanks for your help.
Replies
a.fernandez.martinez
08 Apr 2019, 05:24
I just realised I used Symbol.Bid instead of exchangeSymbol.Bid.
I still have the 3 errors from Account and MarketData, that I can't use for some reason, do I need to pass them to the method instead of using it directly inside ?
@a.fernandez.martinez
PanagiotisCharalampous
10 Apr 2019, 16:03
Hi a.fernandez.martinez,
Can you please post the full cBot code in text, not as an image?
Best Regards,
Panagiotis
@PanagiotisCharalampous
a.fernandez.martinez
12 Apr 2019, 21:07
Here's the code :
using System; using System.Linq; using System.Text; using System.Collections.Generic; 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 BACKTESTING_GOTTAGOFAST : Robot { [Parameter("Range in seconds", DefaultValue = 3600, MinValue = 60, MaxValue = 86400)] public int range { get; set; } protected override void OnStart() { } protected override void OnTick() { } protected override void OnStop() { } ////////////////////////////////////////////////////////////////// /////////// CURRENCY /////////// public static class Currency { // ---------- Methods public static double ExchangeRate(string chartCurrencyPair) { string accountCurrency = Account.Currency; string chartCurrency = chartCurrencyPair.Substring(0, 3); if (accountCurrency != chartCurrency) { Symbol exchangeSymbol = MarketData.GetSymbol(accountCurrency + chartCurrency); if (exchangeSymbol != null) { return exchangeSymbol.Bid; } else { exchangeSymbol = MarketData.GetSymbol(chartCurrency + accountCurrency); return 1 / exchangeSymbol.Bid; } } else { return 1; } } } } }
@a.fernandez.martinez
PanagiotisCharalampous
14 Apr 2019, 13:31
Hi a.fernandez.martinez,
The reason you are getting the errors is that you are using Account and MarketData properties in a class where they do not exist. These properties exists only in classes inheriting from Robot. If you want to use them in Currency class you should pass them as parameters.
Best Regards,
Panagiotis
@PanagiotisCharalampous
a.fernandez.martinez
08 Apr 2019, 05:08 ( Updated at: 21 Dec 2023, 09:21 )
Here is the image it didn't upload for some reason :
@a.fernandez.martinez