Error CS1503

Created at 17 Jun 2024, 22:02
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!
SA

said.moridi

Joined 06.05.2024

Error CS1503
17 Jun 2024, 22:02


using System;
using System.Net.Http;
using System.Threading.Tasks;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using System.Collections.Generic;

namespace cAlgo
{
   [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
   public class PredictionIndicator : Indicator
   {
       private static readonly HttpClient client = new HttpClient();
       private const string ApiUrl = "http://xxx/api/data/5min";

       private List<MarketData> algo1Data = new List<MarketData>();
       private List<MarketData> algo2Data = new List<MarketData>();
       private List<MarketData> algo3Data = new List<MarketData>();

       private DateTime lastFetchTime;

       protected override void Initialize()
       {
           lastFetchTime = Bars.OpenTimes.LastValue;
           AddStaticData(); // Adding static data for testing
       }

       private void AddStaticData()
       {
           var staticTime = DateTime.UtcNow.AddMinutes(5);
           algo1Data.Add(new MarketData { OpenTime = staticTime, Close = 150m });
           algo2Data.Add(new MarketData { OpenTime = staticTime, Close = 152m });
           algo3Data.Add(new MarketData { OpenTime = staticTime, Close = 148m });
       }

       public override void Calculate(int index)
       {
           DrawDots();
       }

       private void DrawDots()
       {
           foreach (var data in algo1Data)
           {
               ChartObjects.DrawText($"algo1_{data.OpenTime}", "•", data.OpenTime, (double)data.Close, VerticalAlignment.Center, HorizontalAlignment.Center, Color.White);
           }
           foreach (var data in algo2Data)
           {
               ChartObjects.DrawText($"algo2_{data.OpenTime}", "•", data.OpenTime, (double)data.Close, VerticalAlignment.Center, HorizontalAlignment.Center, Color.White);
           }
           foreach (var data in algo3Data)
           {
               ChartObjects.DrawText($"algo3_{data.OpenTime}", "•", data.OpenTime, (double)data.Close, VerticalAlignment.Center, HorizontalAlignment.Center, Color.White);
           }
       }
   }

   public class MarketData
   {
       public DateTime OpenTime { get; set; }
       public decimal Close { get; set; }
   }
}
 


@said.moridi
Replies

PanagiotisCharalampous
18 Jun 2024, 05:28

Hi there,

Please provide some description of your problem.

Best regards,

Panagiotis


@PanagiotisCharalampous

said.moridi
18 Jun 2024, 10:02

RE: Error CS1503

PanagiotisCharalampous said: 

Hi, off course, sorry. 
I created this code to get data from my local api, show on the chart and connect the different values to a line.
The last error I keep getting is 
Error CS1503: argument 3: CannotUnloadAppDomainException convert from 'system.DataTime' to 'int'  
I tried everything :)


@said.moridi

PanagiotisCharalampous
18 Jun 2024, 10:35

RE: RE: Error CS1503

said.moridi said: 

PanagiotisCharalampous said: 

Hi, off course, sorry. 
I created this code to get data from my local api, show on the chart and connect the different values to a line.
The last error I keep getting is 
Error CS1503: argument 3: CannotUnloadAppDomainException convert from 'system.DataTime' to 'int'  
I tried everything :)

Hi Said,

The message is self explanatory. You cannot use a DateTime in the place of an int. Also you are using an obsolete method. Try something like the below instead

Chart.DrawText($"algo1_{data.OpenTime}", "•", data.OpenTime, (double)data.Close, Color.White);

Best regards,

Panagiotis


@PanagiotisCharalampous

said.moridi
18 Jun 2024, 11:29

RE: RE: RE: Error CS1503

Thank you!

PanagiotisCharalampous said: 

said.moridi said: 

PanagiotisCharalampous said: 

Hi, off course, sorry. 
I created this code to get data from my local api, show on the chart and connect the different values to a line.
The last error I keep getting is 
Error CS1503: argument 3: CannotUnloadAppDomainException convert from 'system.DataTime' to 'int'  
I tried everything :)

Hi Said,

The message is self explanatory. You cannot use a DateTime in the place of an int. Also you are using an obsolete method. Try something like the below instead

Chart.DrawText($"algo1_{data.OpenTime}", "•", data.OpenTime, (double)data.Close, Color.White);

Best regards,

Panagiotis

 


@said.moridi