fxDreema

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

    Partially Close Trades Example

    Questions & Answers
    2
    5
    1216
    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.
    • T
      Trader3487 last edited by

      Hi, I am looking for a way to close part of trade if it reaches 50 pips below opening price and keep closing that amount every time it crosses back over the 50 pips line. I can't figure out why this example isn't working correctly:

      http://fxdreema.com/shared/RgiqFCLkc

      ScreenClip.png

      ......
      ScreenClip.png
      ScreenClip.png

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

        Because one counter is used to control multiple trades, for this array is needed. I think there is no way to do this with existing blocks, and I don't have some great idea which is the easiest way to do it otherwise, but I can think about it 🙂

        1 Reply Last reply Reply Quote 0
        • T
          Trader3487 last edited by

          thank you, I have been sitting on this puzzle for 12 hours. It's the last piece to finish my ea 🙂

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

            I'm not sure if this will work, but you can try it. Create a new custom block with this content:

            if (FXD_BREAK==true) {return;}
            LoopedResume();
            static int memory[];
            bool next=false;
            int ticket=OrderTicket();
            if (InArrayI(memory,ticket)==false) {
               ArrayValueI(memory,ticket);
               next=true;
            }
            if (next==true) {~next~} else {~inext~}
            

            This is modified "once per trade/order" that should work once per trade... really, I mean - once for each trade, even for those that are result from partial close.

            If this works, I can add some option in "once per trade/order" that will make you choose to consider partial closed trades as a single trade or as independent.

            1 Reply Last reply Reply Quote 0
            • T
              Trader3487 last edited by

              great, thanks - I'll check it out next week (I figured out a workaround using about 100 blocks but your solution would make it a lot cleaner!)

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

              Online Users

              C
              K
              A
              D

              15
              Online

              146.7k
              Users

              22.4k
              Topics

              122.6k
              Posts

              Powered by NodeBB Forums | Contributors