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

New to programing simple ninja question

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

    New to programing simple ninja question

    Hi

    I'm trying to set up a strategy that would execute a buy after two conditions have been meet.
    First condition price or high to cross over a MA envelope top band and then pulls back and buy around the MA plus or minus a few ticks that would be a variable that I can adjust. I don;t want it to look back a specific amount of bars, just when it crosses the top band and it pulls back to the MA buy. Even if the buy condition comes in after a few bars, it doesn't have to be the next bar. My issue is when I try to do it through the wizard is looking for both conditions on the last bar. Been looking in the forums and can find an example that I could look at to learn from it. Any help with this would greatly be appreciated.

    #2
    Hello roadtrader,

    Thank you for your post and welcome to the NinjaTrader Support Forum!

    I have created a video on this matter, you may view this video at the following link: http://screencast.com/t/GPSS8KuC

    Please let me know if you have any questions.

    Comment


      #3
      Thanks, let me play with this and see how it goes. I think I got the concept of setting a variable when condition one is met and then then if the variable is true and the second condition happens to execute the action.

      Comment


        #4
        Question, I don't know how far back the strategy looking to see if my first condition (variable 1) is true. because is executing trades that have not come from hitting by top bad recently. How do I control that. If you need me to send you a picture I can do that. Thanks for your help beginning to get some of this.

        Comment


          #5
          Hello roadtrader,

          Thank you for your response.

          Attached is a screenshot of the Condition Builder. When you select CrossAbove or Below you will see a LookBack Period, this is the number of bars to check for the cross condition.

          Please let me know if you have any questions.
          Attached Files

          Comment


            #6
            Hello Patrick thanks for your help. I have tried playing with the lookback period and results don't change, I'm sending you a picture of three bad trades and one that it actually did what I'm trying to do. Attached a PDF file with picture. I had the look back period at 5 for this example
            Attached Files

            Comment


              #7
              This is the code so far
              Attached Files

              Comment


                #8
                Originally posted by roadtrader View Post
                Hello Patrick thanks for your help. I have tried playing with the lookback period and results don't change, I'm sending you a picture of three bad trades and one that it actually did what I'm trying to do. Attached a PDF file with picture. I had the look back period at 5 for this example
                Without seeing your code, it is hard to be certain, but your results would seem to indicate that you are triggering off a cross of the moving average itself, rather than the offset band.

                Comment


                  #9
                  Code

                  Here is the simple code
                  Attached Files

                  Comment


                    #10
                    picture

                    PDF picture
                    Attached Files

                    Comment


                      #11
                      Hello roadtrader,

                      Thank you for your response.

                      Variable0 is never set back to 0, so the second entry condition stays true after the first condition is true once. Add Variable0 = 0 in the second condition when you EnterLong().

                      Please let me know if you have any questions.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by algospoke, Yesterday, 06:40 PM
                      2 responses
                      19 views
                      0 likes
                      Last Post algospoke  
                      Started by ghoul, Today, 06:02 PM
                      3 responses
                      14 views
                      0 likes
                      Last Post NinjaTrader_Manfred  
                      Started by jeronymite, 04-12-2024, 04:26 PM
                      3 responses
                      45 views
                      0 likes
                      Last Post jeronymite  
                      Started by Barry Milan, Yesterday, 10:35 PM
                      7 responses
                      20 views
                      0 likes
                      Last Post NinjaTrader_Manfred  
                      Started by AttiM, 02-14-2024, 05:20 PM
                      10 responses
                      181 views
                      0 likes
                      Last Post jeronymite  
                      Working...
                      X