• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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.
    Patrick H.NinjaTrader Customer Service

    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
          Patrick H.NinjaTrader Customer Service

          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.
                      Patrick H.NinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by tonynt, Today, 02:48 AM
                      0 responses
                      5 views
                      0 likes
                      Last Post tonynt
                      by tonynt
                       
                      Started by cls71, Today, 02:11 AM
                      2 responses
                      11 views
                      0 likes
                      Last Post NinjaTrader_ChrisSch  
                      Started by RB104, Today, 01:52 AM
                      0 responses
                      4 views
                      0 likes
                      Last Post RB104
                      by RB104
                       
                      Started by reks13, Today, 01:52 AM
                      0 responses
                      5 views
                      0 likes
                      Last Post reks13
                      by reks13
                       
                      Started by raffu, Today, 01:35 AM
                      1 response
                      12 views
                      0 likes
                      Last Post raffu
                      by raffu
                       
                      Working...
                      X