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

Strategy Performance - Wrong profit values?

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

    Strategy Performance - Wrong profit values?

    Hi,

    I'm testing an automated strategy and have some issues with the Strategy Performance window: all the values in the Profit column seem to be off.

    I attached a screenshot with a sample trade.

    The scenario is simple. Assuming a $10,000 account, I want to risk 1% of my account on a trade, so $100 / trade.

    The strategy took a long trade on USDJPY:
    Quantity: 80,557
    Entry price: 109.113
    Exit price: 108.978

    So basically I had a 13.5 pip stop.

    I attached another screenshot of an online position sizing calculator.
    As you can see, in order to risk $100 on a trade, with a 13.5 pip stop and current USDJPY ask price of 109.113, position size should be 80,824 units.
    I risked even less on the trade: 80,557 units.

    So I expected to risk a $100 on the trade (or even less), but the Strategy Performance window shows a loss of $108.75. I don't understand where this came from, or how it's calculated.

    What am I missing here?

    Thanks,
    Adam
    Attached Files

    #2
    Hello sportal,

    Thanks for your post.

    The calculation will involve [(Price Entered * Quantity) - (Price Exited * Quantity)] * Point value.

    For example, you had entered at 109.113 with a quantity of 80557. (8,789,815.941)
    You had exited at 108.978. (108.978 * 80557 = 8,778,940.746)

    Entry minus Exit = -10875.195

    Multiplying this by the Point Value will give us the PnL. Since the base pair is Yen, the Point Value is 0.01.

    We are then left with 108.75 with the remainder rounded off for the loss.

    Please let me know if you have any additional questions.
    JimNinjaTrader Customer Service

    Comment


      #3
      Hi Jim,

      Thanks for your reply.

      The problem is that your formula doesn't calculate with USD. It calculates with the quote currency (JPY in this case).

      I attached two new screenshots. If you look at the first screenshot, you can see that I put all the parameters into a calculator and it shows that I should have lost around $97.7 on the trade.

      Now take a look at the second screenshot. All I changed is that I switched the account currency to JPY and put in 10875 JPY as my risk, the result is the same.

      So all your formula does is that it calculates the loss in JPY (which is 10875 JPY) and multiplies it by 0.01, which won't give me the actual loss in USD.

      So the Strategy Performance window shows all the profit and loss in terms of the quote currency, not in the currency of the account (USD). All other analysis and statistics is probably off because of this.

      Could you please fix this?

      Thanks,
      Adam
      Attached Files

      Comment


        #4
        Hello sportal,

        I have received your message. I have not been able to return to this inquiry but will be able to during our office hours tomorrow.

        Thanks for your patience.
        JimNinjaTrader Customer Service

        Comment


          #5
          Hello sportal,

          Thanks for your patience.

          We have two different kinds of performance reports for strategies. Historical and Realtime. Trades that are made with Realtime data will have the PnL converted using the Account denomination specified when configuring the account. (Control Center > Accounts Tab > Right Click Account > Edit Account.) Trades with historical data will not have context to the conversion rate, so historical performance reported will only show PnL in terms of the quote currency. Realtime strategy performance reports will display PnL in terms of Account denomination.

          This is the general case for trades generated with realtime data and those generated with historical data. Historical trades will not have the currency conversion.

          There is one final note regarding currency conversion for Interactive Brokers that I'll include from our help guide.

          Interactive Brokers reports forex trades in the instrument currency, not the account currency, without commissions applied. So, forex trades are not applied to Realized PnL.

          Source: https://ninjatrader.com/support/help...TheAccountsTab


          You can set up a test for this by creating a simple script like the following and testing it with the playback connection.

          Code:
          protected override void OnBarUpdate()
          {
              if (State == State.Historical)
                  return;
          
              if(Position.MarketPosition == MarketPosition.Flat)
                  EnterLong(10000);
              if(Position.MarketPosition == MarketPosition.Long && Close[0] < Position.AveragePrice - 2)
                  ExitLong();
          }
          1. Download Market Replay data for USDJPY
          2. Accounts Tab > Edit the Sim101 account to use an Account Denomination of USD. Reset the account to apply changes
          3. Restart NinjaTrader
          4. Connect to Playback
          5. Open a chart and enable the strategy.
          6. Start Playback at MAX
          This will test what results would be expected with realtime trades. Take a screenshot of the performance report.

          Now let's see what the strategy will do with historical data.
          1. Edit the strategy to comment out the if (State == State.Historical) check.
          2. Rewind playback
          3. Reload the strategy and enable it (Do not start playback)
          4. Take a screenshot of the historical performance report.
          Now, you may repeat these steps making sure that you set the Sim101 account denomination to another currency. This will change the account denomination of the Playback Connection. After testing both realtime and historical tests, you will see the same trades generated and the same PnL generated for historical trades, but realtime trades will use the conversion rate for the account denomination.

          Please let me know if I can be of further assistance.
          JimNinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by traderqz, Today, 12:06 AM
          10 responses
          18 views
          0 likes
          Last Post traderqz  
          Started by algospoke, 04-17-2024, 06:40 PM
          5 responses
          46 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by arvidvanstaey, Today, 02:19 PM
          1 response
          6 views
          0 likes
          Last Post NinjaTrader_Zachary  
          Started by mmckinnm, Today, 01:34 PM
          3 responses
          5 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by f.saeidi, Today, 01:32 PM
          2 responses
          9 views
          0 likes
          Last Post f.saeidi  
          Working...
          X