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

GetCurrentBid and GetCurrent Function

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

    GetCurrentBid and GetCurrent Function

    Hi,

    I am looking to compute the spread price between 2 instruments say ZN and XT. In my script I used the following to calculate the bid-ask for the spreads between these 2 instruments.

    AskSpreadPx = GetCurrentAsk(0) - GetCurrentBid(1);
    Current Ask Price of ZN - Current Bid Price of XT

    BidSpreadPx = GetCurrentBid(0) - GetCurrentAsk(1);
    Current Bid Price of ZN - Current Ask Price of XT

    I am doing or interpreting the above correctly? I did a run of on my Interactive Brokers paper account and found that when I output the AskSpreadPx and BidSpreadPx, they are all the same. A further look reveals that GetCurrentAsk(0) is the same as GetCurrentBid(0) and GetCurrentBid(1) is GetCurrentAsk(1)?? Isn't this function support to get me the bid and ask for the respective instruments?

    Appreciate yr help thanks.

    EG

    #2
    Hello EG,

    Thank you for your post.

    Are you using the GetCurrentBid and Ask in the OnBarUpdate() or OnMarketData()?

    If you use a different instrument such as ES, do you get the different spread values?

    Are you looking at these values on a historical process or real time feed?
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Hi Cal,

      I am using OnBarUpdate. It's the same with other instruments. Spread values are still the same. I am running this on a realtime feed using Interactive Broker's paper account.

      Thanks.
      EG

      Comment


        #4
        EG,

        What build of TWS are you using? Help -> About Traders Workstation

        Can you share with me your script, so I can test this on my end?
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          I am using TWS Build 944.3, Apr 1, 2014 1:29:41 PM.

          Attached my script here. Thanks.
          Attached Files

          Comment


            #6
            EG,

            Can you show me your Prints to the Output?

            I am not able to replicate the issue on my end. Note that I am using the Edemo account with IB and tested with a live account on IB
            Cal H.NinjaTrader Customer Service

            Comment


              #7
              Cal, here's the output file. on each barupdate, I print the following according to the extracted portion of my script below. I am expecting each pair of consecutive prints to be different according to the script. But they turn out to be the same.

              Print(GetCurrentAsk(0) + " " + GetCurrentBid(1));
              Print(GetCurrentBid(0) + " " + GetCurrentAsk(1));
              Attached Files

              Comment


                #8
                EG,

                Please send me a note to support by going to Help -> Mail to Support
                Put Attn Cal in the subject and reference this thread in the body.

                I would like to get a remote session setup
                Cal H.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by gentlebenthebear, Today, 01:30 AM
                2 responses
                13 views
                0 likes
                Last Post gentlebenthebear  
                Started by Kaledus, Today, 01:29 PM
                2 responses
                7 views
                0 likes
                Last Post Kaledus
                by Kaledus
                 
                Started by frankthearm, Yesterday, 09:08 AM
                13 responses
                45 views
                0 likes
                Last Post frankthearm  
                Started by PaulMohn, Today, 12:36 PM
                2 responses
                16 views
                0 likes
                Last Post PaulMohn  
                Started by Conceptzx, 10-11-2022, 06:38 AM
                2 responses
                56 views
                0 likes
                Last Post PhillT
                by PhillT
                 
                Working...
                X