發表文章

Edit MQL4 on VSCode

圖片
MQL4 Syntax Highlight https://marketplace.visualstudio.com/items?itemName=nervtech.mq4 MQL4 Syntax Highlighting This extension can be used to highlight the MQL 4 & 5 syntax in visual studio code. It is based on the MQL4 tmLanguage file available from  currencysecrets   github page . Please check the  project description page  from my my website for more details, or the  project github page . Features The MQL4 syntax highlight extension will colorize your .mq4, .mq5 and .mqh when working on the MetaTrader projects, as show on the following screenshots.

[MT4/MQL4] check equal or not conditions for double / double 值比較

bool checkDoubles( double a, double b, string check) { if (check== ">" ){ if (a - b > Point / 2 ) return ( 1 ); else return ( 0 ); } else if (check== "<" ){ if (b - a > Point / 2 ) return ( 1 ); else return ( 0 ); } else if (check== ">=" ){ if (a - b > - Point ) return ( 1 ); else return ( 0 ); } if (check== "<=" ){ if (b - a > - Point ) return ( 1 ); else return ( 0 ); } else if (check== "!=" ){ if ( MathAbs (a - b) > Point / 2 ) return ( 1 ); else return ( 0 ); } else { Print ( "Sorry you've entered a wrong check value" ); } return ( 0 ); } Ref:  https://www.mql5.com/en/forum/136997/page2#593570

[MT4/MQL4] Order Handle Guild / 訂單處理說明

Create / 建立 OrderSend The main function used to open market or place a pending order. int   OrderSend (     string     symbol ,                // symbol     int        cmd ,                    // operation     double     volume ,                // volume     double     price ,                 // price     int        slippage ,              // slippage     double     stoploss ,...

[MT4/MQL4] Order Type / 訂單屬性

ID Value Description OP_BUY 0 Buy operation OP_SELL 1 Sell operation OP_BUYLIMIT 2 Buy limit pending order OP_SELLLIMIT 3 Sell limit pending order OP_BUYSTOP 4 Buy stop pending order OP_SELLSTOP 5 Sell stop pending order Ref:  https://docs.mql4.com/constants/tradingconstants/orderproperties

[MT4/MQL4] Error Code / 程式錯誤代碼

Trade Server Return Codes Code ID Description 0 ERR_NO_ERROR No error returned 1 ERR_NO_RESULT No error returned, but the result is unknown 2 ERR_COMMON_ERROR Common error 3 ERR_INVALID_TRADE_PARAMETERS Invalid trade parameters 4 ERR_SERVER_BUSY Trade server is busy 5 ERR_OLD_VERSION Old version of the client terminal 6 ERR_NO_CONNECTION No connection with trade server 7 ERR_NOT_ENOUGH_RIGHTS Not enough rights 8 ERR_TOO_FREQUENT_REQUESTS Too frequent requests 9 ERR_MALFUNCTIONAL_TRADE Malfunctional trade operation 64 ERR_ACCOUNT_DISABLED Account disabled 65 ERR_INVALID_ACCOUNT Invalid account 128 ERR_TRADE_TIMEOUT Trade timeout 129 ERR_INVALID_PRICE Invalid price 130 ERR_INVALID_STOPS Invalid stops 131 ERR_INVALID_TRADE_VOLUME Invalid trade volume 132 ERR_MARKET_CLOSED Market is closed 133 ERR_TRADE_DISABLED Trade is disabled 134 ERR_NOT_ENOUGH_MONEY Not enough money 135 ERR_PRICE_CHANGED Price changed 136 ERR_OFF_QUOTES Off quotes 137 ERR_BROKER_BUSY Broker...