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 Perr0Grande, Today, 08:16 PM
          0 responses
          2 views
          0 likes
          Last Post Perr0Grande  
          Started by elderan, Today, 08:03 PM
          0 responses
          5 views
          0 likes
          Last Post elderan
          by elderan
           
          Started by algospoke, Today, 06:40 PM
          0 responses
          10 views
          0 likes
          Last Post algospoke  
          Started by maybeimnotrader, Today, 05:46 PM
          0 responses
          12 views
          0 likes
          Last Post maybeimnotrader  
          Started by quantismo, Today, 05:13 PM
          0 responses
          7 views
          0 likes
          Last Post quantismo  
          Working...
          X