Huge Ram consumption with Range Bars charts

cTrader
1
Votes
exane since: 12 Jun 2019; 
 02 Jul 2019, 21:23
Huge Ram consumption with Range Bars charts

Hi,
I'am trading with cTrader range bars charts while having some alerts on it. I set alerts on many range interevals, and this costs me a lot of ram. While platform is working for some time and RangeBar chart is open cTrader consumes about 90Mb of ram for each chart. This is annoying problem even for computers with lot of ram.
If you could restrain this process it would be perfect. Please try juggle with ram alocating and combine it with standard disk memory.

Regards, Pete

Panagiotis Charalampous's avatar
Panagiotis Charalampous since: 13 Jan 2017; 
 03 Jul 2019, 09:40

Hi exane,

Thanks for reporting this issue. Can you please send us some troubleshooting information the next time this happens? To do so, please press Ctrl+Alt+Shift+T, paste the link to this discussion in the text box and click Submit.

Best Regards,

Panagiotis

Head of Community Management at cTrader
alexsanramon since: 21 Feb 2019; 
 05 Jul 2019, 04:01

I do not get this issue with regular time based charts. How is the data being processed in renko and range bar charts? Does the broker provides the data then our machine converts it to bars in ctrader? If so there is an issue right there. 

Please look into this since most traders use cTrader because of its supremacy of the renko and range bar charts.

Panagiotis Charalampous's avatar
Panagiotis Charalampous since: 13 Jan 2017; 
 05 Jul 2019, 09:27

Hi alexsanramon,

Can you send us troubleshooting information when this happens. Follow the instructions highlighted above.

Best Regards,

Panagiotis

Head of Community Management at cTrader
alexsanramon since: 21 Feb 2019; 
 09 Jul 2019, 02:20

Ok. So after a very long agonizing monitoring for the sake of troubleshooting, here's what happens. I turned on my bot about 10pm Singapore time, all 28 pairs on range bars. At the time I opened the cbot I got atleast one order filled after about 15 minutes when I came back after a shower. And when I woke up at about 6am Singapore time, all of my cbot have nothing on the charts. You can tell that it is was dead for a while because no orders were made except the earlier order. You can also tell because the bid and ask line is gone. I have to reload or refresh the charts to get it going.

There is really a big issue here. I have other renko cbots running in the background ( 28x2 pairs with 2 different brokers) and none have issue.

Please fix this issue.

Thank you kind developers.

Alexis.

Panagiotis Charalampous's avatar
Panagiotis Charalampous since: 13 Jan 2017; 
 09 Jul 2019, 09:42

Hi Alexis,

Can you share the cBot code with us?

Best Regards,

Panagiotis

