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

MR

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

    MR

    Hi all,

    My name is Bruce and I have a question for you.

    I wrote a code with SMA crossover to entry and exit.

    I would like to modify this code to only entry with the SMA crossover and take the exit manually.

    How could I cancel the exit from my strategy and only use the crossover entry?

    Any suggestions?

    Is there any tutorial the I could watch to learn?

    Thank you very much in advance.
    Bruace

    #2
    Hello brucegale69,

    Thanks for the note.

    If you want to prevent logic from running after you have entered long, then you would need to set up a boolean variable at the class level. Set it to false initially, then set it to true after you take a trade. There are many ways of doing this, so I advise you work with the technique that works best for you.

    A brief example:

    Code:
    public class MyStrategy : Strategy
    {
        private bool flip = false;
    
        ...
    
        protected override void OnBarUpdate()
        {
            if(flip)
                return;
            if(EntryCondition)
            {
                 EnterLong();
                 flip = true;
            }
        }
    }

    Please let us know if we may be of any further assistance.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Thank you very much for your reply.

      I would like to ask you if you know any programmer. I know exactly what I want but I am lack of experience in programming c#.

      Your suggestion will be highly appreciated.

      Thank you very much in advance.
      Bruce

      Comment


        #4
        Hello brucegale69,

        This is Jared from the NinjaTrader Business Development team responding on behalf of my colleague Chris.

        You can search our extensive library of NinjaScript consultants through the link below. Simply enter a consultant name or search by using our filter categories. Once you have identified your consultants of choice, please visit each consultant's site for more information or contact them directly to learn more:

        Search trading indicators, apps and services to personalize your NinjaTrader software. Explore custom trading indicators, automated strategies, free trading apps & more!


        You can locate the contact information for the consultants on their direct websites for any additional questions you may have. Since these consultants are third-party services for NinjaTrader, all pricing and support information will need to be obtained through the consultant.

        Let me know if I may be of further assistance

        This NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The companies and services listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem, LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.
        Jared M.NinjaTrader Customer Service

        Comment


          #5
          Hi,
          Thank you very much for you answer.
          I wrote a code with two SMA and the Stop Loss and Tralling Stop.
          Unfortunately, after doing my assessment I realized the tralling Stop is not working as Tralling Stop. It works as Take Profit.

          In order to write I followsd one of your tutorial step by step. Is there any other tutorial I can watch?

          Additonally, I would like to ask you if there is any indicator (tralling stop) which follows my SMA? I remember there was a code/function to program this function.

          Much appreciate four your help.

          hank you very much n advance

          Comment


            #6
            Hello brucegale69,

            Thanks for the follow up.

            There are no video tutorials on coding NinjaScript, but I would advise looking through all of the sample strategies that are available on the platform by default.

            We have a fully documented help guide which will help you get started with Ninja Script. You will find language references to all of the methods and functions you will be using. You will also see a tutorial section which will help you create your first indicator and get you started with some of these concepts.

            A link to our Help Guide can be found below:



            I am also linking you to the Educational Resources section of the Help Guide to help you get started with NinjaScript:



            You will find Reference Samples online as well as some Tips and Tricks for both indicators and strategies:

            Click here to see our NinjaScript Reference Samples:



            Click here to see our NinjaScript Tips:



            To set a trailing stop, you would use SetTrailStop:



            Please let us know if we may be of any further assistance.
            Chris L.NinjaTrader Customer Service

            Comment


              #7
              Hello,

              Do you know where can we find a sample strategy providing logic or code for a trailing stop to follow an indicator?

              Comment


                #8
                Hello rperez,

                Thank you for the post.

                You will supply a price value or tick value to the SetTrailStop method. Knowing this, you may supply the value of an indicator. For example, you can attach the price of an SMA like so:

                Code:
                SetTrailStop(SMA(14)[0]);
                You would want to first check if the SMA is below the Close price at that time as well.

                Please let me know if I can assist further.
                Chris L.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Mizzouman1, Today, 07:35 AM
                4 responses
                18 views
                0 likes
                Last Post Mizzouman1  
                Started by philmg, Today, 01:17 PM
                1 response
                4 views
                0 likes
                Last Post NinjaTrader_ChristopherJ  
                Started by cre8able, Today, 01:01 PM
                1 response
                6 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by manitshah915, Today, 12:59 PM
                1 response
                3 views
                0 likes
                Last Post NinjaTrader_Erick  
                Started by ursavent, Today, 12:54 PM
                1 response
                4 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Working...
                X