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 sjsj2732, Yesterday, 04:31 AM
        0 responses
        27 views
        0 likes
        Last Post sjsj2732  
        Started by NullPointStrategies, 03-13-2026, 05:17 AM
        0 responses
        283 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        280 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        131 views
        1 like
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        90 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Working...
        X