Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Forumula to calculate Stop Entry Order

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

    Forumula to calculate Stop Entry Order

    I have coded an indicator to give me a signal candle. This signal candle is what then gives me my order placement information.

    I can not find an option in the strategy wizard to enter the market in the way that I would like to.

    For example, let's say that yesterday's Daily AUDUSD created a signal candle.

    High: .91139
    Low: .89727
    Total Pips: 141.2

    I would like to go long if the market moves up higher by 50% of the signal candle.

    This is what it would look like:

    Buy Stop = .91139 + ((.91139 -.89727)/2)

    That would mean:

    Buy Stop @ .91845

    My StopLoss and ProfitTargets will be based on similar calculations.

    Could you please offer some help on how to accomplish this?

    Thank you!

    #2
    jg123, the wizard per se would not offer means to do such calculations - however you could look into creating a custom indicator that would supply this value as calculation, so you could use it in your order generation.

    Comment


      #3
      Okay, that sounds good.

      I am looking for how I can simply plot a line at these price points - but so far I am not able to figure out how to do that.

      I have looked into DrawLine() but I am running into issues when I try to utilize a formula to add the line.

      Can you please help me with how I should go about plotting this line automatically?

      Comment


        #4
        What kind of line are you trying to setup then using the wizard?

        Comment


          #5
          Originally posted by NinjaTrader_Bertrand View Post
          What kind of line are you trying to setup then using the wizard?
          For now, I would just like to create a line where this entry point would be in my first post. I am sure that once I get that figured out, then I could easily create the profit target and stop loss lines.

          Would that then be good enough of an indicator to use in automating my strategy and use for entry/exit techniques?

          On another note, I am also trying to figure out how to create 2 other lines for a different indicator - it would be the high of the range from 01:00 CET to 09:00 CET and the low from that same time frame. Could you direct me in the right direction for that also?

          Comment


            #6
            Well, the DrawLine would not help much here - you might have misunderstood what I was trying to say - the wizard would not allow for such mathematical logic, you would need custom program an indicator that you would then in turn use in the wizard. To get started down this route I would suggest our coding tutorials - http://www.ninjatrader.com/support/h...tsub=tutorials

            When you have calculate your value for every bar, you can then use in Conditions or orders.

            Determining the high low price values for the range would also be a job for custom programming, we have a sample that would illustrate one potential concept you could use - http://www.ninjatrader.com/support/f...ead.php?t=8600

            Comment


              #7
              Thank you very much.

              I have gone through the tutorials and i have created my own indicator that changes the bar color in order to give me my signal candle that I mentioned below. (This pulls from other indicators in order to create the signal)

              What I need help with now is how do I use the information from the signal candle (High & Low; as well as current SMA) to place a Stop Buy order for a strategy?

              At this point, I don't see documentation on how to create these types of orders.

              Comment


                #8
                The changes in bar color would not be of help, as I understand you need an order price

                You could not query the color of a bar and get your associated price then for the order, the indicator will need to return the calculated value of your price level for each bar (the .91139 + ((.91139 -.89727)/2)).

                Then you can use that as price for your Stop order.

                Comment


                  #9
                  haha, sometimes doing things in writing rather than talking makes it difficult to communicate.

                  I am not trying to reference the candle color. (the color of the candle is irrelevant to what I am doing - it is simply a way of showing me signal candles on the chart) All I am saying is that I have created an indicator that gives me a signal candle. From the information of the signal candle (such as high, low, etc) I need to calculate some values for a buy stop, sell limit, and sell stop order.

                  What I need to know is, if yesterday's AUDUSD produced a signal that I should place an order, how do I say to NinjaScript:

                  "See this candle? Take the high of this candle and subtract the low. Now, divide that by 2. When you are finished with that, add it to the high of the candle. At this price, place a Buy Stop order."

                  I have already added all of the conditions into the strategy code. Now I just need to figure out how to add the Entry order as a Buy Stop with that price.

                  Comment


                    #10
                    Right, that's what I understood - however those calcs you will have to do in the indicator itself, as this could not be done in the wizard. So it's a two step process, one for the indicator to give you the stop price, and then the other to use that price in the strategy for your Stop order.

                    Comment


                      #11
                      Okay, cool.

                      So, now, I need to go into the indicator to build the formula for the price(s).

                      What do I need to place the OnBarUpdate() in order for it to start making the calculation? How do I also output it onto the chart in order to create a line at that price point?

                      Is there some specific way that I need to store this number in order for the strategy to read it properly when I refer to it in the strategy code?

                      By the way, you are being a champ! Thanks so much for your help!

                      Comment


                        #12
                        Just create yourself a indicator skeleton through the wizard (Tools > Edit NinjaScript > New Indicator) and let it have one plot for example. This plot you could then in the OnBarUpdate() with your desired calculation, i.e. High[0] + (High[0] - Low[0])/2 - the indicator would set this for every bar into your plot, the [0] indices refer to the current processed candle. That way you continuously have your stop price ready for the strategy, plots could be directly accessed from the wizard.

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                        0 responses
                        648 views
                        0 likes
                        Last Post Geovanny Suaza  
                        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                        0 responses
                        369 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by Mindset, 02-09-2026, 11:44 AM
                        0 responses
                        108 views
                        0 likes
                        Last Post Mindset
                        by Mindset
                         
                        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                        0 responses
                        572 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by RFrosty, 01-28-2026, 06:49 PM
                        0 responses
                        574 views
                        1 like
                        Last Post RFrosty
                        by RFrosty
                         
                        Working...
                        X