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

Trade info on chart not working with US stocks but fine on FOREX

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

    Trade info on chart not working with US stocks but fine on FOREX

    Hello,
    This code below works great on I my chart is referencing Forex data. But as soon as I switch to a stock (UPRO), the output always reads "0". What am I missing? (My brokers/feeds are FOREX.com and Interactive Brokers).

    Draw.TextFixed(this, "Position.GetUnrealizedProfitLoss", "Current Gains_"+ Convert.ToString(Position.GetUnrealizedProfitLoss( PerformanceUnit.Currency)), TextPosition.TopLeft);

    #2
    Ya know, I almost always figure it out AFTER I ask you guys. Ha. This works (change in bold):

    Draw.TextFixed(this, "Position.GetUnrealizedProfitLoss", "Open Profit_"+ Convert.ToString(Position.GetUnrealizedProfitLoss( PerformanceUnit.Currency, Close.GetValueAt(CurrentBar))), TextPosition.TopLeft);

    Comment


      #3
      Hello White Fork,

      I would still expect the last price being substituted to work.

      From the help guide:
      "If no double argument is provided in the call, the current (real-time) Last price will be substituted in."


      To confirm Position.GetUnrealizedProfitLoss( PerformanceUnit.Currency) is always producing a 0, even when there is profit or loss in an open position?
      Chelsea B.NinjaTrader Customer Service

      Comment


        #4
        "0", that is correct. On all Stocks and some Currencies depending on the decimal place. (Maybe it's an "int" thing?)

        Comment


          #5
          Hello White Fork,

          I am not able to reproduce this behavior.

          If you follow the exact steps shown in the video are you experiencing different behavior?
          Attached Files
          Chelsea B.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by rbeckmann05, Today, 06:48 PM
          0 responses
          4 views
          0 likes
          Last Post rbeckmann05  
          Started by rhyminkevin, Today, 04:58 PM
          4 responses
          52 views
          0 likes
          Last Post dp8282
          by dp8282
           
          Started by iceman2018, Today, 05:07 PM
          0 responses
          5 views
          0 likes
          Last Post iceman2018  
          Started by lightsun47, Today, 03:51 PM
          0 responses
          8 views
          0 likes
          Last Post lightsun47  
          Started by 00nevest, Today, 02:27 PM
          1 response
          14 views
          0 likes
          Last Post 00nevest  
          Working...
          X