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);
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!
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
NinjaTrader
Bid/Ask Spread + CurrentBar
Collapse
X
-
Bid/Ask Spread + CurrentBar
Hey guys, quick question. I entered the codeCode:Tags: None
-
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.Paul H.NinjaTrader Customer Service
-
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());
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: 3Paul H.NinjaTrader Customer Service
Comment
-
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.
}
So is it possible to get Historical Spread? that's what I'm after
Comment
-
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.htmPaul H.NinjaTrader Customer Service
Comment
-
Originally posted by ginx10k View PostI 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
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by MacDad, 02-25-2024, 11:48 PM
|
7 responses
158 views
0 likes
|
Last Post Today, 10:23 PM | ||
Started by Belfortbucks, Today, 09:29 PM
|
0 responses
6 views
0 likes
|
Last Post
by Belfortbucks
Today, 09:29 PM
|
||
Started by zstheorist, Today, 07:52 PM
|
0 responses
7 views
0 likes
|
Last Post
by zstheorist
Today, 07:52 PM
|
||
Started by pmachiraju, 11-01-2023, 04:46 AM
|
8 responses
151 views
0 likes
|
Last Post
by rehmans
Today, 06:44 PM
|
||
Started by mattbsea, Today, 05:44 PM
|
0 responses
6 views
0 likes
|
Last Post
by mattbsea
Today, 05:44 PM
|
Comment