Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Bid/Ask Spread + CurrentBar

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

    Bid/Ask Spread + CurrentBar

    Hey guys, quick question. I entered the code
    Code:
    	
    spread = Math.Abs(GetCurrentAsk() - GetCurrentBid());
    									DrawText("Sell Trig" + CurrentBar, "Sell Trigger: " + Instrument.MasterInstrument.Round2TickSize(sellEntryPrice).ToString(), 1, High[1] + 6 * TickSize, Color.Orange);
    										DrawText("SPread" + CurrentBar, "Spread: " + Instrument.MasterInstrument.Round2TickSize(spread).ToString(), 1, High[1] + 15 * TickSize, Color.Blue);
    Into my indicator. and The "Sell Trig" works as always, just fine. shows Trig at every Signal. but the "Spread" always Shows 0. How can I show what the Spread was at Every Signal occurence? regardless of Strategy or signal. I just want the Spread to show on CurrentBars.

    #2
    Hello ginx10k,

    Thanks for your post.

    If I understand correctly you are looking for the spread in ticks. In that case you would want to change the first line to:

    spread = Math.Abs((GetCurrentAsk() - GetCurrentBid()) / TickSize); // get absolute difference then / TickSize.

    Comment


      #3
      Hey Paul, I just tried this spread = Math.Abs((GetCurrentAsk() - GetCurrentBid()) / TickSize); and it didn't work either. It keeps showing 0. Any suggestions

      Comment


        #4
        Hello ginx10k,

        Thanks for your reply.

        Is spread a double?

        What instrument are you apply this to?

        Comment


          #5
          Code:
          private double spread = Math.Abs((GetCurrentAsk() - GetCurrentBid()) / TickSize);;
          Applied Only to EUR/USD. It Doesn't work for some reason.

          Comment


            #6
            Hello ginx10k,

            Here is what i am using:

            Code:
            if (Historical) return;
            			
            double spread = Math.Abs((GetCurrentAsk() - GetCurrentBid()) / TickSize);
            Print ("Spread:  "+spread +"  ticks: "+Instrument.MasterInstrument.Round2TickSize(spread).ToString());
            Output window results $EURUSD as source):
            Spread: 3.00000000000189 ticks: 3
            Spread: 3.00000000000189 ticks: 3
            Spread: 3.00000000000189 ticks: 3
            Spread: 3.00000000000189 ticks: 3
            Spread: 3.00000000000189 ticks: 3
            Spread: 2.000000000002 ticks: 2
            Spread: 2.000000000002 ticks: 2
            Spread: 2.000000000002 ticks: 2
            Spread: 2.000000000002 ticks: 2
            Spread: 2.000000000002 ticks: 2
            Spread: 2.000000000002 ticks: 2
            Spread: 2.000000000002 ticks: 2
            Spread: 2.000000000002 ticks: 2
            Spread: 3.00000000000189 ticks: 3
            Spread: 3.00000000000189 ticks: 3
            Spread: 3.00000000000189 ticks: 3
            Spread: 3.00000000000189 ticks: 3
            Spread: 2.000000000002 ticks: 2
            Spread: 3.00000000000189 ticks: 3
            Spread: 3.00000000000189 ticks: 3
            Spread: 3.00000000000189 ticks: 3
            Spread: 3.00000000000189 ticks: 3
            Spread: 3.00000000000189 ticks: 3
            Spread: 3.00000000000189 ticks: 3
            Spread: 3.00000000000189 ticks: 3
            Spread: 3.00000000000189 ticks: 3
            Spread: 3.00000000000189 ticks: 3
            Spread: 3.00000000000189 ticks: 3
            Spread: 3.00000000000189 ticks: 3

            Comment


              #7
              Hey Paul, I get that also on Output window. but my original post was stating that I want

              Into my indicator. and The "Sell Trig" works as always, just fine. shows Trig at every Signal. but the "Spread" always Shows 0. How can I show what the Spread was at Every Signal occurence? regardless of Strategy or signal. I just want the Spread to show on CurrentBars.
              Meaning I want to see what the Spread was 10 bars ago. 50 bars ago. No matter how far back ago, just on Every Signal occurrence: example: if(EMA(10) > EMA(20) { enterSignal = true; DrawText("SPread" + CurrentBar, "Spread: " + Instrument.MasterInstrument.Round2TickSize(spread) .ToString(), 1, High[1] + 15 * TickSize, Color.Blue);
              }

              So is it possible to get Historical Spread? that's what I'm after

              Comment


                #8
                Hello ginx10k,

                Thanks for your reply.

                You would not be able to get historical bid/ask information as it is not stored.



                In both cases, on historical look, the close price of the evaluated bar is used.

                Comment


                  #9
                  Is it possible to add some kind of Slippage calculation into an Indicator (Not Strategy), so I can set my own Spread?

                  Comment


                    #10
                    Hello ginx10k,

                    You can take the work done with the spread and instead of printing to the output window send it to the chart using DrawTextFixed() method: http://ninjatrader.com/support/helpG...wtextfixed.htm

                    Comment


                      #11
                      I already have an indicator that does that. I guess can't get it to do what I want. thx anyways

                      Comment


                        #12
                        Originally posted by ginx10k View Post
                        I already have an indicator that does that. I guess can't get it to do what I want. thx anyways
                        Have you tried adding a Bid and an Ask DataSeries, and calculating off those?

                        Comment


                          #13
                          I don't know how to do that. How can you use bid data series. If it doesn't get stored? I would appreciate if you showed me. Thanks.

                          Comment


                            #14
                            Originally posted by ginx10k View Post
                            I don't know how to do that. How can you use bid data series. If it doesn't get stored? I would appreciate if you showed me. Thanks.
                            Here is the reference, with necessary links: http://ninjatrader.com/support/helpG..._ask_serie.htm

                            Comment

                            Latest Posts

                            Collapse

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