Testing out Swap, can't get it to work
-
Hi
I am testing out swap in mt5, just made a very simple strategy that opens a trade when swap is positive and closes trades when swap <=0.
I made the strategy put the value of the swap in the journal during tests. Problem is, swap is always registered as being = 0.
To get swap I use:
SwapLong = SymbolInfoDouble("AUDJPY",SYMBOL_SWAP_LONG);
Where SwapLong is the variable holding the value found.
Btw, is there any way to have it use current pair instead of a specific defined pair as above?
-
That function should work...
Check my test: https://fxdreema.com/shared/TGLf2UFI
Maybe your SwapLong is type bool, int or something else - it should be double.Use this to return the swap on current symbol:
SymbolInfoDouble(Symbol(),SYMBOL_SWAP_LONG); -
I tried to get your test to work, but it didnt. However I figured out how to share the project. SwapTest
I checked, and all swap data is kept in double format.
-
Did you try my example in visual mode? It works for me.

I'm not sure how the "Alert message" block works, but you may be using it wrong - put your variables in the data rows.
-
After restarting the computer the problem went away, and now it all works fine. Odd, but as long as it works
Thanks for the help 