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.

    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 Kaledus, Today, 01:29 PM
        4 responses
        11 views
        0 likes
        Last Post Kaledus
        by Kaledus
         
        Started by alifarahani, Today, 09:40 AM
        5 responses
        22 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by gentlebenthebear, Today, 01:30 AM
        3 responses
        16 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by PhillT, Today, 02:16 PM
        2 responses
        7 views
        0 likes
        Last Post PhillT
        by PhillT
         
        Started by frankthearm, Yesterday, 09:08 AM
        14 responses
        47 views
        0 likes
        Last Post NinjaTrader_Clayton  
        Working...
        X