Symbol locks up bot

Created at 07 Feb 2024, 02:24
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!
CT

ctid4921325

Joined 18.11.2023

Symbol locks up bot
07 Feb 2024, 02:24


Hi there

I'm using a broker who has 2 versions of each pair, for eg USDJPY and USDJPY.p  

I have a bot which uses `Symbol.PipSize` to calculate various things.

On the USDJPY.p symbol however locks up the bot when I reference its ‘Symbol.PipSize' .

How can I manage this?

Thanks


@ctid4921325
Replies

PanagiotisCharalampous
07 Feb 2024, 07:32

Hi there,

What do you mean when you say “locks up”? How can we reproduce this behavior?

Best regards,

Panagiotis 


@PanagiotisCharalampous

ctid4921325
07 Feb 2024, 09:30

RE: Symbol locks up bot

PanagiotisCharalampous said: 

Hi there,

What do you mean when you say “locks up”? How can we reproduce this behavior?

Best regards,

Panagiotis 

Hi Panagiotis

By ‘lockedup' I mean the bot (which is a UI for managing trades) becomes unresponsive.

I have debugs that show that it gets locked just stops when trying to access Symbol.PipSize.. for eg in the method below,  the last line that ‘logged’ was “Print($"{Symbol.PipSize}”)" Then everything stopped.
 

        private double TotalExposure()
        {.

            double result = 0;

            Print("Calculating total exposure");
            foreach (var position in Positions)
            {
                double stopLoss;
                Print($"position {position.Id}");
                if (position.StopLoss == null)
                {
                    stopLoss = 0;
                } else
                {
                  stopLoss = position.StopLoss.Value;
                 
                }
                double entry = position.EntryPrice;
                Print($"Stop loss: {stopLoss} {entry}");
                Print($"{position.VolumeInUnits}");
                Print($"{Symbol.PipSize} ");
                Print($"{Symbol.PipValue}");
                Print($"{position.VolumeInUnits} {Symbol.PipSize} {Symbol.PipValue}");
                result += position.VolumeInUnits * Symbol.PipSize * Symbol.PipValue * (position.TradeType == TradeType.Buy ? 1 : -1) * (entry - stopLoss);
                Print($"Volume in units: {position.VolumeInUnits}, pip value: {Symbol.PipValue} stoploss {stopLoss} result: {result}" );
            }
            Print($"Exposure: {result}");
            return result;
        }

I'm not sure how to reproduce it. When I originally posted, I could replicate it or fix it by just choosing the correct symbol.  Right now however, I can no longer replicate it. So i don't really understand what this might mean. 


@ctid4921325

ctid4921325
07 Feb 2024, 09:30

RE: Symbol locks up bot

PanagiotisCharalampous said: 

Hi there,

What do you mean when you say “locks up”? How can we reproduce this behavior?

Best regards,

Panagiotis 

Hi Panagiotis

By ‘lockedup' I mean the bot (which is a UI for managing trades) becomes unresponsive.

I have debugs that show that it gets locked just stops when trying to access Symbol.PipSize.. for eg in the method below,  the last line that ‘logged’ was “Print($"{Symbol.PipSize}”)" Then everything stopped.
 

        private double TotalExposure()
        {.

            double result = 0;

            Print("Calculating total exposure");
            foreach (var position in Positions)
            {
                double stopLoss;
                Print($"position {position.Id}");
                if (position.StopLoss == null)
                {
                    stopLoss = 0;
                } else
                {
                  stopLoss = position.StopLoss.Value;
                 
                }
                double entry = position.EntryPrice;
                Print($"Stop loss: {stopLoss} {entry}");
                Print($"{position.VolumeInUnits}");
                Print($"{Symbol.PipSize} ");
                Print($"{Symbol.PipValue}");
                Print($"{position.VolumeInUnits} {Symbol.PipSize} {Symbol.PipValue}");
                result += position.VolumeInUnits * Symbol.PipSize * Symbol.PipValue * (position.TradeType == TradeType.Buy ? 1 : -1) * (entry - stopLoss);
                Print($"Volume in units: {position.VolumeInUnits}, pip value: {Symbol.PipValue} stoploss {stopLoss} result: {result}" );
            }
            Print($"Exposure: {result}");
            return result;
        }

I'm not sure how to reproduce it. When I originally posted, I could replicate it or fix it by just choosing the correct symbol.  Right now however, I can no longer replicate it. So i don't really understand what this might mean. 


@ctid4921325

ctid4921325
07 Feb 2024, 11:50

RE: Symbol locks up bot

PanagiotisCharalampous said: 

Hi there,

What do you mean when you say “locks up”? How can we reproduce this behavior?

Best regards,

Panagiotis 

Hi again, this is working fine now. I don't know what caused it or why it went away (or if it will come back).  If you have theories, i'd be delighted to hear, but otherwise don't want to waste more of your time on it. 

Thanks again.


@ctid4921325