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

Entry at higher/lower than previous candle

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

    Entry at higher/lower than previous candle

    Hi there,

    that's my first post so i'm a newbie.
    I have a simple idea in my head that I can't convert into a strategy, even with the tutorial videos on youtube. I've been searching through this forum and couldn't find an answer to that.
    When I say new high/low, I mean the complete candle with its wicks, not only the close.


    So here's the Idea: (instead of ticks/pips/whatever I say "steps" because I'm referring to the candle movement, not the actual price movement)

    LONG:
    Everytime a new candle is made and its price goes above the last candles high (so it's defined as a new high) I'll go long and exit the position right away at the next step in profit.

    SHORT:
    Everytime a new candle is made and its price goes below the last candles low (so it's defined as a new low) I'll go short and exit the position right away at the profit.

    Additional thoughts:
    - It's important that a position is only opened once per candle and only if it reaches the high/low of the last candles high/low (again: body PLUS wicks/shadows)
    - StopLoss would be around 2 steps more than the profit. It's not a good win/lose ratio but it's way more probable that a candle goes even higher/lower as soon as it breaks the previous candles hi/lo.
    - The higher the time frame of the strategy, the bigger the wicks, the bigger chances of profittaking of every new high/low.

    Explanation of my train of thought:
    Almost every candle makes shadows/wicks and I want to catch those little steps. If they're not making any wicks, it can only mean three things: either it's a reversal, it's a consolidation or price goes in the direction of the profit anyways.

    Fees are not calculated in this strategy. I want to test on demoaccount first.

    What are your thoughts on that? How could I set my variables and conditions? I'm not familiar with c#.

    Thank you and have a nice weekend!!
    Markus

    #2
    I will visualize my idea at a few examples in photoshop to make it more clear hopefully, haha. Give me a few minutes.

    Comment


      #3
      Hello msmusic88,

      Thank you for your post.

      To clarify, when you say that "I'll go long and exit the position right away at the next step in profit", what do you mean by "next step in profit"? After 1 tick in profit? Where exactly?

      This certainly sounds like it potentially could be created in the Strategy Builder, which we'd recommend as the first step in learning NinjaScript.

      I'd recommend checking out this video on the Strategy Builder:

      Strategy Builder 301

      As well as this section of our help guide on the Builder that includes examples of making various types of conditions:



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

      Comment


        #4
        Hi. Thanks for the very fast reply. Well, the profit could be anywhere where it's the most profitable after testing different settings right? First I'd go for the very smallest profit possible to exclude reversals (for now). Just one tick to the profit and then take it as long as it's warm.

        When a new high/low is made, statistically it goes more than just one or two ticks - especially if the previous candle has a very low range (that you can predefine as a condition), right? So what if you took a position everytime price exceeds the high/low of the previous candle at the first "tick" and take the profit right away at the minimum expected move (let's say 2 ticks to include fees, lol)

        I will definitely read about ninja script right away.

        Thanks and hear from you soon. Everyone here is invited to this discussion how to make this simple but effective strategy work.

        Comment


          #5
          Click image for larger version  Name:	image_64497.png Views:	4 Size:	171.1 KB ID:	1140301

          This is a real screenshot of a chart. It isn't even important which timeframe or charts you're using except one fact: the higher the timeframe, the more probable it is to get a minimum profit target.

          The rest is backtesting which timeframe is the most profitable with X entries at X position size. And our S/L will hit in case of just going 1 tick and then reverse back. If long, S/L at the low of the current or previous candle and vice versa.

          Side effect: Because of the wavy movement almost every candle has potential.

          Edit: Maybe you could then add a trailing stop and let it run until it hits in totalmega profit but I won't get too crazy now.
          Last edited by msmusic88; 02-05-2021, 03:27 PM.

          Comment


            #6
            Hello msmusic88,

            Thank you for your replies.

            You could certainly set this up in the Strategy Builder. Things I would note would be that a 1 tick profit target is really close to the current price at the time the order is entered, and you're pretty likely to get an error in which your stop and target get rejected because by the time the protective orders are submitted the price can easily move up or down by a tick or two and the stop or target can get rejected for being above the current bid or below the current ask (depending on the way the market moves. I'd suggest considering increasing the distance from the entry price for the stop and target, but your mileage may vary there.

            The other thing I'd note is that you could ensure there's only one trade taken per bar even when using OnEachTick by using Bars Since Entry in your conditions for entry. In the Strategy Builder you can find this under Misc in the Condition builder:



            I'll make up a basic example that uses this to restrict entry to once per bar and get that to you on Monday.

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

            Comment


              #7
              Hello msmusic88,

              Thank you for your patience.

              I've created that example I mentioned in my previous reply and attached that below. Please note that our examples are not intended for live trading, however, this should give you a start on creating your own logic.

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

              Comment


                #8
                NinjaTrader_Kate , does this line work while the current bar is still forming, because the "close" of the bar is really the "current price" since the current bar has not yet closed?
                • && (Close[0] > High[1]))
                I am still using the Strategy Builder because I'm a newbie and don't know code. I am trying this same thing (to go long one tick above the high of the previous bar) and can't get it to work.

                Comment


                  #9
                  Hello,

                  Thank you for your reply.

                  As long as you have the strategy set to Calculate On Price Change or On Each Tick, yet, Close[0] will reference the current price of the currently forming bar. The example strategy is set to run On Each Tick by default.

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

                  Comment


                    #10
                    NinjaTrader_Kate , in Strategy Builder it comes out as this - is this correct? I still can't get it to fire off correctly...
                    Click image for larger version

Name:	image_2021-02-08_091542.png
Views:	1171
Size:	7.6 KB
ID:	1140643

                    Comment


                      #11
                      Hello Jim H.,

                      Thank you for your reply.

                      Your conditions themselves look fine from what I can see. What's your current setting for the Calculate property? This gets set on the "Default Properties" screen of the Builder. If you want this to be fired intrabar on the currently forming bar, the Calculate setting must be set to On Price Change or On Each Tick on that page.

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

                      Comment


                        #12
                        I'm glad it looks right so far - The calculate property is set to "on each tick."

                        Comment


                          #13
                          Hello Jim H.,

                          Thank you for your reply.

                          What I'd recommend if you're not seeing the strategy place orders when you think it should be would be to turn on the Order Trace function:

                          Strategy Builder > Default Properties > More Properties > Trace Orders

                          Once you then recompile the strategy, you can open a new NinjaScript Output window under New > NinjaScript Output. This will print a log of any orders submitted by the strategy during while it's running, along with any ignored orders. You can then look through and see what may be occurring.

                          Here is a link to our help guide that goes into more detail on tracing orders:

                          https://ninjatrader.com/support/help...aceorders2.htm

                          Trace orders alone may not give you the full picture of whether or not a trade should have been entered on a given bar, so adding prints to your strategy that will show in the NinjaScript Output window, with information on what the variables you're using for your conditions are on a particular bar, can be helpful.

                          This forum post goes into great detail on how to use prints to help figure out where issues may stem from — this should get you going in the correct direction. You can even add these using the Strategy Builder.

                          https://ninjatrader.com/support/foru...ns-not-working

                          If you run into issues like we saw here, the above information will allow you to print out all values used in the condition in question that may be evaluating differently. With the printout information you can assess what is different between the two.

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

                          Comment


                            #14
                            NinjaTrader_Kate - I think I have some more information on the discrepancies. Because I have chosen to calculate on each tick, my indicator continues to calculate on the current (still forming) bar and if the "cross above" happens inter bar, the purchase order qualifies. To make the indicator cross over, the price is normally above the high of the previous bar. Gosh, does that even make sense ...?

                            So..... To get it to fire how I envisioned it, I would need the indicator to calculate after the end of each bar, and then if it met the indicator criteria, for the the purchase order to be calculated based on tick data. Or I suppose I can use last bar and last bar+1 for the indicator criteria (so it checks when the bar is actually finished), and then continue using tick data for the entry criteria?

                            Comment


                              #15
                              Not sure that will work because the Crossover criteria limits you to the 0 bar and the 1 bar, right?

                              Do you see another way?

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by GLFX005, Today, 03:23 AM
                              0 responses
                              1 view
                              0 likes
                              Last Post GLFX005
                              by GLFX005
                               
                              Started by XXtrader, Yesterday, 11:30 PM
                              2 responses
                              11 views
                              0 likes
                              Last Post XXtrader  
                              Started by Waxavi, Today, 02:10 AM
                              0 responses
                              6 views
                              0 likes
                              Last Post Waxavi
                              by Waxavi
                               
                              Started by TradeForge, Today, 02:09 AM
                              0 responses
                              14 views
                              0 likes
                              Last Post TradeForge  
                              Started by Waxavi, Today, 02:00 AM
                              0 responses
                              3 views
                              0 likes
                              Last Post Waxavi
                              by Waxavi
                               
                              Working...
                              X