Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Draw in the next bar [-1]

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

    Draw in the next bar [-1]

    Hi.
    I have a query, I have an indicator that is working.
    And mark the points in the table.
    What I need is that when you start the next bar, also place the point at the same price level.
    Since "Sells[-1]" can not be placed.
    I do not know how to do it.

    Thanks.





    protected override void OnBarUpdate()
    {

    if (CurrentBar <3)
    return;


    {
    if ((Close[1] > Open[1])&&(Close[0] < Open[0]))
    {
    Sells[0] = Close[0]-(2*TickSize);
    }

    else if ((Close[1] < Open[1])&&(Close[0] > Open[0]))
    {
    Buys[0] = Close[0]+(2*TickSize);
    }
    }
    }









    #2
    Hello iradielt,

    Thanks for your post.

    Prior to your conditions that conditionally set the current bar of sells and buys, you can copy the previous bar values.

    protected override void OnBarUpdate()
    {

    if (CurrentBar <3)
    return;

    Sells[0] = Sells[1]; // copy previous bar to current bar
    Buys[0] = Buys[1]; // copy previous bar to current bar

    {
    if ((Close[1] > Open[1])&&(Close[0] < Open[0]))
    {
    Sells[0] = Close[0]-(2*TickSize); // if conditions are true write new value into the current bar of Sells
    }

    else if ((Close[1] < Open[1])&&(Close[0] > Open[0]))
    {
    Buys[0] = Close[0]+(2*TickSize); // if conditions are true write new value into the current bar of Buys
    }
    }
    }


    Comment


      #3
      Thanks for your reply.
      And this how can I do it?
      He has some example of that.
      I do not understand what I should add to it.

      Comment


        #4
        Hello iradielt,

        Thanks for your reply.

        The code I added to your code example would keep the last used sells or buys until your conditions write a new sells or buys value.

        This is the code lines I added:
        Sells[0] = Sells[1]; // copy previous bar to current bar
        Buys[0] = Buys[1]; // copy previous bar to current bar

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        562 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        325 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        547 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        547 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X