Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Open bar data diferent from chart data

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

    Open bar data diferent from chart data

    Hi All and happy new year!!!

    I hope everything is well for you.


    My question is about a indicator I have, this indicator print open price of first bar from MES03-23 cash time in Europe it is 15:30. the problem I have found today is that the price printed is 3852,50 but the chart I use show 3861.50. Can someone to help me to understand this behaivour???

    My code:
    protected override void OnBarUpdate()
    {
    if (ToDay(DateTime.Now )== ToDay(Time[0]) & ToTime(Time[0]) > ToTime(15, 30, 00) )
    {

    // Calculate the bars ago value
    int barsAgo0 = CurrentBar - Bars.GetBar(new DateTime(2023, 01, 05, 15, 30, 0));

    int barsAgo1 = CurrentBar - Bars.GetBar(new DateTime(2023, 01, 05, 15, 30, 1));


    Print("The Open price on the 15:30:00 bar was: " + Open[barsAgo0].ToString());
    Print("The Open price on the 15:30:01 AM bar was: " + Open[barsAgo1].ToString());

    }

    else
    {
    return;

    }

    }​

    screenshot of output:


    Click image for larger version  Name:	image.png Views:	0 Size:	3.9 KB ID:	1230110

    screen shot chart TF 1s: Blue line in the top is over 3860, exactly 3861,5

    Click image for larger version  Name:	image.png Views:	0 Size:	13.2 KB ID:	1230111


    Best Regards.

    #2
    Hi again

    Sorry I have attached a chart of cash market, below I am adding a new one without this time gap, I am remarking by rectangle the bars from 15:29:59 to 15:30:01 ( three bars into rectangle), and below you can see the orange line drawed from code at same time is printed in output. Can I tell to me the rigth open price?


    Click image for larger version

Name:	image.png
Views:	96
Size:	10.5 KB
ID:	1230114

    I hope some one can help to me with tihs.


    Best Regards.​

    Comment


      #3
      Hello J2512,

      From the code you provided you are missing an & symbol, if your condition in your code only has a single & its likely not equating as you expect it to. You need to do && in conditions.

      I would suggest testing that first and if that is not the issue you may need to use Print statements in your code to check when the condition is becoming true to make sure its working right.

      Comment


        #4
        Hi Jesse

        Thank you so much for your support!!!


        best Regards.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        88 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        48 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        30 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        34 views
        0 likes
        Last Post TheRealMorford  
        Started by Mindset, 02-28-2026, 06:16 AM
        0 responses
        68 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Working...
        X