PanagiotisCharalampous's avatar
PanagiotisCharalampous
26 follower(s) 0 following 1006 subscription(s)
Replies

PanagiotisCharalampous
04 Sep 2024, 13:30

Hi Nick,

There are no limits to how many symbols you can subscribe. One thing that could be happening is that you do not read the incoming messages fast enough causing a buffer overflow on the server which eventually drops your connection. If you cannot figure it out yourself, contact the Open API support on Telegram so that they can check what is happening with your connection

https://t.me/ctrader_open_api_support

Best regards,

Panagiotis

 


@PanagiotisCharalampous

PanagiotisCharalampous
04 Sep 2024, 05:56

Hi there,

We do not have such plans at the moment.

Best regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
04 Sep 2024, 05:55

Hi there,

cTrader is just a platform and Spotware is a technology provider. We are not brokers, therefore we do not offer brokerage services to traders. 

Best regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
04 Sep 2024, 05:55

Hi there,

cTrader is just a platform and Spotware is a technology provider. We are not brokers, therefore we do not offer brokerage services to traders. 

Best regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
04 Sep 2024, 05:55

RE: RE: RE: RE: Algo Compiler v8 for Cloud?

elia.morling said: 

Thanks, yes I found this tab.

The code below works perfectly locally. All it does it connect to a websocket, and prints OnStart…

When I run this in the cloud I get no errors, and no prints either. Should I not see a Print statement with this?

