Errors that I cannot seem to fix, ChatGPT also too stupid

Created at 15 May 2023, 10:25
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!
UM

umadrat2012

Joined 18.09.2021

Errors that I cannot seem to fix, ChatGPT also too stupid
15 May 2023, 10:25


Hi guys,

I am getting the following error in my code and I cant seem to fix it

if (is_16_00 && Convert.ToBoolean(go_long))
            {
                double take_profit = Symbol.Ask + Symbol.PipSize * tp_value;
                var result = ExecuteMarketOrder(TradeType.Buy, Symbol.Name, Symbol.NormalizeVolume(0.1), Symbol.Ask, 1, 0, take_profit, "buy");
                if (result.IsSuccessful)
                {
                    Print("Buy order placed");
                }
                else
                {
                    Print("Buy order failed with error code: ", result.Error);
                }
            }

Errors

Symbol.Ask highlighted ,Cannot convert from double to bool
take_profit highlighted, Cannot convert double to string
"buy" highlighted, cannot convert from string to bool
 


@umadrat2012
Replies

firemyst
18 May 2023, 08:18

RE:

umadrat2012 said:

Hi guys,

I am getting the following error in my code and I cant seem to fix it

if (is_16_00 && Convert.ToBoolean(go_long))
            {
                double take_profit = Symbol.Ask + Symbol.PipSize * tp_value;
                var result = ExecuteMarketOrder(TradeType.Buy, Symbol.Name, Symbol.NormalizeVolume(0.1), Symbol.Ask, 1, 0, take_profit, "buy");
                if (result.IsSuccessful)
                {
                    Print("Buy order placed");
                }
                else
                {
                    Print("Buy order failed with error code: ", result.Error);
                }
            }

Errors

Symbol.Ask highlighted ,Cannot convert from double to bool
take_profit highlighted, Cannot convert double to string
"buy" highlighted, cannot convert from string to bool
 

 

You have the wrong parameters for your call to the ExecuteMarketOrder method.

For starters, no ExecuteMarketOrder API call takes a "double" (Symbol.Ask) as the 4th parameter.

 

 


@firemyst