Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

GetCurrentAsk() returns wrong price

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

    GetCurrentAsk() returns wrong price

    I have a strategy that starts with the following lines:

    Code:
     
    [FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]protected [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]override [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] OnBarUpdate()[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]{[/FONT][/SIZE]
    [SIZE=2][FONT=Courier New]   DrawHorizontalLine([/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"Bid"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2], GetCurrentBid(), Color.Green, DashStyle.Dot, [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]);[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]   DrawHorizontalLine([/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"Ask"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2], GetCurrentAsk(), Color.Red, DashStyle.Dot, [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]);[/SIZE][/FONT][/SIZE][/FONT]
    [FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]   ...[/SIZE][/FONT]
    [/SIZE][/FONT]
    When I attach this strategy on a chart and run it with the Sim101 account everything works as expected, two nice lines at the ask and bid price. But when I run this strategy on my live account, both lines are drawn on the bid price.

    I've tested several options and it's definitely only the used account that makes the difference.

    Regards,
    Daniel

    #2
    Addition: The lines are drawn correct when I use the same code in an indicator. Anyway, this is a really evil bug when strategies don't know the actual ask price.

    Comment


      #3
      Daniel, thanks for the post - are you testing this on live (realtime) data?

      Comment


        #4
        Hello Bertrand,

        yes, it's realtime data from GAIN. But Live and Sim101 account are using the same connection, so the data seems to be correct. Also the SuperDOM and FX Pro have no problem to display the actual ask price.

        Regards,
        Daniel

        Comment


          #5
          Please try with a strategy with only those two lines of code and no other logic. Suggest you also try printing the values of bid/ask so you can assess the values directly.
          Josh P.NinjaTrader Customer Service

          Comment


            #6
            Ok, that works. I'll check the output values for other strategy later, right now I can't modify it for Live account.

            Comment


              #7
              Hm, strange, the output window shows the correct values, so the bug only occurs when I try to draw lines in my strategy. It's still a bug, but it's ok, these lines should be part of an indicator.

              Comment


                #8
                Daniel, I can't reproduce here, tried with a sample like this and works well here -

                Code:
                 
                DrawLine("ask", 10, GetCurrentAsk(), 0, GetCurrentAsk(), Color.Blue, DashStyle.Dot, 2);
                DrawLine("bid", 10, GetCurrentBid(), 0, GetCurrentBid(), Color.Red, DashStyle.Dot, 2);

                Comment


                  #9
                  Have you tried it with a live account? In the best case a Gain live account?

                  I tried to reproduce it in another strategy and guess what I got: Nothing This time is none of the lines visible. Anyway, the methods seem to return the correct values (confirmed by output window). If there is a bug, then there's just anything wrong with the line functions, but that's really nothing I care about.

                  Regards,
                  Daniel

                  Comment


                    #10
                    Daniel, dont' have access to a Gain one, but tried with my MBT live account - working as expected no different noticed if sim101 or the live account where the strategy was executing to, printouts fine as well. If you're fine with it working in the indicator, then just leave as is - otherwise I would suggest reinstalling your .NET framework and the account connection fresh and retest.

                    Comment

                    Latest Posts

                    Collapse

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