Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Pullback trading strategy help

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

    Pullback trading strategy help

    Hello,
    I'm new to programming.
    I'm attempting to develop a strategy that sends signals on trend pullbacks.
    My main logic is that i can buy or sell on the first and second pullback of the trend, but stay out on the 3rd and wait for a new trend.
    I want to add the following to my code:

    If pullback is detected based on my code. count it as 1 and trade
    if pullback 2 is detected. trade
    if pullback 3 is detected. return to the beginning.

    Can someone help?

    Thank you

    #2
    Hello,

    Thank you for the post.

    Could you tell me, are you trying to make this using the strategy builder or with manual coding? I could provide better details knowing how you will be creating the script.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hello,

      I am attempting to do this with manual coding.
      I already have the code for identifying a possible pullback.
      I just need that block of code to be recognized and identified as pullback one, two, three, etc.

      Thank You

      Comment


        #4
        Hello,

        Thank you for the details.

        If you already have the conditions for the pullbacks, the majority of the work would be out of the way.

        I just need that block of code to be recognized and identified as pullback one, two, three, etc.
        Are you saying that you have the pullback detection but now need to count each time this happens, and if it does happen, depending on the count do a specific action?



        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          yes, that is correct

          Comment


            #6
            Hello,

            Thank you for confirming.

            In the current logic you have, you could implement a counter and a reset to return to the beginning. In the detection logic where you reach the conclusion that this may be a pullback, you could increment a variable:

            Code:
            private int trackingVariable = 0;
            
            protected override void OnBarUpdate()
            {
            //logic for detection
                if(some condition)  // is a pullback
                {
                    trackingVariable++;
                    if(trackingVariable == 3) trackingVariable = 0;
                    if(trackingVariable == 1)
                    {
            
                    } 
                    else if(trackingVariable == 2)
                    {
            
                    }
                }
            }
            This kind of logic would just increment a int variable when detected, if the int equals 3, it is reset to 0. After the increment/reset a condition is used to check if the pullback was 1 or 2, 3 is not reached because it resets to 0.

            I look forward to being of further assistance.
            JesseNinjaTrader Customer Service

            Comment


              #7
              Thank you so much for your prompt assistance.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by chbruno, Today, 04:10 PM
              0 responses
              3 views
              0 likes
              Last Post chbruno
              by chbruno
               
              Started by josh18955, 03-25-2023, 11:16 AM
              6 responses
              436 views
              0 likes
              Last Post Delerium  
              Started by FAQtrader, Today, 03:35 PM
              0 responses
              6 views
              0 likes
              Last Post FAQtrader  
              Started by rocketman7, Today, 09:41 AM
              5 responses
              19 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by frslvr, 04-11-2024, 07:26 AM
              9 responses
              127 views
              1 like
              Last Post caryc123  
              Working...
              X