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

Help needed for Cumulative profit calculation during backtest

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

    Help needed for Cumulative profit calculation during backtest

    Hello
    I am nearing the end of my strategy development and I would like to test the performance of the strategy by compounding all profits and placing subsequent orders accordingly.

    I have created a double variable and I am adding all realized profits to this variable. I am then converting this double variable to Int and placing the Order(EnterLong only takes Int Values).
    I am also diving my take profit targets into 4 parts. The issue is, that sometimes the strategy holds the remaining order size till close of session and I miss out on a lot of opportunities as a result. As an example,

    say I have a total qty of 19546. Diving it in 4 equal parts of TP gives me 4886. The rounded 1 contract is left and the strategy holds on to it forever. How do I make it place all the remaining contracts on last TP or on the last stop loss?

    tp1=ExitLongLimit(1,true,execution.Order.Filled/4,fib100,"MyTarget","My Entry");
    tp2=ExitLongLimit(1,true,execution.Order.Filled/4,fib50,"MyTarget1","My Entry");
    tp3=ExitLongLimit(1,true,execution.Order.Filled/4,fib618,"MyTarget2","My Entry");
    tp4=ExitLongLimit(1,true,execution.Order.Filled/4,fib764,"MyTarget3","My Entry");

    Thanks

    #2
    Hello MyFirstMillion,

    Thanks for writing in.

    If you do not specify a "fromEntrySignal" parameter, the entire position is exited rendering your strategy flat. This would mean you may have your greatest profit target take the remainder of contracts, by simply using the variation of ExitLongLimit() below:

    Code:
    ExitLongLimit(double limitPrice, string signalName, string fromEntrySignal)
    This variation does not take an order quantity and will exit the remaining number of open contracts. You can find syntax for more variations and usage here: https://ninjatrader.com/support/help...tlonglimit.htm

    The same approach can be used for a stop loss with ExitLongStop(): https://ninjatrader.com/support/help...itlongstop.htm

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

    Comment


      #3
      I will give it a try tonight and let you know if I have problems. Thank you for the quick response. ninja support is the best

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by GwFutures1988, Today, 02:48 PM
      1 response
      5 views
      0 likes
      Last Post NinjaTrader_Clayton  
      Started by ScottWalsh, 04-16-2024, 04:29 PM
      6 responses
      32 views
      0 likes
      Last Post ScottWalsh  
      Started by frankthearm, Today, 09:08 AM
      10 responses
      36 views
      0 likes
      Last Post frankthearm  
      Started by mmenigma, Today, 02:22 PM
      1 response
      4 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by NRITV, Today, 01:15 PM
      2 responses
      10 views
      0 likes
      Last Post NRITV
      by NRITV
       
      Working...
      X