using System;using cAlgo.API;using cAlgo.API.Collections;using cAlgo.API.Indicators;using cAlgo.API.Internals;namespace cAlgo.Robots{    [Robot(AccessRights = AccessRights.None, AddIndicators = true)]    public class AlgoBot2 : Robot    {                // Defining the necessary WebSocketClientOptions        private static WebSocketClientOptions _webSocketClientOptions = new WebSocketClientOptions         {            KeepAliveInterval = new TimeSpan(0, 1, 30),            UseDefaultCredentials = true,        };                // Initialising the WebSocketClient        private WebSocketClient _webSocketClient = new WebSocketClient(_webSocketClientOptions);                // Defining the target URI where the AI service is available        private readonly Uri _targetUri = new Uri("wss://custom-subdomain.loca.lt");         protected override void OnStart()        {            Print("OnStart...");                        _webSocketClient.Connect(_targetUri);                        // Serialize JSON data            string jsonMessage = System.Text.Json.JsonSerializer.Serialize(new { hello = "world" });            _webSocketClient.Send(jsonMessage);                        _webSocketClient.TextReceived += webSocketClient_TextReceived;        }        protected override void OnBarClosed()        {            // Attaining data for the current bar that has just closed            // and the preceding bar            var currentBar = Bars.LastBar;            var previousBar = Bars.Last(Bars.Count - 2);                        // Creating a prompt for market analysis based on bar data            string marketPrompt = @$"            For the current bar, the high, low, open, and close were the following:            {currentBar.High}, {currentBar.Low}, {currentBar.Open}, {currentBar.Close}. For the previous bar,            these values were {previousBar.High}, {previousBar.Low}, {previousBar.Open}, {previousBar.Close}.            Make predictions about the future.            ";                        // Sending the new prompt to the AI service            _webSocketClient.Send(marketPrompt);        }        protected void webSocketClient_TextReceived(WebSocketClientTextReceivedEventArgs obj)        {            Print("Received message");        }        protected override void OnStop()        {            // Disposing of the WebSocketClient to avoid memory leaks            _webSocketClient.Close(WebSocketClientCloseStatus.NormalClosure);        }    }}

Can you share a screenshot of the cBot log as well?


@PanagiotisCharalampous

PanagiotisCharalampous
04 Sep 2024, 05:52

Hi there,

There is no such feature unfortunately.

Best regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
04 Sep 2024, 05:26

RE: RE: RE: RE: RE: RE: RE: RE: RE: RE: RE: RE: Backtesting - Incorrect TP / SL calculation

zytotoxiziteat said: 

zytotoxiziteat said: 

zytotoxiziteat said: 

PanagiotisCharalampous said: 

zytotoxiziteat said: 

PanagiotisCharalampous said: 

zytotoxiziteat said: 

PanagiotisCharalampous said: 

zytotoxiziteat said: 

zytotoxiziteat said: 

zytotoxiziteat said: 

PanagiotisCharalampous said: 

Hi there,

Please share your cBot code and make sure you are using tick data for your backtests.

Best regards,

Panagiotis

using System;using System.Collections.Generic;using cAlgo.API;using cAlgo.API.Indicators;using cAlgo.API.Internals;namespace cAlgo.Robots{    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]    public class TradingBot : Robot    {        [Parameter("Risk Percentage", DefaultValue = 1, MinValue = 0.1, MaxValue = 10)]        public double RiskPercentage { get; set; }        [Parameter("Stop Loss (Pips)", DefaultValue = 40, MinValue = 0, MaxValue = 100)]        public double StopLossPips { get; set; }        [Parameter("Take Profit (Pips)", DefaultValue = 20, MinValue = 0, MaxValue = 200)]        public double TakeProfitPips { get; set; }        private AI_101.ML101.ModelInput _modelInput;        private double _lastPrediction;        protected override void OnStart()        {            _modelInput = new AI_101.ML101.ModelInput();        }        protected override void OnTick()        {            // Ensure only one open position per currency pair            if (Positions.FindAll("ML Prediction", Symbol.Name).Length > 0)                return;            // Update model input with the latest close price            _modelInput.ClosePrice = (float)Symbol.Bid;  // Use Symbol.Bid instead of Symbol.LastTick.Bid            // Get prediction            var prediction = AI_101.ML101.Predict(_modelInput);            // Calculate the predicted price change            double predictedChange = prediction.ClosePrice[0] - _modelInput.ClosePrice;            // Determine if we should open a position            if (Math.Abs(predictedChange) > Symbol.PipSize)            {                if (predictedChange > 0 && _lastPrediction <= 0)                {                    OpenPosition(TradeType.Buy);                }                else if (predictedChange < 0 && _lastPrediction >= 0)                {                    OpenPosition(TradeType.Sell);                }            }            _lastPrediction = predictedChange;        }        private void OpenPosition(TradeType tradeType)        {            // Calculate position size based on risk            double riskAmount = Account.Balance * (RiskPercentage / 100);            double volumeInUnits = riskAmount / (StopLossPips * Symbol.PipValue);            // Ensure volume is within acceptable range and increments            volumeInUnits = Symbol.NormalizeVolumeInUnits(volumeInUnits, RoundingMode.ToNearest);            // Check if the volume is valid            if (volumeInUnits < Symbol.VolumeInUnitsMin || volumeInUnits > Symbol.VolumeInUnitsMax)            {                Print("Volume is out of range: " + volumeInUnits);                return;            }            // Open the position            ExecuteMarketOrder(tradeType, Symbol.Name, volumeInUnits, "ML Prediction", StopLossPips, TakeProfitPips);        }    }}

My thought was:

Since I collected only m5 candle data for my Machine learning module I changed the “Data” in settings to “m5 bars from server” for backtesting 

and I was considering to change “protected override void OnTick()” to "protected override void OnBar()".
 

Is that wrong?

What is the best solution?

Thank you

Hi there, 

If you are using fixed SL and TP, you need to use tick data to ensure accurate results in backtesting.

Best regards,

Panagiotis

Okay, my cbot code uses

protected override void OnTick()

I still get wrong TP.

You need to use tick data on your backtesting settings. OnTick() is irrelevant.

 

Where does the option “m5 bars from server” come from?

 

 I thought the system provided the best possible set-up because of my csv file, which contains only m5 bars data. 

 

I don't understand what you mean. It's just an option in a dropdown list

My friend,

I created a csv file with m5 bars only to train my module. I thought that is why I the option “M5” is available.

Can you please explain why in any of the options in Backtesting drop-down list is not triggering my predefined TP or SL . 

What is the point of predefining it?

I thought the Backtesting process should prepare for the real environment. But when there are options which are not correctly executed by the system makes no sense to me.

 

The options have nothing to do with the data you used to generate the model. The backtesting module has no clue what your cBot is doing. Those options are there to choose the data source to be used for the backtesting. If you don't use tick data but you use SP and TP at specific price levels, your execution will be inaccurate, since m5 bars data source only uses open prices for the execution 


@PanagiotisCharalampous

PanagiotisCharalampous
04 Sep 2024, 05:20

RE: RE: RE: RE: Placing Stop Order - FAILED with error "TechnicalError"

sebastien.t said: 

My broker is ICMarkets and here is the simple code, I just put an order. It could be anything a Market order or a stop order, i have always the Failure message.

 

using cAlgo.API;

using cAlgo.API.Internals;

using cAlgo.Indicators;

using System;


 

namespace cAlgo.Robots

{

[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]

public class StopLimitOrdersAt915 : Robot

{

private double _high15;

private double _low15;

 

[Parameter("Volume (in units)", DefaultValue = 10)]

public int VolumeInUnits { get; set; }

 

[Parameter("Offset (points)", DefaultValue = 20)]

public double OffsetInPoints { get; set; }

 

[Parameter("Take Profit (points)", DefaultValue = 50)]

public double TakeProfitInPoints { get; set; }


protected override void OnStart()

{

var closedBar = Bars[1];

_high15 = closedBar.High;

_low15 = closedBar.Low;
 

double sellStopLoss = OffsetInPoints / Symbol.PipSize;
 

double takeProfit = TakeProfitInPoints / Symbol.PipSize;

double StopLoss= (_high15-_low15)/Symbol.PipSize

 

PlaceStopOrder(TradeType.Sell, SymbolName, VolumeInUnits, _low15, "Sell Stop Limit Order", StopLoss, takeProfit);
 

}


}

}

Please let us know the symbol as well. I tried this on EURUSD and works fine


@PanagiotisCharalampous

PanagiotisCharalampous
04 Sep 2024, 05:13

RE: RE: Very simple issue

tuuguu177 said: 

PanagiotisCharalampous said: 

Hi there,

No this is not possible at the moment.

Best regards,

Panagiotis

Hello

How to make line into transparent at coding?

Hi there,

You need to set make your line's color transparent by setting the alpha to 0. See below

var color = Color.FromArgb(0,255,0,0); 

Best regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
03 Sep 2024, 11:55

Hi again,

Thank you for reporting this issue. Unfortunately we were not able to reproduce this behavior. Could you please send us some troubleshooting information the next time this happens? Please paste a link to this discussion inside the text box before you submit it.

Best regards,

Panagiotis


 


@PanagiotisCharalampous

PanagiotisCharalampous
03 Sep 2024, 11:48

RE: RE: badvolumn

chenshy27 said: 

PanagiotisCharalampous said: 

Hi there,

Please share your cBot code so that we can understand what it is doing.

Best regards,

Panagiotis

using cAlgo.API;
using cAlgo.API.Internals;
using System.Linq;

namespace cAlgo.Robots
{
   [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
   public class GridTradingBot : Robot
   {
       private const double EurUsdTakeProfit = 2.5;  // EUR/USD 盈利2.5美金时平仓
       private const double UsdChfTakeProfit = 2.27; // USD/CHF 盈利2.27美金时平仓
       private const double EurUsdLossThreshold = 2.5;   // EUR/USD 亏损2.5美金时加仓
       private const double UsdChfLossThreshold = 2.27;  // USD/CHF 亏损2.27美金时加仓
       private const double LotSize = 0.01;          // 初始手数
       private const double MaxLotSize = 0.1;        // 最大手数

       private Symbol _eurUsd;
       private Symbol _usdChf;

       protected override void OnStart()
       {
           // 获取符号信息
           _eurUsd = Symbols.GetSymbol("EURUSD");
           _usdChf = Symbols.GetSymbol("USDCHF");

           // 启动时开仓 EUR/USD 和 USD/CHF 多单
           OpenPosition(_eurUsd, TradeType.Buy);
           OpenPosition(_usdChf, TradeType.Buy);
       }

       protected override void OnTick()
       {
           ManagePositions(_eurUsd, EurUsdTakeProfit, EurUsdLossThreshold);
           ManagePositions(_usdChf, UsdChfTakeProfit, UsdChfLossThreshold);
       }

       private void OpenPosition(Symbol symbol, TradeType tradeType, double volume = LotSize)
       {
           ExecuteMarketOrder(tradeType, symbol.Name, volume, "GridTradingBot");
       }

       private void ManagePositions(Symbol symbol, double takeProfit, double lossThreshold)
       {
           var positions = Positions.FindAll("GridTradingBot", symbol.Name);

           foreach (var position in positions)
           {
               // 如果单个仓位的利润达到设定的盈利目标,平仓并重新开仓
               if (position.NetProfit >= takeProfit)
               {
                   ClosePosition(position);
                   OpenPosition(symbol, position.TradeType, LotSize);
               }
           }

           // 如果总亏损超过设定的亏损阈值且手数未达到上限,加仓
           double totalVolume = positions.Sum(p => p.VolumeInUnits);
           double totalProfit = positions.Sum(p => p.NetProfit);

           if (totalProfit <= -lossThreshold && totalVolume < MaxLotSize * 100000)
           {
               OpenPosition(symbol, TradeType.Buy, LotSize);
           }
       }
   }
}

The volume in your order method should be in units not in lots. Use QuantityToVolume() method to convert your lots to units


@PanagiotisCharalampous

PanagiotisCharalampous
03 Sep 2024, 11:44

RE: RE: Algo Compiler v8 for Cloud?

elia.morling said: 

PanagiotisCharalampous said: 

Hi there,

Can you describe your problem using screenshots so that we can understand what you are looking at?

Best regards,

Panagiotis

Sorry, seems like compiled v8 works in Cloud. Issue is rather with the code itself, which may run locally but not in Cloud.

A few follow up quetions:
1. Is there sample of a script which can run in Cloud and able to call external service (assuming it needs to be web socket and port 25345)?
2. How to debug cbots in cloud? I am not seeing any errors whatsoever?

Hi there,

Unfortunately I do not have an example script for you. You can see your cloud instance's log in the Instance Information tab 


@PanagiotisCharalampous

PanagiotisCharalampous
03 Sep 2024, 09:33

RE: RE: RE: RE: RE: RE: When a bot was "unexpectedly terminated", cTrader shows the bot as still running

firemyst said: 

PanagiotisCharalampous said: 

 

Hi firemyst,

It seems we have not received this email. Can you please resend it to community@ctrader.com?

Best regards,

Panagiotis

Resent as requested. PLease let me know if you received it. If not, I might have to send separate individual emails with all the info as I wonder if your email system might be blocking it or sending it to spam for some reason.

Hi firemyst,

Try my personal one as well pcharalampous@spotware.com

Best regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
03 Sep 2024, 08:58

Hi there,

Please share your cBot code so that we can understand what it is doing.

Best regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
03 Sep 2024, 08:55

RE: RE: RE: RE: When a bot was "unexpectedly terminated", cTrader shows the bot as still running

firemyst said: 

PanagiotisCharalampous said: 

firemyst said: 

PanagiotisCharalampous said: 

Hi firemyst,

Can we have the cBot that reproduces this problem?

Best regards,

Panagiotis

Any updates on this?

  1. I provided a private video link on YouTube demonstrating the issue;
  2. I provided access details to my VPS so the team can see it first hand.
  3. I provided .algo file and source code that reproduces the issue on the VPS
  4. I've provided plenty of details in this thread

Thank you.

Hi firemyst,

We were not able to reproduce this. You said that you will provide access to your VPS but we have not received anything yet.

Best regards,

Panagiotis

I sent the email last week:

Hi firemyst,

It seems we have not received this email. Can you please resend it to community@ctrader.com?

Best regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
03 Sep 2024, 08:50

RE: RE: Placing Stop Order - FAILED with error "TechnicalError"

sebastien.t said: 

Hello,

 

thank you for your answer.

 

I modified the code to respect the Ticksize. I still get an error

Trade | → Placing Stop Order to Sell 10 DE30 (Price: 18772.6, SL: 5700, TP: 5000) FAILED with error "TechnicalError"

 

I also tried to use the Pipsize :

But I have the same issue Trade | → Placing Stop Order to Sell 10 DE30 (Price: 18772.6, SL: 570, TP: 500) FAILED with error "TechnicalError"

 

Thank you for your help.

 

PanagiotisCharalampous said: 

Hi there,

You are setting the SL and TP is absolute price. You need to set them in pips.

Best regards,

Panagiotis

 

Please share the complete cBot code, your cBot parameters and backtesting settings, as well as your broker, so that we can reproduce this on backtesting.


@PanagiotisCharalampous

PanagiotisCharalampous
03 Sep 2024, 05:58

RE: RE: When a bot was "unexpectedly terminated", cTrader shows the bot as still running

firemyst said: 

PanagiotisCharalampous said: 

Hi firemyst,

Can we have the cBot that reproduces this problem?

Best regards,

Panagiotis

Any updates on this?

  1. I provided a private video link on YouTube demonstrating the issue;
  2. I provided access details to my VPS so the team can see it first hand.
  3. I provided .algo file and source code that reproduces the issue on the VPS
  4. I've provided plenty of details in this thread

Thank you.

Hi firemyst,

We were not able to reproduce this. You said that you will provide access to your VPS but we have not received anything yet.

Best regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
03 Sep 2024, 05:56

Hi there,

Can you describe your problem using screenshots so that we can understand what you are looking at?

Best regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
03 Sep 2024, 05:55

Hi there,

You need to provide some more information. What do you mean when you say “my screen is totally freeze”? Can you share screenshots/videos so that we can see what happens?

Best regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
03 Sep 2024, 05:50

Hi there,

You are setting the SL and TP is absolute price. You need to set them in pips.

Best regards,

Panagiotis


@PanagiotisCharalampous