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 Shansen, 08-30-2019, 10:18 PM
              24 responses
              938 views
              0 likes
              Last Post spwizard  
              Started by Max238, Today, 01:28 AM
              0 responses
              3 views
              0 likes
              Last Post Max238
              by Max238
               
              Started by rocketman7, Today, 01:00 AM
              0 responses
              2 views
              0 likes
              Last Post rocketman7  
              Started by wzgy0920, 04-20-2024, 06:09 PM
              2 responses
              27 views
              0 likes
              Last Post wzgy0920  
              Started by wzgy0920, 02-22-2024, 01:11 AM
              5 responses
              32 views
              0 likes
              Last Post wzgy0920  
              Working...
              X