Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Price Filter..??

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Price Filter..??

    Hello,

    In the Strategy Builder.... Is there a way to filter out an unwanted price when building a strategy..?? For instance.. In a Short position..We all take profit when your entry price is higher then your exit price.. How can I add the logic and use it as a filter in the Strategy Builder to filter out those prices where the exit price is higher than the entry price..?


    Michael

    #2
    Hello Mykro,

    Thank you for your post.

    To clarify, are you saying you only want your strategy to exit the trade if you'd be taking a profit? Or are you asking how to create a Stop loss in the Strategy Builder to ensure you don't take too much of a loss?

    If you just need to know how to find the entry price in the Strategy Builder it's in the Strategy folder under "Average Position Price", which you can then compare to the current close.

    Thanks in advance; I look forward to assisting you further.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Hello Kate...

      Originally posted by NinjaTrader_Kate View Post
      Hello Mykro,

      Thank you for your post.

      To clarify, are you saying you only want your strategy to exit the trade if you'd be taking a profit? Yes... This is correct..! I am using ExitLongs & ExitShorts with this particular strategy..

      Or are you asking how to create a Stop loss in the Strategy Builder to ensure you don't take too much of a loss?

      If you just need to know how to find the entry price in the Strategy Builder it's in the Strategy folder under "Average Position Price", which you can then compare to the current close.

      Thanks in advance; I look forward to assisting you further.
      Thank You

      Michael

      Comment


        #4
        Hello Mykro,

        Thank you for your reply.

        You could certainly program a strategy that only exits if it's profitable, but if you don't handle situations in which the market is not going your way you stand a very good chance of taking large losses before your broker takes you out of the trade. Your broker closing you out of a trade will generally not halt your strategy and will make your account out of sync with it, which can result in unintended positions.

        That being said, you have several options here, but the simplest thing would be to check whether the close of the current bar is greater than the Average Position Price (for a long trade, less than the Average Position Price for a short trade) and if so, allow the exit. For example:

        Click image for larger version

Name:	2019-10-14_0841.png
Views:	207
Size:	67.7 KB
ID:	1074332
        Please let us know if we may be of further assistance to you.
        Attached Files
        Kate W.NinjaTrader Customer Service

        Comment


          #5
          Thank You Kate...

          I see how this works.. It's leveling the playing... It takes most..if not all of the the trades winners or losers, and gives them a two tick profit.. If I have a 30 tick profit it ends up being a two tick profit... and visa versa..
          What if... you could test for the condition using the Position.MarketPosition as a bool.. If it is false use your current condition to Exit the trade else, the Position.MarketPosition.. ??

          Michael
          Last edited by Mykro; 10-15-2019, 05:42 PM.

          Comment


            #6
            Hello Mykro,

            Thank you for your reply.

            The position is not a bool with a true or false value and cannot be used as such. Instead, it can have a value of long, short, or flat. If you wish to know if you are in a position, compare the current position to a flat position, then exit or not based on whether or not it is flat.

            Please let us know if we may be of further assistance to you.
            Kate W.NinjaTrader Customer Service

            Comment


              #7
              Kate,

              For what it's worth, Here is what I'm trying to accomplish.. See the attached image..
              The image shows a long trade with the trade exiting when the close crosses below the Red VMA line.. The Red VMA line being the stop loss too..
              On the left in the image is a bogus trade I'm trying to filter out as best I can..



              Click image for larger version

Name:	Long Trade.jpg
Views:	288
Size:	138.0 KB
ID:	1074768



              The following is what I'm trying to do based on what you showed me..using some pseudo code of my own..... Is this doable..??

              If all of the following conditions are met:

              IF, (Default Input[0] < Position.Average Price) = True

              Then, (Default Input[0] > Position.Average Price)

              Else, (Default Input[0] <= VMA(RedPeriod, RedVol)[0]


              Do the Following: ExitLong(Default Quantity "","")

              Thanks
              Michael

              Comment


                #8
                Hello Mykro,

                Thank you for your note.

                Strategy Builder condition sets are evaluated independently. The strategy builder is limited and complex logic would need to be coded by hand.

                Can you clarify what you mean by "Then, (Default Input[0] > Position.Average Price)"? To me, this reads like you're wanting this to force the current price to be profitable. What in your logic makes the left side trade "bogus"?

                You need to literally define what you want to not take an action during. From your screenshot, it appears your strategy entered a long order at what is just about the lowest point of that entire displayed time frame. Rather than looking at how it's exiting, I would take a look as to why your strategy entered at that point in the first place with a short order.

                Thanks in advance; I look forward to assisting you further.
                Kate W.NinjaTrader Customer Service

                Comment


                  #9
                  Hello Kate,

                  You are correct, I know my pseudo code would be too complex for the strategy builder and would probably needed to be coded by hand I was hoping for a work around...
                  The "Then" corresponds to an "IF, Then, Else" statement..

                  "IF" this happens... Default Input[0] < Position.Average Price = True

                  "Then" do this... Default Input[0] > Position.Average Price

                  If the "Then" is false, "Else" Do this... Default Input[0] <= VMA(RedPeriod, RedVol)[0]

                  Sorry for the confusion...

                  The Long position in the image is the ideal trade and a Short Position would be the opposite.. The other short trade in the image is the result of a sideways market with low volume.. I'm trying to filter those out..

                  Thanks for your help

                  Michael


                  Comment


                    #10
                    Hello Mykro,

                    Thank you for your reply.

                    C# does not have If...then...else statements.

                    You could do a similar thing with nested if statements, however.

                    Code:
                    If (this thing is true)
                    {
                         // do some things
                        if (this thing is also true)
                        {
                              //do something further (this will only run if the first two if statements were true)
                         }
                    }
                    else if (something other than the original thing is true)
                    {
                         //do a different thing here
                    }
                    Obviously that's not valid code, but you get the general idea of the structure.

                    As I mentioned in my previous email, rather than looking at how it's exiting, I would take a look as to why your strategy entered at that point in the first place with a short order and adjust those conditions for entry.

                    Please let us know if we may be of further assistance to you.
                    Last edited by NinjaTrader_Kate; 10-17-2019, 10:44 AM.
                    Kate W.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by judysamnt7, 03-13-2023, 09:11 AM
                    4 responses
                    56 views
                    0 likes
                    Last Post DynamicTest  
                    Started by ScottWalsh, Today, 06:52 PM
                    4 responses
                    35 views
                    0 likes
                    Last Post ScottWalsh  
                    Started by olisav57, Today, 07:39 PM
                    0 responses
                    7 views
                    0 likes
                    Last Post olisav57  
                    Started by trilliantrader, Today, 03:01 PM
                    2 responses
                    19 views
                    0 likes
                    Last Post helpwanted  
                    Started by cre8able, Today, 07:24 PM
                    0 responses
                    8 views
                    0 likes
                    Last Post cre8able  
                    Working...
                    X