Huge Ram consumption with Range Bars charts

Created at 02 Jul 2019, 21:23
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!
EX

exane

Joined 12.06.2019

Huge Ram consumption with Range Bars charts
02 Jul 2019, 21:23


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


cTrader
@exane
Replies

PanagiotisCharalampous
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


@PanagiotisCharalampous

alexsanramon
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.


@alexsanramon

PanagiotisCharalampous
05 Jul 2019, 09:27

Hi alexsanramon,

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

Best Regards,

Panagiotis


@PanagiotisCharalampous

alexsanramon
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.


@alexsanramon

PanagiotisCharalampous
09 Jul 2019, 09:42

Hi Alexis,

Can you share the cBot code with us?

Best Regards,

Panagiotis


@PanagiotisCharalampous

alexsanramon
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;
        }


    }
}

 


@alexsanramon

exane
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. 


@exane

PanagiotisCharalampous
09 Jul 2019, 15:12

Hi exane,

Did you send the troubleshooting information we requested?

Best Regards,

Panagiotis


@PanagiotisCharalampous

alexsanramon
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.


@alexsanramon

exane
10 Jul 2019, 07:04

RE:

Panagiotis Charalampous said:

Hi exane,

Did you send the troubleshooting information we requested?

Best Regards,

Panagiotis

Wwhat is this thread for? I cant imagine troubleshoot after platform crash. Here I can paste screen shoots and continue problem specyfication. 


@exane

PanagiotisCharalampous
10 Jul 2019, 09:10

Hi exane, 

We need you to send us troubleshooting information when the memory consumption becomes excessive, as per your original post, not after the VPS crash.

Best Regards,

Panagiotis


@PanagiotisCharalampous

exane
10 Jul 2019, 23:50 ( Updated at: 21 Dec 2023, 09:21 )

As you wish, next troubleshoot sent. If you want better problem description via cTrader ctrlaltshiftT, then make the troubleshoot msg longer then 100 charaters...
As well screen shot here, 3 days of working platform, 5 range bars, 650mb ram memory consumption still growing. 
 


@exane

alexsanramon
11 Jul 2019, 01:49

Look. I have entirely gave up on range bars. I went back to renko again. There is really an issue here. I do not know if the update has anything to do with this or what.


@alexsanramon

PanagiotisCharalampous
11 Jul 2019, 10:02 ( Updated at: 21 Dec 2023, 09:21 )

RE:

exane said:

As you wish, next troubleshoot sent. If you want better problem description via cTrader ctrlaltshiftT, then make the troubleshoot msg longer then 100 charaters...
As well screen shot here, 3 days of working platform, 5 range bars, 650mb ram memory consumption still growing. 
 

Hi exane,

Thanks. 650 mb cannot be considered excessive memory usage. But we will double check.

Best Regards,

Panagiotis


@PanagiotisCharalampous

exane
11 Jul 2019, 10:14

RE: RE:

Panagiotis Charalampous said:

Hi exane,

Thanks. 650 mb cannot be considered excessive memory usage. But we will double check.

Best Regards,

Panagiotis

Keep in mind that 5 range bar charts was only for testing issue to NOT couse vps and pc crash. When I want to use multiple charts (40-50 charts), as cTrader is build to work with I can only stay with 3 day and I recieve any PC crash. Becouse the memory usage is growing to infinitive. This is the problem. Starting ram usage was about 300 mb for those 5 charts. For now the cTrader with multiple range bars is totally uselessa. Imagine I want to trade 70 charts and after every crash I need to REOPEN every range bar chart and collect new data with pageUP. Try it and you will find this is REALLY ANNOYING. Btw. I guess I gotta move to other platform, becouse of such softy help from your side and misunderstading of own software.


@exane