Head of Community Management at cTrader
alexsanramon since: 21 Feb 2019; 
 09 Jul 2019, 10:35
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.None)]
    public class RelativeMomentum : Robot
    {

        [Parameter("Instance", DefaultValue = "001")]
        public string InstanceName { get; set; }
        [Parameter("Lot Size", DefaultValue = 0.01)]
        public double LotSize { get; set; }
        [Parameter("BandDistance", DefaultValue = 2.4)]
        public double Band { get; set; }        
        
        
        [Parameter("Include Trailing Stop", DefaultValue = false)]
        public bool IncludeTrailingStop { get; set; }

        [Parameter("Trailing Stop Trigger (pips)", DefaultValue = 20)]
        public int TrailingStopTrigger { get; set; }

        [Parameter("Trailing Stop Step (pips)", DefaultValue = 10)]
        public int TrailingStopStep { get; set; }
        [Parameter("Take Profit (Pips)", DefaultValue = 6, MinValue = 1, Step = 1)]
        public int TakeProfit { get; set; }
        [Parameter("Stop Loss (Pips)", DefaultValue = 150, MinValue = 1, Step = 1)]
        public int StopLoss { get; set; }
        private RelativeStrengthIndex RSSI;
        private MomentumOscillator Mom;

        protected override void OnStart()
        {


            RSSI = Indicators.RelativeStrengthIndex(MarketSeries.Close, 14);
            Mom = Indicators.MomentumOscillator(MarketSeries.Close, 14);

        }
        protected override void OnTick()
        {

        }
        protected override void OnBar()
        {
            ManagePositions();
            SetTrailingStop();
        }
        protected override void OnStop()
        {
            // unused
        }
        private void ManagePositions()
        {

            if ((RSSI.Result.LastValue > 50) & (Mom.Result.LastValue > 100) & (Positions.Count() == 0))
            {


                if (!IsPositionOpenByType(TradeType.Buy))
                {
                    OpenPosition(TradeType.Buy);
                }

                ClosePosition(TradeType.Sell);
            }

            if ((RSSI.Result.LastValue < 50) & (Mom.Result.LastValue < 100) & (Positions.Count() == 0))
            {


                if (!IsPositionOpenByType(TradeType.Sell))
                {
                    OpenPosition(TradeType.Sell);
                }

                ClosePosition(TradeType.Buy);
            }

        }
        private void SetTrailingStop()
        {
            var sellPositions = Positions.FindAll(InstanceName, Symbol, TradeType.Sell);

            foreach (Position position in sellPositions)
            {
                double distance = position.EntryPrice - Symbol.Ask;

                if (distance < TrailingStopTrigger * Symbol.PipSize)
                    continue;

                double newStopLossPrice = Symbol.Ask + TrailingStopStep * Symbol.PipSize;

                if (position.StopLoss == null || newStopLossPrice < position.StopLoss)
                {
                    ModifyPosition(position, newStopLossPrice, position.TakeProfit);
                }
            }

            var buyPositions = Positions.FindAll(InstanceName, Symbol, TradeType.Buy);

            foreach (Position position in buyPositions)
            {
                double distance = Symbol.Bid - position.EntryPrice;

                if (distance < TrailingStopTrigger * Symbol.PipSize)
                    continue;

                double newStopLossPrice = Symbol.Bid - TrailingStopStep * Symbol.PipSize;
                if (position.StopLoss == null || newStopLossPrice > position.StopLoss)
                {
                    ModifyPosition(position, newStopLossPrice, position.TakeProfit);
                }
            }
        }

        private void OpenPosition(TradeType type)
        {
            
            long volume = Symbol.QuantityToVolume(LotSize);

            
            ExecuteMarketOrder(type, this.Symbol, volume, InstanceName, StopLoss, TakeProfit);
        }

        private void ClosePosition(TradeType type)
        {
            var p = Positions.Find(InstanceName, this.Symbol, type);

            if (p != null)
            {
                ClosePosition(p);
            }
        }
        private bool IsPositionOpenByType(TradeType type)
        {
            var p = Positions.FindAll(InstanceName, Symbol, type);

            if (p.Count() >= 1)
            {
                return true;
            }

            return false;
        }


    }
}
exane since: 12 Jun 2019; 
 09 Jul 2019, 15:10

Also I have noticed that after weekend, when market is opening, and I was having opened platform through while wknd, ram is increasing drastically and the vps crashes. Vps provider told me that ctrader coused crash with peak ram usage. Noticed same thing on home pc with 16 gb ram and ctrader usage about 1,8 gb of ram. 

Panagiotis Charalampous's avatar
Panagiotis Charalampous since: 13 Jan 2017; 
 09 Jul 2019, 15:12

Hi exane,

Did you send the troubleshooting information we requested?

Best Regards,

Panagiotis

Head of Community Management at cTrader
alexsanramon since: 21 Feb 2019; 
 10 Jul 2019, 02:51

I just replicated it now. What happened is there a was a very quick internet service interruption. All my renko cbots works as if nothing happened. But range bars, approximately, 25% of it works. And because my cbot works onBar, some of them triggered an order.

So there you go. The issue is with the range bars not refreshing. This is very dangerous also if you are using onBar.