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

Strategie Start

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

    Strategie Start

    Hello,

    this Moving Average strategy starts at 09:00am and stops at 10:00 pm.
    A long signal is generated at 00:38 pm at 13143. ( Picture 1 )

    But I want the strategy to generate a signal from 9:00 am, in this case a short signal, because the moving average is short at this time.

    How do I change the strategy code. (picture 2)

    It should work like this ATR strategy. (Picture3).

    Thanks.
    Attached Files

    #2
    Hello daxtrader,

    Below I am providing a link to a forum post with helpful resources on getting started with NinjaScript and C#. Be sure to watch the training video.
    https://ninjatrader.com/support/foru...232#post775232

    Your strategy code has a condition to submit an EnterShort() when the SMA(Fast) (the red SMA line) crosses below the SMA(Slow) (the blue SMA line).

    What are the rules you are wanting instead?


    Please note, NinjaTrader 7 is no longer in active development and we are no longer considering new feature requests or changes for NinjaTrader 7. Main development has shifted to our flagship platform NinjaTrader 8. This does mean updates from brokerages, data feeds, or operating systems that require an update in NinjaTrader will not be implemented in NinjaTrader 7 and may cause an interruption in service.

    While there is not a set ETA for the complete discontinuation of NinjaTrader 7, we highly recommend transitioning to NinjaTrader 8 as soon as possible before NinjaTrader 7 reaches its end of life to prevent interruption of service.

    Click below to download NinjaTrader 8.
    http://ninjatrader.com/GetStarted
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello Chelsea,

      thank you for the quick reply.

      I have here another example of what I want.
      In picture 1, NinjaTrader 7 I get a short signal at 9:00 at 13102.
      In picture 2 , NinjaTrader 8 I do not get it.

      Both the same strategies.
      What is wrong with my code in NinjaTrader 8.​

      Comment


        #4
        Hello daxtrader,

        What is the logic you are wanting?

        What are the rules should cause a 'short signal'?

        To assist you in turning the logic you want into c#, I would need to know what logic you want.

        Without using a screenshot, please state in words, what the rules are for a 'short signal'.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          HelloChelsea,

          if the indicator is short on 10/28 (red) like in picture 1, and my strategy starts at 9:00,
          then I would like my strategy to go short then and not only when a next signal comes like here at 11:59.

          With NinjaTrader 7 the entry works as you can see in the picture 1.

          Unfortunately not with Ninjatrader 8 and I can not find the error in the programming.

          Please excuse my bad English​

          Comment


            #6
            Hello daxtrader,

            How is the indicator short?

            What are the rules for the condition?

            You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like our NinjaTrader Ecosystem team follow up with you with a list of affiliate consultants who would be happy to create this script or any others at your request or provide one on one educational services.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Hello Chelsea,

              here the code for the indicator NinjaTrader8

              Comment


                #8
                Hello daxtrader,

                What is the logic you want for entering a short position?

                Is there a specific line of code in the script you are posting you want to copy into your condition?

                I am not able to create the logic on your behalf, however this thread will remain open for any community members that would like to do this as a convience to you.

                I am able to assist you with understanding how to turn logic into C# code for your strategy. Please let me know what you want in the condition and I will be happy to assist.

                Unfortunately, post another script does not tell me what condition you want to enter short.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  ​My logic is.
                  The indicator goes short on10/27 at 17:31, as you can see on Picture 2 and goes long on10/28 at 11:59, we also create a long at 13144 with the strategy.
                  This works also with Ninjatrader 7+8.

                  My strategy starts at 9:00 and I want my strategy to generate a signal at this time, depending on whether the indicator is long or short.
                  This works with NinjaTrader 7 every day (picture 1) only with NinjaTrader 8 not.

                  Since I am just switching from NT7 to NT8 I noticed this error

                  the indicator provides the same signals in NinjaTrader 7 + 8.
                  Only the Strategy does not provide the same signals at the opening at 9:00, as you can see on the pictures 1 + 2.

                  Therefore, I think it is the code of the strategy.​

                  Comment


                    #10
                    Hello daxtrader,

                    The indicator goes short on10/27 at 17:31, as you can see on Picture 2
                    So the logic you would like is if the date and time of the current bar is 17:31 on October 27th, submit an EnterLong()?

                    if (Time[0].Year == 2022 && Time[0].Month == 10 && Time[0].Day == 27 && ToTime(Time[0]) == 170000)
                    {
                    EnterLong();
                    }

                    Are you certain this is the condition you want to submit a short entry order?

                    Please do not refer to pictures. State in words what you want.


                    My strategy starts at 9:00 and I want my strategy to generate a signal at this time
                    if (ToTime(Time[0]) == 90000)

                    depending on whether the indicator is long or short
                    What does this mean?
                    Which indicator?
                    How can an indicator be long, how can an indicator be short?
                    What value of the indicator means "long" to you?
                    What value of the indicator means "short" to you?

                    Are you talking about the SMA indicator?

                    If the SMA Indicator has a value of 100, is this short or long?

                    Do you mean the current bar value of the SMA is greater than the previous bars value of the SMA and the SMA is rising?


                    What is the logic you want in your condition?

                    What values do you want compared? What are the rules?
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      I don't mean the SMA but the ATR.

                      I mean the pictures I posted at 8:40 am.
                      There you can see that both ATR indicators show the same at NT 7 as well as at NT 8.

                      Only with the strategy at NT 7 I get at 9:00 at 13102 a short signal.
                      This signal is not generated at NT 8, as you can see on the pictures 1+2.

                      I do not understand why there is a signal at NT7 and not at NT8.​

                      Comment


                        #12
                        Hello daxtrader,

                        What do you consider a 'signal'?

                        What rules do you want with the ATR?

                        If the ATR is below 0 you want to submit a sell order?

                        If not, what do you want for the condition?
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #13
                          if (Close[0] > DownTrend[1])
                          EnterLong(DefaultQuantity, "LE");

                          if (Close[0] < .UpTrend[1])
                          EnterShort(DefaultQuantity, "SE");
                          Last edited by daxtrader; 11-03-2022, 08:31 AM.

                          Comment


                            #14
                            Hello daxtrader,

                            You have not put into words as requested.

                            In words, you want to submit a short entry market order when the current market price is less than the value of the TSSuperTrend.UpTrend plot on the previous bar (1 bar ago) between the hours of 9:00 AM and 1:14 PM (13:14:00)?

                            Is this the logic you want?

                            Specifically for short entry you want the condition to be
                            Code:
                            if (Close[0] < TSSuperTrend.UpTrend[1])
                            Have you put that in your condition?

                            Use prints to see if this evaluating as true.

                            Print the time of the bar and all values in the condition, include labels for each value and each comparison operator.

                            Follow the video that demonstrates how to use prints to debug and understand behavior in the forum post linked below.


                            Save the output to a text file and include this with your reply.
                            Chelsea B.NinjaTrader Customer Service

                            Comment


                              #15
                              Hello Chelsea,

                              is it so right.

                              if (Close[0] > DownTrend[1])

                              {
                              EnterLong(DefaultQuantity, "LE");
                              }​

                              if (Close[0] < UpTrend[1])

                              {
                              EnterLong(DefaultQuantity, "LE");
                              }​​
                              Last edited by daxtrader; 11-03-2022, 08:31 AM.

                              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