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 andrewtrades, Today, 04:57 PM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by chbruno, Today, 04:10 PM
        0 responses
        6 views
        0 likes
        Last Post chbruno
        by chbruno
         
        Started by josh18955, 03-25-2023, 11:16 AM
        6 responses
        436 views
        0 likes
        Last Post Delerium  
        Started by FAQtrader, Today, 03:35 PM
        0 responses
        7 views
        0 likes
        Last Post FAQtrader  
        Started by rocketman7, Today, 09:41 AM
        5 responses
        19 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Working...
        X