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

Cancel Orders if trigger arrived and ATR > 2

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

    Cancel Orders if trigger arrived and ATR > 2

    Hello, short foreword to my trading style. I trade the TF (Russell 2000) without any automatic strategys.

    For my Entry Stop Orders i use the „Basic Entry“ platform. For the stop loss and Profit target i use ATM Strategy.

    Now to my problem.
    If the trigger Price are arrived, is it possible to cancel the order automatically by following conditions:

    If the ATR 7 from the last Bar is greater than 2 – cancel the order.

    Unfortunately i know nothing about NinjaScripts. I hope you can help me.

    Best wishes
    Matthias

    #2
    Hello matthiasmaze,

    Thank you for writing in.

    I would be happy to provide some resources on how you would be able to accomplish this.

    I'm not quite sure if your entry is for a long or short position, but you would be able to call EnterLongStop() or EnterShortStop() to generate a buy or sell stop order to enter a position:
    EnterLongStop()
    EnterShortStop()

    You'll want to ensure that the liveUntilCancelled bool parameter is set to true so you can explicitly cancel the order only when your condition is true.

    You'll also need to assign your order entry method to an IOrder object so it can be canceled: https://ninjatrader.com/support/help...t7/?iorder.htm

    To cancel the order based on the condition you have provided:
    Code:
    // entry is the specific IOrder object storing my entry order
    // cancel our entry order if the previous bar's ATR indicator with a period of 7 value is more than 2
    if (ATR(7)[1] > 2)
         CancelOrder(entry);
    We do have resources to help you begin creating NinjaScript Strategies/Indicators.

    The best way to begin learning NinjaScript is to use the Strategy Wizard. With the Strategy Wizard you can setup conditions and variables and then see the generated code in the NinjaScript Editor by clicking the View Code button.

    I'm also providing a link to a pre-recorded set of videos 'Strategy Wizard 301' and 'NinjaScript Editor 401' for you to view at your own convenience.
    Strategy Wizard 301
    NinjaScript Editor 401

    There are a few Sample Automated Strategies which come pre-configured in NinjaTrader that you can use as a starting point. These are found under Tools--> Edit NinjaScript--> Strategy. You will see locked strategies where you can see the details of the code, but you will not be able to edit (you can though always create copies you can later edit via right click > Save as)

    We also have some Reference samples online as well as ‘Tips and Tricks’ for both indicators and strategies:
    Click here to see our NinjaScript Reference Samples
    Click here to see our NinjaScript Tips

    These samples can be downloaded, installed and modified from NinjaTrader and hopefully serve as a good base for your custom works.

    Further, the following link is to our help guide with an alphabetical reference list to all supported methods, properties, and objects that are used in NinjaScript.
    Alphabetical Reference

    We also have a few tutorials in our help guide for both Indicators and Strategies.
    Indicator tutorials
    Strategy tutorials

    Please, let me know if I may be of further assistance.
    Zachary G.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by yertle, Yesterday, 08:38 AM
    7 responses
    28 views
    0 likes
    Last Post yertle
    by yertle
     
    Started by bmartz, 03-12-2024, 06:12 AM
    2 responses
    21 views
    0 likes
    Last Post bmartz
    by bmartz
     
    Started by funk10101, Today, 12:02 AM
    0 responses
    6 views
    0 likes
    Last Post funk10101  
    Started by gravdigaz6, Yesterday, 11:40 PM
    1 response
    9 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by MarianApalaghiei, Yesterday, 10:49 PM
    3 responses
    11 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Working...
    X