fxDreema

    • Register
    • Login
    • Search
    • Back to the main page
    • Categories
    • Recent
    • Tags
    • Popular
    • Search

    Testing out Swap, can't get it to work

    Questions & Answers
    2
    5
    1142
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      simharr last edited by

      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?

      0_1570854244683_SwapTest.ex5

      1 Reply Last reply Reply Quote 0
      • roar
        roar last edited by roar

        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);

        Need small help? Tag me in your post
        Need big help? https://www.fiverr.com/big_algo/automate-your-winning-strategy-in-mql4-or-mql5

        1 Reply Last reply Reply Quote 0
        • S
          simharr last edited by

          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.

          1 Reply Last reply Reply Quote 0
          • roar
            roar last edited by

            Did you try my example in visual mode? It works for me.
            0_1570896782415_3d79a3b8-2157-4f28-95b2-2e7f46a531f6-image.png

            I'm not sure how the "Alert message" block works, but you may be using it wrong - put your variables in the data rows.

            Need small help? Tag me in your post
            Need big help? https://www.fiverr.com/big_algo/automate-your-winning-strategy-in-mql4-or-mql5

            1 Reply Last reply Reply Quote 0
            • S
              simharr last edited by

              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 🙂

              1 Reply Last reply Reply Quote 1
              • 1 / 1
              • First post
                Last post

              Online Users

              E
              K
              M
              D
              N

              14
              Online

              146.7k
              Users

              22.4k
              Topics

              122.6k
              Posts

              Powered by NodeBB Forums | Contributors