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

Flipping from long to short in 5 set strategy

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

    Flipping from long to short in 5 set strategy

    (I just realized I have this post in the wrong category, I'll get it right next time)

    I have the long side working beautifully now with all kinds of strategy experiments.

    Now I'm flipping to short & it's kind of a mind bend I'm missing something simple that I'm not seeing.
    I'm quite sure it's in the minus & not minus category starting in the inputs.

    Just by a quick look does anything jump out at you that I am doing wrong.
    If this looks about right, then it's in conditions.
    Attached Files
    Last edited by trdninstyle; 11-07-2022, 01:10 PM.

    #2
    Hello trdninstyle,

    Thank you for your post.

    I have moved this thread to the NinjaTrader 8 Strategy Development topic accordingly. Thank you for acknowledging it was in the wrong category and helping us to keep the forum categories organized!

    Based on your screenshot, I am not able to see anything jumping out that would explain what you may or may not be missing. What is the expected behavior of the strategy vs. what is actually occurring? Have you tried adding any print statements to debug your strategy? We have the following post about adding print statements, including the video link demonstrating how to add prints in the strategy builder:



    Please let me know if I may be of further assistance.
    Emily C.NinjaTrader Customer Service

    Comment


      #3
      HI Emily,

      I found it; it was in the conditions. I methodically went back through it comparing it to the long side on the wizard. I am going to go thru the video of describing the adding print statements because in historic view it will sometimes show the stop not getting hit thus allowing price to go too far but as price would come back up the stop being executed right there. I on purposely went back on replay to test that instance and it played out like it should. So, it's a view type thing not actual type thing. I have to also learn more about the tracing and its benefits to that.

      I did realize how to get back to Strategy Development topic afterwards. I admit before I was guessing where to start a thread.

      Also, where I have two bull bars in a row triggering a long it will trigger a long after the first two bear bars of the day, RTH. On that instance I need to look at it in replay.

      Thank you for your superior support without a single doubt.
      (I just opened up those links, got an extra video! YES) (I learn quicker by video)
      Last edited by trdninstyle; 11-07-2022, 02:40 PM.

      Comment


        #4
        This last pic is how I added the information for yesterday's date & time of 10:25am then 11:05am for the entry & exit to get a string readout for the 1st pic where u can see that price went further without stop being activated, but then activated on the way back up.

        I copied the strategy deleted all the other stuff but the string readout & exported it to you. I put in the (Close[0]>Open[0]) and added the prior bar too. And the bar closing above EMA instances.

        I haven't done the tracer yet but going to soon, but it has to be in an unlocked version I believe? Thats the 2nd pic.

        So, can the string builder tell us why the stop didn't stop me out as price raced down even further?

        Thank you, Emily, for any light you can shed on this. Or anything I can do to make a more accurate printout.
        Awesome and even more awesome. Now thats awesome
        Attached Files

        Comment


          #5
          Hello trdninstyle,

          Thank you for your reply.

          Trace Orders may actually be enabled in the Strategy Builder without having to unlock the script. To enable Trace Orders, follow these steps:To view the output from Trace Orders when your strategy is running, go to Control Center > New > NinjaScript Output

          You may even monitor this window during a backtest of your strategy to review what happened with your orders and why they were or were not processed as expected based on your strategy logic.

          Please let us know if we may be of further assistance.
          Emily C.NinjaTrader Customer Service

          Comment


            #6
            Thank you for good the information. I'm learning my way through the print series it's pretty interesting.

            Instead of two ma's one crossing over the other I have price closing greater than a set EMA. I need to have a bar's close just prior to the EMA and the bar closing right after the EMA in order to diagnose a strategy not acting right? I know there's more to it but thats the real first premises I need to figure out, right?

            In Chelsea's video thats how he has the value for the two SMA's in the string builder, but I have price & one EMA.

            How does this information get applied to fix an error so stops get taken out as they need to?

            Thank you I do appreciate everything I'm slowly picking up on it.
            p.s. creating a bot doesn't happen overnight This is good stuff once I learn it.

            Comment


              #7
              Hello trdninstyle,

              Thank you for your reply.

              I think I will need additional clarification to understand this:
              "Instead of two ma's one crossing over the other I have price closing greater than a set EMA. I need to have a bar's close just prior to the EMA and the bar closing right after the EMA in order to diagnose a strategy not acting right? I know there's more to it but thats the real first premises I need to figure out, right?"

              If possible, please provide a screenshot of your strategy builder condition showing where you are checking for the price closing greater than the EMA. Even better, if you click the "View Code" button, please send a screenshot of the portion of code that lines up with that set of conditions. In the View Code page, there will be code comments that show the set numbers that align with the set numbers in the Conditions and Actions screen of the builder.
              • To send a screenshot with Windows 10 or newer I would recommend using the Windows Snipping Tool.
              • Alternatively to send a screenshot press Alt + PRINT SCREEN to take a screenshot of the selected window. Then go to Start--> Accessories--> Paint, and press CTRL + V to paste the image. Lastly, save it as a jpeg file and send the file as an attachment.
              Once I have more details, I would be glad to provide a sample print statement that you could set up to understand when the condition is being triggered and why, and this could help to understand why the action is/is not triggered and then tweak the condition so that it triggers when expected.

              I look forward to your reply.
              Emily C.NinjaTrader Customer Service

              Comment


                #8
                Sorry about that.

                I just meant that I have only two items, the close of a bar and an EMA. When a bar closes above a certain value of an EMA, sometimes a 20ema. It triggers a limit buy.

                In Chelseas video he had 2 SMA's, he set them to a prior bar [1] (after a label) to identify them and then the next set he made them for the current bar [0]. So, he could see what was happening prior to the cross and at the cross. (Not bar but sma's)

                So, I don't have 2 moving averages but one with a close above that ema. I was working on my scenario for a price bar close just before crossing the ema and the bar close after it crossed the ema. I made that completely confusing before.

                Let me work on this tomorrow and I will set up some screenshots, but I found my nitch and this is it. I love how this technology can do all this and narrow things down to a nice tight trading strategy.
                I'm so excited this is so crazy, making a trading bot. lol You will hear from me tomorrow. All gratitude. Bill
                Last edited by trdninstyle; 11-09-2022, 07:06 PM.

                Comment


                  #9
                  Thank you again Emily, I use Greenshot does that work okay on your end? I'll go back and use the one you're recommending if u prefer me to use that one.
                  I gave you both, the builder and the script. I thank you I thank you I thank you!
                  Attached Files
                  Last edited by trdninstyle; 11-10-2022, 10:18 AM.

                  Comment


                    #10
                    I'm learning, I need to have a close[0]> Open[0] right after the (GetCurrentBid(0) > EMA1[0] so I get long only on bull bars above the ema.

                    && (GetCurrentBid(0) > EMA1[0])
                    && (Close[0] > Open[0]))

                    I'm trying to figure out how to tell it to take bulls that have distance between the open & close so I can avoid doji's.
                    Something like && Close[0[,3Ticks> Open[0]))
                    Attached Files
                    Last edited by trdninstyle; 11-10-2022, 11:00 AM.

                    Comment


                      #11
                      Originally posted by trdninstyle View Post
                      Thank you again Emily, I use Greenshot does that work okay on your end? I'll go back and use the one you're recommending if u prefer me to use that one.
                      I gave you both, the builder and the script. I thank you I thank you I thank you!
                      Hello Bill,

                      Thanks for the screenshots - Greenshot worked just fine.

                      Based on your condition for Set 2 that checks if the position is flat, if the Close[0] is greater than the Open[0] of the bar, and if the Close[0] is greater than EMA1[0], here is an example print statement you could include to check on those values when the condition is triggered and better understand your strategy's current behavior:

                      Screenshot - https://www.screencast.com/t/TLLKhEmGT
                      Video - https://www.screencast.com/t/mSqjVvcmbQ

                      This print statement will show the Time for the bar when the condition as triggered as well as print all values involved in the condition and actions. When you run your strategy, you can check in the NinjaScript Output window and when you see that print statement, it will help you understand when your condition was triggered and why based on those values. If it triggers at a time when you don't want it to, you may need to modify the conditions to consider a more specific set of conditions when you want the EnterLongLimit order to be submitted.

                      Please let us know if we may be of further assistance.
                      Emily C.NinjaTrader Customer Service

                      Comment


                        #12
                        You are the best! oops, forgot the.
                        Last edited by trdninstyle; 11-10-2022, 01:36 PM.

                        Comment


                          #13
                          I noticed a gap in the print between 1:50 and 2:00 and that stop was at 1:55 right in between, so it didn't register. (last pic)
                          Another clue could be where it said 'Reason='Invalid order price, please see log tab' this was at the entry time of 12:25 on the chart, actually it was 12:27.

                          So, when it makes an invalid entry, it may not know to exit on time? 2nd pic is the entry at 12:27 in the log tab.

                          Now this wasn't in real time, though. It probably would have been stopped out as it should have. It's after activating the strategy and it is in history. Tomorrow I will try that time span in replay to see what happens.

                          From your insight what can you discern from these pics.
                          Trust me, I'm fortunate to have u helping me. Pheww and I'm glad.

                          I slipped in a screenshot of the log at 1:56 saying an order was being ignored from earlier, so I don't know. Thats where that stop exit happened.
                          I re-entered the now, last pic.
                          Attached Files
                          Last edited by trdninstyle; 11-10-2022, 07:03 PM.

                          Comment


                            #14
                            Hello trdninstyle,

                            Thank you for your note.

                            Your observations seem to be in line with the expected discrepancies between backtest (historical) and real-time; order fills in a backtest are processed on OHLC data from each bar, meaning there is no intrabar granularity and they are essentially calculated OnBarClose rather than OnPriceChange or OnEachTick. We have some more details here:


                            One way to try and mitigate this is to use the High order fill resolution option which allows you to select a secondary series for order fills. You could select a more granular series, such as 1-tick, although it will typically use more resources to calculate so you may notice some delays in loading. For more information regarding Historical Order Processing and the Order Fill Resolution:


                            Otherwise, another option is to program your script to submit orders to a 1-tick data series. We have a reference sample that demonstrates this more advanced concept here:


                            Please feel free to reach out with any additional questions or concerns.
                            Emily C.NinjaTrader Customer Service

                            Comment


                              #15
                              Hi Emily,

                              "order fills in a backtest are processed on OHLC data from each bar" This makes sense & explains why historical looks the way that it does at times.
                              So, just use "the High order fill resolution option" for historical view when examining then. I can place a lookback of 5 days to fix some of the rendering.

                              During live market data using a strategy I haven't seen a stop not get activated like it looks in the historical view, the initial stop, breakeven +1 and target all works excellent, I'm happy about that.

                              I've been adjusting the language in the way it enters though, I want to enter long after a bull bar closes & while it is above the ema. So, I've been moving that around with the way I tell the machine to do that. It is so efficient with its orders no human emotions. I'm going to examine the links u just gave me.

                              It's Friday! Best news of the day. Bill
                              Last edited by trdninstyle; 11-11-2022, 11:28 AM.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by ageeholdings, Today, 07:43 AM
                              0 responses
                              2 views
                              0 likes
                              Last Post ageeholdings  
                              Started by pibrew, Today, 06:37 AM
                              0 responses
                              4 views
                              0 likes
                              Last Post pibrew
                              by pibrew
                               
                              Started by rbeckmann05, Yesterday, 06:48 PM
                              1 response
                              14 views
                              0 likes
                              Last Post bltdavid  
                              Started by llanqui, Today, 03:53 AM
                              0 responses
                              6 views
                              0 likes
                              Last Post llanqui
                              by llanqui
                               
                              Started by burtoninlondon, Today, 12:38 AM
                              0 responses
                              12 views
                              0 likes
                              Last Post burtoninlondon  
                              Working...
                              X