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

SMA status linked to other indicator

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

    SMA status linked to other indicator

    Good morning, I have been searching for threads to help with an issue but so far in vain.
    I would like to be able to code the following: I have 3 SMAs and I want the software to be able to link, for example, the situation when any ONE of them is UP, to another indicator.
    I also want to add another condition that the difference between 2 chosen SMAs should not be greater than a specified number.
    Would be grateful for some help in this direction please.
    TIA

    #2
    Hello jmsUK,
    Thanks for your note.

    You can use the Rising function to check if any one of the SMA is UP or not.

    Code:
    if (Rising(SMA(14)) || Rising(SMA(34)) || Rising(SMA(50)))
    {
    	//do something
    }


    You can use the Math.Min function to make sure the difference between 2 SMA is not greater than a certain number. A sample code will be like.

    Code:
    double smaDiff = Math.Min(15, Math.Abs(SMA(14)[0] - SMA(34)[0]));


    Have you sent a email to us in this context. If so then we would request you to use one channel only.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      Joydeep, thank you very much for prompt reply. I will work with you suggestions and see how I get on

      Comment


        #4
        I am working through the ideas you gave me yesterday, but another issue has arisen in the meantime:
        I am attempting to add a second time-frame (a tick chart) to the existing tick chart but am getting nothing. Is it possible to reference 2 tick charts (and no minute charts) in same strategy please?
        Thanks

        Comment


          #5
          Hello jmsUK,
          Yes, you can create multi-series strategies. Please refer to our help guide to know more aboit it.


          You can also refer to the sample code which comes native with NinjaTrader.
          • In Control Center menu bar goto Tools>Edit NinjaScirpt>Strategies...
          • In the Strategies dialog please refer to the SampleMultiTimeframe and Sample MultiInstrument strategies.


          You may also refer to this sample code
          You can submit orders to different Bars objects. This allows you the flexibility of submitting orders to different timeframes. Like in live trading, taking entry conditions from a 5min chart means executing your order as soon as possible instead of waiting until the next 5min bar starts building. You can achieve this by


          Please let me know if I can assist you any further.
          JoydeepNinjaTrader Customer Service

          Comment


            #6
            Good morning, I am still stuck at what appears to be a basic concept in terms of adding Bars,

            I am trying to write a script to trade on a tick chart when 3 criteria occur together-
            2 conditions on the tick chart involving Stocastic and bollinger band AND 1 condition on a higher time frame chart.

            There appears to be a contradiction in the method for adding bars between the link:
            http://www.ninjatrader.com/support/h...nstruments.htm / Adding Additional Bars Object to NinjaScript,
            where a 3 min chart higher time frame) is added to a 1 minute (lower time frame)
            and
            the SampleIntrabarBacktest where on Initialise it is stated:
            /* Add a secondary bar series.
            Very Important: This secondary bar series needs to be smaller than the primary bar series.

            I would prefer to load the strategy into the tick chart
            I would be very grateful if you could clarify this for me.
            Many thanks
            Jeremy Stuart

            Comment


              #7
              Hello Jeremy,
              Since the SampleIntrabarBacktest strategy backtests the strategy intrabar, a higher granularity secondary timeframe is needed (for example if primary data series is 5 minute then the secondary data series must be below 5 minute, say a one minute bar series). It is specific to the SampleIntrabarBacktest strategy only and not a general rule.
              JoydeepNinjaTrader Customer Service

              Comment


                #8
                Thank you for that information and I will work with that.
                Can you please answer this question specifically? Can NinjaTrader combine a 5 minute time frame with a tick chart. I have seen examples of 15, 5, 3 and 1 minute but does it work with tick charts and minute charts combined.
                Thanks again for your support

                Comment


                  #9
                  Hello Jeremy,
                  Yes, you can add a minute and a tick bar (or any other period type) as additional bar series in a NinjaScript code.
                  JoydeepNinjaTrader Customer Service

                  Comment


                    #10
                    Ok Thanks for that. This isn't easy!

                    Comment


                      #11
                      I have used the code you gave me and come up with this combination, and it compiles but doesn't do what it should:
                      // Condition set 1 for buying
                      if (Stochastics(5, 14, 3).K[0] < 15
                      && Low[0] < Bollinger(2, 14).Lower[0]
                      && Rising(SMA(BarsArray[1], 10)) || Rising(SMA(BarsArray[1], 25))
                      && ToTime(Time[0]) > ToTime(07, 00, 0)
                      && ToTime(Time[0]) < ToTime(20, 50, 0))
                      {
                      I suspect my syntax is incorrect. Adding the reference to the 5 minute chart just does not work. Without the reference to the 5 min, it behaves as I want
                      Could you please guide me on this.
                      Many thanks as always for support

                      Comment


                        #12
                        Hello Jeremy,
                        To assist you further can you please send a toy NinjaScript code* replicating the behavior to support[AT]ninjatrader[DOT]com

                        Please append Attn:Joydeep in the subject line of the email and give a reference of this thread in the body of the email.

                        I look forward to assisting you further.

                        *The "toy" just means something that is a stripped down version that isn't necessarily the whole logic. It makes things easier to rout out.
                        JoydeepNinjaTrader Customer Service

                        Comment


                          #13
                          Thank you I am emailing

                          Comment


                            #14
                            Hello Jeremy,
                            Thanks for your note.

                            I have received your email and have replied to it.
                            JoydeepNinjaTrader Customer Service

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by DanielTynera, Today, 01:14 AM
                            0 responses
                            2 views
                            0 likes
                            Last Post DanielTynera  
                            Started by yertle, 04-18-2024, 08:38 AM
                            9 responses
                            40 views
                            0 likes
                            Last Post yertle
                            by yertle
                             
                            Started by techgetgame, Yesterday, 11:42 PM
                            0 responses
                            12 views
                            0 likes
                            Last Post techgetgame  
                            Started by sephichapdson, Yesterday, 11:36 PM
                            0 responses
                            2 views
                            0 likes
                            Last Post sephichapdson  
                            Started by bortz, 11-06-2023, 08:04 AM
                            47 responses
                            1,615 views
                            0 likes
                            Last Post aligator  
                            Working...
                            X