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

Pull Back Logic Possible?

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

    #16
    Ok I think I am getting close.

    So far I have the right pullback candle formation in tact as the prints are showing correctly.

    However, I am now having trouble with creating logic to only EnterLong()


    How do I create logic to make sure that from the holdValue candle to the candle entry have all had their lows greater than the middle bollinger band?

    if from the holdValue candle low to the candle that triggers the entry have all lows greater than the middle bollinger band and the High[0] is greater than the high of holdValue than it will trigger long.

    **As long as all the candle lows in between the holdvalue and entry candle are above the mid bb.

    I provided a few examples of how to phrase what I need.

    Here is my code now:


    protected override void OnBarUpdate()
    {
    if (CurrentBars[0] < 5)
    return;

    if ((High[4] < High[3])
    && (Low[4] > midbbBull.Middle[4])
    && (Low[3] > midbbBull.Middle[3])
    && (Low[2] > midbbBull.Middle[2])
    && (Low[1] > midbbBull.Middle[1])
    && (High[3] > High[2])
    && (High[3] > High[1]))// pseudo condition, replace with your condition
    {
    holdValue = High[3]; //store the close when the condition was true
    holdBarNumber = CurrentBar; // store the current bar number when the condition was true
    }

    if (holdValue != 0 && holdBarNumber != 0) // check if we have values for the variables
    {
    Print("Close price at last condition was " + holdValue);
    }

    if (High[0] > holdValue)
    {
    EnterLong();
    }

    if (Low[0] < SMA5[0])
    {
    ExitLong();
    }

    Comment


      #17
      Hello dorony,

      Thank you for your response.

      Based on your description that code should do as you wish.

      Please let me know if you have any questions.

      Comment


        #18
        Hey thanks!

        It's not because I need the condition to also say that all bars from holdValue until trigger must have candle lows greater than the middle bollinger band.

        Right now it only has the first four candles with that condition and thats just to confirm a pullback with holding its high value. After the pullback confirms I need it to continue to make sure all candle lows are greater than the middle bollinger band, otherwise holdvalue needs to reset

        Comment


          #19
          Hello dorony,

          Thank you for your response.

          You could add a condition that checks if (Low[0] < midbbBull.Middle[0]) and if so then restart the condition checking. Below is an example that sets the holValue to 0 and checks for that 0 value to act as a switch.
          Code:
          [B]if (holdValue == 0[/B]
          && (High[4] < High[3])
          && (Low[4] > midbbBull.Middle[4])
          && (Low[3] > midbbBull.Middle[3])
          && (Low[2] > midbbBull.Middle[2])
          && (Low[1] > midbbBull.Middle[1])
          && (High[3] > High[2])
          && (High[3] > High[1]))// pseudo condition, replace with your condition
          {
          holdValue = High[3]; //store the close when the condition was true
          }
          
          [B]if (holdValue != 0
          && Low[0] < midbbBull.Middle[0])
          holdValue = 0;[/B]

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by funk10101, Today, 09:43 PM
          0 responses
          6 views
          0 likes
          Last Post funk10101  
          Started by pkefal, 04-11-2024, 07:39 AM
          11 responses
          37 views
          0 likes
          Last Post jeronymite  
          Started by bill2023, Yesterday, 08:51 AM
          8 responses
          44 views
          0 likes
          Last Post bill2023  
          Started by yertle, Today, 08:38 AM
          6 responses
          26 views
          0 likes
          Last Post ryjoga
          by ryjoga
           
          Started by algospoke, Yesterday, 06:40 PM
          2 responses
          24 views
          0 likes
          Last Post algospoke  
          Working...
          X