Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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?
      BertrandNinjaTrader Customer Service

      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);
                BertrandNinjaTrader Customer Service

                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.
                    BertrandNinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Austiner87, Today, 03:42 PM
                    1 response
                    14 views
                    0 likes
                    Last Post NinjaTrader_Manfred  
                    Started by cshox, Today, 11:11 AM
                    2 responses
                    14 views
                    0 likes
                    Last Post cshox
                    by cshox
                     
                    Started by algospoke, Today, 06:53 PM
                    0 responses
                    5 views
                    0 likes
                    Last Post algospoke  
                    Started by mlprice12, 12-21-2021, 04:55 PM
                    3 responses
                    293 views
                    0 likes
                    Last Post paypachaysa  
                    Started by lorem, 04-25-2024, 09:18 AM
                    20 responses
                    85 views
                    0 likes
                    Last Post lorem
                    by lorem
                     
                    Working...
                    X