Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Martingale System still possible?

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

    Martingale System still possible?

    In other forum threads, I see an old discussion about implementing the Martingale system One suggestion was to use

    (Performance.AllTrades[Performance.AllTrades.Count - 1].ProfitCurrency

    I got compile time errors with this, but can compile if I use "SystemPerformance". When I go to use the code however, I get a new error in the log. My question is, has the object model been deprecated to make Martingale logic no longer possible?

    #2
    Hello go2toa,

    Thank you for your post.

    Likely you are looking at NinjaTrader 7 code that just needs to converted into NinjaTrader 8. What is the exact error you are getting the log?

    Below I am including a link to a list of the code breaking changes from NT7 to NT8.
    http://ninjatrader.com/support/helpG...ng_changes.htm

    When first starting to port scripts, I myself would open the NT7 help guide and the NT8 help guide to the same sections so that I could compare.

    The majority of code supported by NinjaTrader is included in the help guides.

    Below is a link to a forum post with helpful information about getting started with NinjaScript.

    Comment


      #3
      I appreciate the link to the table with new/old terms. That is something I was not aware of so, thank you.

      That code is accessing profitcurrency 2 trades back in time, when I only want to check 1 trade back in time. To answer your question, the log reveals that I cannot remove the -1 to get the most recent trade profitability If I remove the one, ie.

      SystemPerformance.AllTrades[SystemPerformance.AllTrades.Count].ProfitCurrency

      says "you are accessing an index with a value that is invalid since it is out-of-range."

      I'm guessing there is some sort of "profit calculation engine" in the code, and for some odd reason, it needs an extra, newer trade, to finish calculating profit.
      Last edited by go2toa; 09-17-2024, 11:37 PM.

      Comment


        #4
        Hello,

        Make sure you are checking that the collection is greater than 0 before accessing any index.

        The code in this HG page demonstrates:

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Yesterday, 05:17 AM
        0 responses
        54 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        130 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        72 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        44 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        49 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X