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 Max238, Today, 01:28 AM
        5 responses
        40 views
        0 likes
        Last Post Max238
        by Max238
         
        Started by giulyko00, Yesterday, 12:03 PM
        3 responses
        12 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by habeebft, Today, 07:27 AM
        1 response
        14 views
        0 likes
        Last Post NinjaTrader_ChristopherS  
        Started by AveryFlynn, Today, 04:57 AM
        1 response
        12 views
        0 likes
        Last Post NinjaTrader_Erick  
        Started by r68cervera, Today, 05:29 AM
        1 response
        10 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X