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/Bid

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

    GetCurrentAsk/Bid

    Hello,

    I want to ask please if GetCurrentAsk()/GetCurrentBid() is OK when using different dataseries in a script strategy so that its always "the current ask" or "the current bid"
    Or is it to handle like prices with eg Highs[2][0]....

    I want to use it like
    if(Highs[1][0] >= RSIBands1.RSIBandUpper[0])
    {SetProfitTarget("dtLa", CalculationMode.Price, GetCurrentBid());}

    Where the Highs[1][0] is from the 1-Tick-Datseries that has to be added anyhow because of using OF-Delta and the RSIBands I want to have from eg 3Range Dataseries.

    New question when testing now is why there is no target placed from this code here please?

    Thank you!
    Tony
    Last edited by tonynt; 06-16-2020, 09:13 AM. Reason: typo

    #2
    Hello tonynt,

    GetCurrentAsk(int barsSeriesIndex) has a overload signature with a barsSeresIndex parameter if you need to specify which bar series you are wanting the current snapshot from.



    If the profit target did not appear, it may not have had a valid price at the moment of submission.

    Use prints and TraceOrders to understand the behavior of the strategy.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello ChelseaB,

      thank you for your reply. In the meantime I change the logic using the Donchian with
      DonchianChannel1 = DonchianChannel(Closes[2], 21);

      and in OnBarUpdate I have
      if(BarsInProgress==2)
      {
      if(Highs[2][0] >= DonchianChannel1.Upper[1] && Closes[2][0]<Opens[2][0])
      SetProfitTarget("djL1a", CalculationMode.Price, GetCurrentBid());

      But in the attached screenshot you can see that the target was before that condition was true because we were below the Donchian and not above.

      Why might the target have been put there please?

      Thank you!
      Tony

      Attached Files

      Comment


        #4
        Hello Tony,

        The target was likely put there because that was the price it was submitted to. (Or this is this historical data with no intra-bar granularity)

        The condition was true because the high of the 3rd series is greater than the DonchianChannel1.Upper of the previous bar while the close of the 3rd series is less than the open of the second series.

        Print the values to confirm this.

        Are you setting the profit target before placing the order?

        What is the output from the prints telling you?

        What is the GetCurrentBid() at the time of order submission?
        What is the order price from OnOrderUpdate()?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hello ChelseaB,

          thank you for your reply. Sorry I dont understand why condition is true. And why you are referring to a dataseries 3 and 2. There is only dataseries[2] in the modified code with Donchian. I attach a screenshot with different coloring, upper Donchian is yellow and this is higher then the high of the bar where the profit target is triggered. So why is this high greater than the DonchianChannelUpper of the previous bar (the value I have made visible with 3110 - little different so that the blue is not hiding the Donchian. And the ellipse shows the high with price 3109.

          Total confusion, why is condition true?

          Thank you!
          Tony
          Attached Files

          Comment


            #6
            Hello Tony,

            BarsInProgress 0 (or Bar series index 0) is the first series and this is also the primary series.
            BarsInProgress 1 (or Bars series index 1) is the second series. This would be added with AddDataSeries().
            BarsInProgress 2 (or Bars series index 2) is the third series. This would also be added with AddDataSeries().

            If you are using Highs[2][0], this would be the high of the third series, starting with 0.

            Have you added prints to your script?

            Did you watch the video on using prints?

            Are you printing the the time of the bar, the high of the third series, the indicator plot value, and the close to the output window?

            Please save the output from the output window to a file (right-click the output window > select Save As) and I will be happy to assist you with analyzing the output.

            As a tip, do not use visual indications on a chart unless you are just looking for chart marker placed with the condition is true. Use the output only.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Hello ChelseaB,

              yes of course [2] is the third series. Why you write in #4 "...while the close of the 3rd series is less than the open of the second series." Its hard for me in english, you want to confuse me even more? Why you write "...second series"? I only have [2] (which is 3rd as we agree).

              The High of the Bar shown in the screenshot above is way below the Donchian of the bar before, its obviously below few ticks.


              Thank you!
              Tony
              Last edited by tonynt; 06-16-2020, 12:50 PM. Reason: add info

              Comment


                #8
                Hello Tony,

                I will refer to the BarsInProgress instead of referring to the series to prevent confusion.

                Please let me know if you would like assistance analyzing the output from prints and TraceOrders to understand the behavior.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Hello ChelseaB,

                  thank you for your reply. I´m confused as you write about 2 dataseries. So yes, I´d like assistance analyzing the output from prints and TraceOrders to understand what you mean.

                  Thank you!
                  Tony

                  Comment


                    #10
                    Hello Tony,

                    From my understanding you have three data series. BarsInProgress 2 would be the third data series.

                    May I have the output from the prints so that I may assist you in understanding the output?(As shown in the video)
                    Please attach this with you next post.

                    Have you enabled trace orders?

                    I look forward to your reply.
                    Chelsea B.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by zstheorist, Today, 07:52 PM
                    0 responses
                    7 views
                    0 likes
                    Last Post zstheorist  
                    Started by pmachiraju, 11-01-2023, 04:46 AM
                    8 responses
                    150 views
                    0 likes
                    Last Post rehmans
                    by rehmans
                     
                    Started by mattbsea, Today, 05:44 PM
                    0 responses
                    6 views
                    0 likes
                    Last Post mattbsea  
                    Started by RideMe, 04-07-2024, 04:54 PM
                    6 responses
                    33 views
                    0 likes
                    Last Post RideMe
                    by RideMe
                     
                    Started by tkaboris, Today, 05:13 PM
                    0 responses
                    6 views
                    0 likes
                    Last Post tkaboris  
                    Working...
                    X