此工具可以顯示隔夜拆帳利率
- //+------------------------------------------------------------------+
- //| CheckSwaps.mq4 |
- //| Copyright 2025, MetaQuotes Ltd. |
- //| https://www.mql5.com |
- //+------------------------------------------------------------------+
- #property copyright "Copyright 2025, MetaQuotes Ltd."
- #property link "https://www.mql5.com"
- #property version "1.00"
- #property strict
- //+------------------------------------------------------------------+
- //| Expert initialization function |
- //+------------------------------------------------------------------+
- int OnInit()
- {
- //--- create timer
- EventSetTimer(60);
- int totalSymbols = SymbolsTotal(true); // true = 只顯示交易商品
- Print("===== 所有交易商品掉期資訊 =====");
-
- for(int i=0; i<totalSymbols; i++)
- {
- string sym = SymbolName(i, true); // 取得交易商品名稱
- double swapLong = MarketInfo(sym, MODE_SWAPLONG);
- double swapShort = MarketInfo(sym, MODE_SWAPSHORT);
-
- string status = "";
- if(swapLong==0 && swapShort==0)
- status = " [Swap Free / 無掉期]";
- else if(swapLong==0)
- status = " [Long 無掉期]";
- else if(swapShort==0)
- status = " [Short 無掉期]";
-
- Print(sym, " | SwapLong: ", swapLong, " | SwapShort: ", swapShort, status);
- }
-
- //---
- return(INIT_SUCCEEDED);
- }
- //+------------------------------------------------------------------+
- //| Expert deinitialization function |
- //+------------------------------------------------------------------+
- void OnDeinit(const int reason)
- {
- //--- destroy timer
- EventKillTimer();
-
- }
- //+------------------------------------------------------------------+
- //| Expert tick function |
- //+------------------------------------------------------------------+
- void OnTick()
- {
- //---
-
- }
- //+------------------------------------------------------------------+
- //| Timer function |
- //+------------------------------------------------------------------+
- void OnTimer()
- {
- //---
-
- }
- //+------------------------------------------------------------------+
复制代码
|