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
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.
-
-
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 Kaledus, Today, 01:29 PM
|
4 responses
11 views
0 likes
|
Last Post
by Kaledus
Today, 02:52 PM
|
||
Started by alifarahani, Today, 09:40 AM
|
5 responses
22 views
0 likes
|
Last Post Today, 02:53 PM | ||
Is it possible to have a drawing, such as a line, cycle through different colors?
by gentlebenthebear
Started by gentlebenthebear, Today, 01:30 AM
|
3 responses
16 views
0 likes
|
Last Post Today, 02:41 PM | ||
Started by PhillT, Today, 02:16 PM
|
2 responses
7 views
0 likes
|
Last Post
by PhillT
Today, 02:33 PM
|
||
Started by frankthearm, Yesterday, 09:08 AM
|
14 responses
47 views
0 likes
|
Last Post Today, 02:19 PM |
Comment