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

How to enter on an indicator value in ninjascript

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

    How to enter on an indicator value in ninjascript

    Hi,

    I would like to enter on a market and/or limit order when price trades through an indicator value, such as the 20 ema. How would this be done in ninjascript?

    #2
    Hello wooofad,

    You could create a condition where the Close price is crossing above the SMA(20)..

    if (CrossAbove(Close, SMA(20), 1))
    {
    EnterLong();
    }

    Below are public links to the help guide on CrossAbove, Close, and SMA.




    Also, below is a link to a forum post with helpful information about getting started with NinjaScript.


    I recommend the Strategy Builder 301 course linked in that forum post.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea,

      I would like to enter at a limit price at the same price where to 20 ema is. This may require having the limit order sitting at that price before the price gets there, or using intrabar data. How would this be done?

      Comment


        #4
        Hello wooofad,

        Is this a different separate inquiry that no longer uses the cross of the close price with an sma?

        You can update the price of a limit to the price of an SMA.

        EnterLongLimit(SMA(20)[0]);

        You can run this with Calculate on bar close set to false to have OnBarUpdate update with each tick in real-time.

        If you want this to work historically, you would want intra-bar granularity.
        Below is a link to a post on intra-bar granularity.




        If you are wanting to place a limit order when a cross has occurred, you would first need to detect the cross to find the price at which the two series crossed. This means you would have to place the order (or adjust the price of a working order) after the cross has occurred.

        A limit order fills at the specified price or better.

        A buy limit order placed after a cross above at the price of the cross may fill immediately or may not fill at all until the market comes back to it.

        A sell limit placed after a cross above at the price of the cross would fill immediately at the market price.

        The rules would be reversed for a cross below. (i.e. a buy limit would fill immediately at market and a sell might sit until the market comes back)
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by thanajo, 05-04-2021, 02:11 AM
        3 responses
        467 views
        0 likes
        Last Post tradingnasdaqprueba  
        Started by Christopher_R, Today, 12:29 AM
        0 responses
        10 views
        0 likes
        Last Post Christopher_R  
        Started by sidlercom80, 10-28-2023, 08:49 AM
        166 responses
        2,236 views
        0 likes
        Last Post sidlercom80  
        Started by thread, Yesterday, 11:58 PM
        0 responses
        4 views
        0 likes
        Last Post thread
        by thread
         
        Started by jclose, Yesterday, 09:37 PM
        0 responses
        9 views
        0 likes
        Last Post jclose
        by jclose
         
        Working...
        X