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

I need code for Indicator to display Spread

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

    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.

    #2
    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

    Comment


      #3
      Thanks

      Brett, thanks so much for your prompt reply and code. I'll give it a go.

      Comment


        #4
        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 corman, Today, 02:02 PM
        1 response
        10 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by Uregon, Today, 12:12 PM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_Kate  
        Started by kerplunk1899, Today, 10:03 AM
        1 response
        19 views
        0 likes
        Last Post NinjaTrader_Kate  
        Started by rexsole, Today, 10:20 AM
        1 response
        12 views
        0 likes
        Last Post NinjaTrader_RyanS  
        Started by pjsmith, Today, 03:01 AM
        6 responses
        18 views
        0 likes
        Last Post bltdavid  
        Working...
        X