• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Simple Price and Spead Indicator

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

    Simple Price and Spead Indicator

    Hello everyone, I couldn't find this simple indicator anywhere, so I figured I create it for myself. I just wanted to create a simple indicator that displays price and spread on the chart. I trade forex and my broker is a five digit broker. The price code is quite simple, it's

    double price = GetCurrentBid();

    When I display it on my chart, it displays but for example if price is 1.83700 it will display price as 1.837.

    1. How do I keep the price as a 5 digit number?
    2. On the weekend, the price doesn't display because I guess it can't get a value because the market is closed. Is there a way to display the last price?
    3. I only trade forex, for now, but I can I plan on trading futures. Is the spread on the ES, for example, the same as forex, ask-bid?

    Thank you for taking the time out to read this. Hopefully someone could help me. I haven't really programmed in over 10 years so I'm kind of rusty.

    #2
    Hello Johncolavito,

    Thank you for your post.

    I would try Math.Round(double, int32)

    Code:
    Math.Round(Close[0], 5);
    Unless, there is real time data coming in, Close[0] will bring up the last traded price.

    Yes, this is how spread is calculated.
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      I apologize for the delay in response. I tried it today after the market opened. It doesn't update until it receives tick data. However, I tried what was recommended and unfortunately, it didn't work. I am a beginner when it comes to c# but here is the code I tried. I'm sure i'm coding it wrong.

      DrawTextFixed("price", (Math.Round(price,5).ToString()),TextPosition.TopR ight, Color.White, new Font("Arial", 18), Color.Transparent, Color.Empty, 3);

      Comment


        #4
        John, thanks for the reply. For the formatting you could force certain formattings through the ToString() method directly - http://www.ninjatrader.com/support/f...ead.php?t=3823

        i.e. for your case try working with -

        DrawTextFixed("price", (Math.Round(price,5).ToString("N5")),TextPosition.TopRight, Color.White, new Font("Arial", 18), Color.Transparent, Color.Empty, 3);
        BertrandNinjaTrader Customer Service

        Comment


          #5
          That worked perfectly! Thanks!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by frankduc, Today, 08:12 AM
          0 responses
          1 view
          0 likes
          Last Post frankduc  
          Started by jertrade, Today, 08:10 AM
          1 response
          2 views
          0 likes
          Last Post jertrade  
          Started by iq200, Today, 08:05 AM
          0 responses
          1 view
          0 likes
          Last Post iq200
          by iq200
           
          Started by frantic, Today, 06:37 AM
          1 response
          9 views
          0 likes
          Last Post NinjaTrader_PatrickG  
          Started by bouncetherubble, Yesterday, 06:56 PM
          1 response
          14 views
          0 likes
          Last Post NinjaTrader_ChristopherS  
          Working...
          X