Announcement

Collapse
No announcement yet.

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 NullPointStrategies, Today, 05:17 AM
          0 responses
          44 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          124 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          65 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          42 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          46 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X