Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
I need code for Indicator to display Spread
Collapse
X
-
I need code for Indicator to display Spread
I trade FX and don't use the DOM or FX Pro. I trade using ChartTrader - which displays Ask and Bid numbers but not the Spread (Ask - Bid). So I have to mentally subtract the two, which are changing all the time. I would like to write an Indicator that simply subtracts Bid from Ask every tick and display the number on the Chart. Can anyone give me the few lines of code this would need. I know how to create the Indicator but the specific commands for this task would be very time consuming for a non-programmer to delve into, even though it probably only needs a few lines. Or just point me in the right direction. Thanks in advance for any help. -
Hello,
Thank you for your note.
This request was simple enough to just create instead of point you in right direction. You will want to paste this code into a script you create do to this.
DrawTextFixed("Spread", "Spread : " + Instrument.MasterInstrument.Round2TickSize((GetCur rentBid() - GetCurrentAsk())) , TextPosition.BottomRight);
Let me know if I can be of further assistance.BrettNinjaTrader Product Management
-
-
Got it working. It's exactly what I needed. I moved it to bottom left since I have a Bar Timer at bottom right. Also switched it around to (Ask - Bid) since it was giving me a negative number, and multiplied that by 10,000 so I get "Spread: 1.8" rather than "Spread: 0.00018" so it's easier to read.
Thanks again Brett. You likely saved me a whole weekend since I don't know the commands or syntax. Your one line plus NT's simple/robust way of integrating scripts did the trick.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
603 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
349 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
104 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
560 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
560 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment