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:	74
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.
      JesseNinjaTrader Customer Service

      Comment


        #4
        Hi Jesse

        Thank you so much for your support!!!


        best Regards.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by asd32, Today, 11:45 AM
        0 responses
        1 view
        0 likes
        Last Post asd32
        by asd32
         
        Started by tkaboris, Today, 11:09 AM
        1 response
        3 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by marco231, 03-20-2024, 03:56 PM
        5 responses
        155 views
        0 likes
        Last Post bnoisette  
        Started by tonynt, Today, 08:05 AM
        2 responses
        17 views
        0 likes
        Last Post tonynt
        by tonynt
         
        Started by victor68133, Today, 07:50 AM
        4 responses
        26 views
        0 likes
        Last Post backtester831  
        Working...
        X