fxDreema

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

    Best way to achieve this?

    Questions & Answers
    2
    6
    1537
    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.
    • B
      BlueMoon last edited by

      I want to open all open trades and open opposite trade.
      Example: If there is a an Open Buy for USDJPY....then close this trade and Open new Trade Sell USDJPY....do this for all the open trade. I mean if it is Buy, take a Sell trade, if it is Sell then take a Buy Trade.

      What is the best way to achieve this?

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

        What closes the first buy? And how it was opened, under what conditions? Because if you open a new trade every time you close one, then you have one trade all the time. I do such EAs for experimenting when I don't want to put any Condition blocks, but this doesn't sound like a strategy for trading that someone will want to actually use.

        1 Reply Last reply Reply Quote 0
        • B
          BlueMoon last edited by BlueMoon

          lets say I have a Buy trade on USDJPY....and it starts to lose money. I realize I had a wrong direction. So my condition would like when it has lost certain number of pips or amount.....I want my EA to close the Buy USDJPY...and immediatly open Sell USDJPY.

          Above was a simple example. Usually I would have a bucket of all different kind of trades. The common thing for all thse trades is their "Group" When the bucket reaches certain amount of loss. I want all trades in this bucket closed and new opposite trades taken immediately. My bucket have have combination of buy/sell trades of different pairs.

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

            Here is my example, I use the Trade event to detect when a trade is closed and then close another one:

            https://fxdreema.com/shared/bNwso8Lzc

            Of course, everything depends. I detect only then the trade is closed by SL. And this is EA, it is set by default to put some magic number to the trades => by default doesn't work with manually created trades. This is the result:

            0_1547160101519_283af0f0-7d41-424c-a97c-91b304163a8f-image.png

            1 Reply Last reply Reply Quote 0
            • B
              BlueMoon last edited by

              will this open the new trade of the same pair? if not, how do I make it open the trade of the same pair?

              Note: My EA is trading multi-currencies here.

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

                This is interesting question and the answer is no. It will open the new trade in the current pair, beccause the value of Symbol is empty value (meaning the current symbol). But it's possible to open it on the same pair of the closed trade if we just use the symbol name of the closed trade.

                Unfortunately the input field of Symbol is a simple input field, not one of those "Custom" fields where you can choose from many available options. But here are 2 methods you can try:

                Write this:

                "" + OrderSymbol() + ""
                

                here:
                0_1547753339063_825d2905-5a7e-4282-801a-9749a759f60d-image.png

                Or put the symbol name into a variable:
                0_1547753419627_f2504a67-3612-4e6e-bc54-1ca53617982d-image.png

                Also test whether this works or not, I didn't tested it in real world.

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

                Online Users

                S
                P
                T
                I
                B
                A
                H
                E

                22
                Online

                146.7k
                Users

                22.4k
                Topics

                122.6k
                Posts

                Powered by NodeBB Forums | Contributors