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.
    Gaby V.NinjaTrader Customer Service

    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:

        Gaby V.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by johnMoss, Today, 07:31 AM
        7 responses
        19 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by Skifree, Today, 08:58 AM
        7 responses
        21 views
        0 likes
        Last Post Skifree
        by Skifree
         
        Started by Don David, 04-10-2020, 12:04 PM
        4 responses
        2,512 views
        0 likes
        Last Post NinjaTrader_Erick  
        Started by Powerbucker, Today, 09:17 AM
        1 response
        10 views
        0 likes
        Last Post NinjaTrader_Erick  
        Started by zagier, Today, 05:10 AM
        1 response
        13 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X