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

Ninjascript code questions..

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

    Ninjascript code questions..

    NT Support,

    Would you assist with the following questions:

    1) We are attempting to have NT flatten all at a specific maximum loss (which although I understand is not supported by NT, could you answer the following questions). Would the following code check for overall (realized + unrealized) drawdown?

    if(Performance.RealtimeTrades.TradesPerformance.Cu rrency.DrawDown >
    maxDailyDrawdown)
    //ExitPositionCode

    If not, we also had feedback that "this will not include intrabar / open drawdown -
    you could take the closed figure and then add for example the Open PNL
    to it to exit then as you hit your daily max." But this does not make sense to us, can you explain how do we calculate the closed figure and then add the Open PNL?
    Meaning how exactly code wise is this doable (we thought that's what the code you sent us earlier was doing)?


    2) In our Output window, for example, we are getting the following:

    6/28/2010 3:05:01 PM Disable() called: strategy disabled
    6/28/2010 3:05:01 PM CancelAllOrders: BarsInProgress=0
    **NT** Disabling NinjaScript strategy
    'Auto44v5/92eb29faf3e54e1eb576ac0f507536c1'
    6/28/2010 3:05:01 PM Disable() called: strategy disabled

    We are not sure why did NT disable our Ninjascript strategy? What are potential causes for NT strategies to disable?

    Thank you for your time and assistance..

    #2
    Hello sev888,

    1) That will check drawdown for closed trades. To check open trades or unrealized PnL you could work with GetProfitLoss() and custom code the drawdown value. Using either MAX or MIN is good to capture the highest or lowest value over a series of values.

    You could add these two together for your drawdown check.

    PseudoCode Below:
    if (closedDrawDown + openDrawDown >= drawDownThreshold)
    doSomething;

    This reference sample can help further with the trade performance class: Using trade performance statistics for money management

    2) The disable message can appear anytime you stop running the strategy. This could be due to unchecking the enabled box, removing from chart etc. It means that is no longer running.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      I appreciate your reply... I do not stop the strategy from running (by disabling the strategy, removing it from the chart, or closing the chart), any other suggestions? Thanks..

      Comment


        #4
        I would suggest you recheck your code, as the output suggests the Disable() was called -

        6/28/2010 3:05:01 PM Disable() called: strategy disabled

        Strategies would also be terminated on errors received (rejections...), provided you're working with the default RealtimeErrorHandling - http://www.ninjatrader-support.com/H...rHandling.html
        BertrandNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by pechtri, 06-22-2023, 02:31 AM
        10 responses
        124 views
        0 likes
        Last Post Leeroy_Jenkins  
        Started by judysamnt7, 03-13-2023, 09:11 AM
        4 responses
        59 views
        0 likes
        Last Post DynamicTest  
        Started by ScottWalsh, Yesterday, 06:52 PM
        4 responses
        36 views
        0 likes
        Last Post ScottWalsh  
        Started by olisav57, Yesterday, 07:39 PM
        0 responses
        7 views
        0 likes
        Last Post olisav57  
        Started by trilliantrader, Yesterday, 03:01 PM
        2 responses
        22 views
        0 likes
        Last Post helpwanted  
        Working...
        X