Announcement

Collapse
No announcement yet.

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 op1031, Today, 05:51 PM
        0 responses
        2 views
        0 likes
        Last Post op1031
        by op1031
         
        Started by nighttrader99, Today, 04:34 PM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_ShawnB  
        Started by Simon Investimens, Today, 02:51 PM
        1 response
        15 views
        0 likes
        Last Post NinjaTrader_ChrisL  
        Started by Unsuitable, Today, 02:49 PM
        0 responses
        14 views
        0 likes
        Last Post Unsuitable  
        Started by AroraAbhishek, Today, 01:49 PM
        1 response
        12 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Working...
        X