aa63030808 发表于 2025-9-29 20:20:08

【隔夜拆帳利率】顯示商品隔夜拆帳利率

此工具可以顯示隔夜拆帳利率
//+------------------------------------------------------------------+
//|                                                   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 = " ";
      else if(swapLong==0)
            status = " ";
      else if(swapShort==0)
            status = " ";
      
      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()
{
//---
   
}
//+------------------------------------------------------------------+


hub888 发表于 2025-10-2 08:05:01

不错,可以免费使用 吗

movie 发表于 2025-10-11 10:50:04

有些平台的掉期用系统函数好像显示不了
页: [1]
查看完整版本: 【隔夜拆帳利率】顯示商品隔夜拆帳利率