Page 1 of 1

MT5 - swap monitor for single currency symbol

Posted: Tue Feb 06, 2024 3:48 am
by JohnnyRy
Here is a swap monitoring indicator for a single currency pair. The currency symbol input defaults to GBPJPY, but simply replace that with 0 to use the current chart symbol or any other symbol. In this way, the indicator can be attached to a custom chart while drawing data from the base chart symbol. There is a known bug that stalls the swap values at 0.00 if the indicator loads before MT5 loads sufficient data at startup. Removing the indicator and reattaching it is the only workaround I've found, and I've been unable to fix the bug. I've attached source code below, in case another coder can fix it. Otherwise, the indicator updates every minute (M1 bar close) regardless of the chart timeframe to which it is attached. This ensures that the swap values are accurate up to the minute whenever the broker-dealer updates swaps.
 
Note: The swaps in the image are from the generic Metaquotes MT5 demo. Note: The swaps in the image are from the generic Metaquotes MT5 demo.

Re: MT5 - swap monitor for single currency symbol

Posted: Tue Feb 06, 2024 4:07 am
by JohnnyRy
@TransparentTrader, there is a multi-pair swaps monitor at: mt5-swaps-monitor-for-all-market-watch- ... 75665.html

Re: MT5 - swap monitor for single currency symbol

Posted: Tue Apr 02, 2024 11:44 am
by JohnnyRy
Here's version 2 of this indicator. Version 1 has a hard coded Print command for diagnostic purposes but it pollutes the Experts tab which can be a nuisance. New input, ExpertsTab, defaults to false in version 2. Set it to true if you want it continue printing.


Re: MT5 - swap monitor for single currency symbol

Posted: Wed Apr 03, 2024 7:10 am
by JohnnyRy
I found a bug in version 2 caused by the additional input. Fixed in version 3, attached.

I'm still on an obsessive-compulsive quest to validate MQL5 class data prior to loading which will kill that annoying zero value bug at startup...


Re: MT5 - swap monitor for single currency symbol

Posted: Wed Apr 03, 2024 8:02 am
by JohnnyRy
And... ah ha! MQL5 reference documentation revealed that MQL5 object pointers can only be used once in any coding project. Startup bug fixed in version 4, attached.

(I'll also fix the all-inclusive Market Watch symbols swap indicator when I have time).