Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Cut another Trade after profit is reached.

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

    Cut another Trade after profit is reached.

    Hello,

    i need Help

    I have a signal to go long , short in my Strategy AND i will take i.e. 5 ticks of profit. How do I make sure it DOES NOT take another 5 ticks of the next bar (or maybe not) i.e. I only want 5 ticks ONCE until I get another signal in the opoosit direction, an so on.

    Please send my the code. I think it must be placed under the first and second condition.

    This is an example

    // Condition set 1
    if (Close[0] > HMA(Median, 1)[0])
    {
    EnterLong(DefaultQuantity, "Buy");
    }

    // Condition set 2
    if (Close[0] < HMA(Median, 1)[0])
    {
    EnterShort(DefaultQuantity, "Sell");
    }
    }

    thanks a lot

    #2
    Hi Deogenes,

    Thanks for the post and welcome to the NT forums. I'm not entirely clear on this:
    How do I make sure it DOES NOT take another 5 ticks of the next bar
    Are looking to enforce only one signal per direction? So it will always alternate long > short > long > short?
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Hi Ryan,

      yes, but only if a new Signal is made ( something crossing, higher, lower ...) to generate in the opposit direction. Here i will take another bit of profit and so far.

      Comment


        #4
        Thanks for the reply. It sounds like you want to use CrossAbove or CrossBelow rather than > <.

        These functions will capture the specific bar that indicators change directions. You could use the strategy wizard condition builder to create crossing expressions, or refer to this sample here:


        These will likely work with your specific conditions, but you can also use bool flags or user variables to create sequences in code. This sample can help with user variables in the strategy wizard:
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Thanks Ryan,

          i have just looked at the Samples. I think it is the right way to get what i want. I try something, and give you later a feed back.

          Comment


            #6
            It doesen´t work !

            My Indicator ist the ATR. The thing i want, is:
            If c > ATR Enter Long ; set profit target 8 ticks and do not trade(!!)
            till you get:
            If c < ATR Enter Short set profit target 8 ticks and do not trade(!!) till you get ... Enter Long and so on.

            I´am not a Programmer, so i need to know wher to set what.

            Thanks a lot

            Comment


              #7
              That type of condition compares two different types of values. They're unlikely to ever cross, and comparison with > or < is unlikely to be meaningful.

              Close is the traded price of an instrument. ATR is built from an average of high - low over a series of bars. Add ATR to a chart from your indicator list and you can see the types of values you get compared to the close price.
              Ryan M.NinjaTrader Customer Service

              Comment


                #8
                But it works very good. How can i send you a chart, so that you can see exaktly how it looks like, till yet.

                Comment


                  #9
                  You can post a chart to the forums and we're happy to take a look. When posting click the paper click icon (or manage attachment button) and can then choose an image to post.

                  We will not be able to offer you custom coding services, however. We're happy to point you in the right direction where you can learn more and are usually always able to offer feedback on progress shared.

                  If you are not a programmer, this material can offer a learning curve, and you may want to start with only the strategy wizard condition builder when building strategies. This is a point and click interface that does not require programming, but also does not have all the flexibility of working with code.

                  If you have limited programming experience and would prefer to explain your strategy requirements to a dedicated professional, you can always consider one of our 3rd party NinjaScript consultants. A complete list is available below:
                  Last edited by NinjaTrader_RyanM1; 06-07-2012, 03:44 PM.
                  Ryan M.NinjaTrader Customer Service

                  Comment


                    #10
                    OK Ryan,
                    i have posted a Chart (under Charting). Thank you.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by kevinenergy, 02-17-2023, 12:42 PM
                    115 responses
                    2,699 views
                    1 like
                    Last Post kevinenergy  
                    Started by prdecast, Today, 06:07 AM
                    1 response
                    4 views
                    0 likes
                    Last Post NinjaTrader_LuisH  
                    Started by Christopher_R, Today, 12:29 AM
                    1 response
                    14 views
                    0 likes
                    Last Post NinjaTrader_LuisH  
                    Started by chartchart, 05-19-2021, 04:14 PM
                    3 responses
                    577 views
                    1 like
                    Last Post NinjaTrader_Gaby  
                    Started by bsbisme, Yesterday, 02:08 PM
                    1 response
                    15 views
                    0 likes
                    Last Post NinjaTrader_Gaby  
                    Working...
                    X