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 Mindset, 04-21-2026, 06:46 AM
        0 responses
        44 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        54 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        34 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by cmoran13, 04-16-2026, 01:02 PM
        0 responses
        95 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        57 views
        0 likes
        Last Post PaulMohn  
        Working...
        X