Weird null reference error

Created at 25 Sep 2022, 05:03
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!
MM

mmmsogood69

Joined 25.08.2022

Weird null reference error
25 Sep 2022, 05:03


Any idea why this would throw a null reference error when the print line is working but my bot is crashing on the boolean comparisons?

 

                                Print($"Does this work? {positionHighestProfit}");
                                if ((currentProfit < (positionHighestProfit * .75)) && (positionHighestProfit > 25))
                                {
                                    try {
                                        Print($"Got here at least");
                                        ClosePosition(position);
                                        Print($"Closed position {position.Label}");
                                    } catch(NullReferenceException err){
                                        Print($"{err.Message}");
                                    }
                                }


@mmmsogood69
Replies

PanagiotisCharalampous
26 Sep 2022, 10:50

Hi there, 

In order to help you we need the full cBot code as well as exact steps to reproduce the problem.

Best Regards,

Panagiotis 

Join us on Telegram and Facebook


@PanagiotisCharalampous