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

Need Help With Ninja Trader Strategy

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

    Need Help With Ninja Trader Strategy

    kdkeckewknqkwx wdnkqlndkqleqnkle. ednedqwnklqfenkl qflnnqef wiefwf jowewv wevj;wvj
    Attached Files
    Last edited by John abraham; 03-26-2024, 07:12 PM.

    #2
    Hello John abraham,

    Thank you for your post.

    One thing I want to note is that you are calling SetStopLoss from OnOrderUpdate() - if you are updating the stop loss dynamically, we recommend doing this from OnBarUpdate(). From the Help Guide:

    "You may call this method from within the strategy OnBarUpdate() method should you wish to dynamically change the stop loss price while in an open position​."

    Set methods should also be called before the entry if you are calculating custom prices.

    "Should you call this method to dynamically change the stop loss price in the strategy OnBarUpdate() method, you should always reset the stop loss price / offset value when your strategy is flat otherwise, the last price/offset value set will be used to generate your stop loss order on your next open position​"



    If you want to submit protective orders from OnOrderUpdate(), we would recommend using Exit methods and following the SampleOnOrderUpdate reference sample that demonstrates using OnOrderUpdate() and OnExecution() to enter protective orders.




    To understand why the script is behaving as it is, such as placing orders or not placing orders when expected, it is necessary to add prints to the script that print the values used for the logic of the script to understand how the script is evaluating.

    In the strategy add prints (outside of any conditions) that print the date time of the bar and all values compared in every condition that places an order.

    The prints should include the time of the bar and should print all values from all variables and all hard coded values in all conditions that must evaluate as true for this action to be triggered. It is very important to include a text label for each value and for each comparison operator in the print to understand what is being compared in the condition sets.

    Prints will appear in the NinjaScript Output window (New > NinjaScript Output window).

    Further, enable TraceOrders which will let us know if any orders are being ignored and not being submitted when the condition to place the orders is evaluating as true.

    I am happy to assist you with analyzing the output from the output window.

    Run or backtest the script and when the output from the output window appears save this by right-clicking the output window and selecting Save As... -> give the output file a name and save -> then attach the output text file to your reply.

    Below is a link to a forum post that demonstrates using informative prints to understand behavior and includes a link to a video recorded using the Strategy Builder to add prints.


    Please let me know if I may further assist with analyzing the output or if you need any assistance creating a print or enabling TraceOrders.​
    Last edited by NinjaTrader_Gaby; 03-26-2024, 01:35 PM.
    Gaby V.NinjaTrader Customer Service

    Comment


      #3
      Hi, I would run it with the print statements but I dont have acess to the MBOX package Ive used. The other person who helped me code it( my trading partner has the Mbox Indicators purchased). Could you suggest what part is causing the error and I can fix it. Thanks

      Comment


        #4
        pls help me out i am really frustrated Pls

        Comment


          #5
          Hello John,

          Unfortunately, from the code it is not clear to me what error you are facing. Is there a specific error you are seeing the Log tab of the Control Center?

          If you are having trouble with the script placing orders when not expected, adding prints and debugging using TraceOrders is necessary.

          Please let me know if you have any further questions.
          Gaby V.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by fx.practic, 10-15-2013, 12:53 AM
          5 responses
          5,404 views
          0 likes
          Last Post Bidder
          by Bidder
           
          Started by Shai Samuel, 07-02-2022, 02:46 PM
          4 responses
          95 views
          0 likes
          Last Post Bidder
          by Bidder
           
          Started by DJ888, Yesterday, 10:57 PM
          0 responses
          8 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Started by MacDad, 02-25-2024, 11:48 PM
          7 responses
          159 views
          0 likes
          Last Post loganjarosz123  
          Started by Belfortbucks, Yesterday, 09:29 PM
          0 responses
          8 views
          0 likes
          Last Post Belfortbucks  
          Working...
          X