what's wrong with my code? 新评论 ziyang2048 2022.08.06 11:12 MqlTradeRequest request; MqlTradeResult result; void OnTick() { request.symbol = Symbol(); request.volume = 0.01; request.action = TRADE_ACTION_DEAL; request.type_filling = ORDER_FILLING_IOC; request.price = SymbolInfoDouble(Symbol(),SYMBOL_ASK); request.type = ORDER_TYPE_BUY; for(int i = 1; i < 2 ; i++) { bool a = OrderSend(request,result); } if(PositionSelect(Symbol()) == true) { long ticket = PositionGetInteger(POSITION_TICKET); string position = PositionGetString(POSITION_SYMBOL); double volume = PositionGetDouble(POSITION_VOLUME); ENUM_POSITION_TYPE position_type = (POSITION_TYPE_BUY)PositionGetInteger(POSITION_TYPE); double sl = PositionGetDouble(POSITION_SL); double tp = PositionGetDouble(POSITION_TP); double open_price = PositionGetDouble(POSITION_PRICE_OPEN); Comment("ticket = ",ticket,"\n", "position_open = ",position,"\n", "position_type = ",position_type,"\n", "sl = ",sl,"\n", "tp = ",tp,"\n", "open_price = ",open_price); } } hi guys, I have really no idea what's wrong with the position_type, I got a error says that "position_type - some operator expected", can anyone help? Ziheng Zhuang 2022.08.06 11:18 #1 ENUM_POSITION_TYPE position_type = (ENUM_POSITION_TYPE)PositionGetInteger(POSITION_TYPE); Ziheng Zhuang 2022.08.06 13:52 #2 ziyang2048 #: 我有一个问题,我不是很懂为什么为什么PositionGetInteger前面要放enum_position_type? 两边的数据类型不一致, 把大的类型赋给小的类型时需要做强制转换. 因为PositionGetInteger()函数的返回值类型是long,而左边的变量position_type的类型是ENUM_POSITION_TYPE 需要把long类型转换成 ENUM_POSITION_TYPE类型 ziyang2048 2022.08.07 03:09 #3 Ziheng Zhuang #: 两边的数据类型不一致, 把大的类型赋给小的类型时需要做强制转换. 因为PositionGetInteger()函数的返回值类型是long,而左边的变量position_type的类型是ENUM_POSITION_TYPE 需要把long类型转换成 ENUM_POSITION_TYPE类型 哦哦 我了解了,谢谢你 新评论 您错过了交易机会: 免费交易应用程序 8,000+信号可供复制 探索金融市场的经济新闻 注册 登录 拉丁字符(不带空格) 密码将被发送至该邮箱 发生错误 使用 Google 登录 您同意网站政策和使用条款 如果您没有帐号,请注册 可以使用cookies登录MQL5.com网站。 请在您的浏览器中启用必要的设置,否则您将无法登录。 忘记您的登录名/密码? 使用 Google 登录
hi guys, I have really no idea what's wrong with the position_type,
I got a error says that "position_type - some operator expected",
can anyone help?