• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

SMA Distance in ATS

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

    SMA Distance in ATS

    Hey guys :-) I have a question: If I add a SMA-Indicator to my chart, I have the choice to push him a few steps to the right with an option named "distance" (see on picture). I would like to use this option for an automated trading strategy, but can't find the parameter in SMA source code. So I guess it is only an optical manipulation, right? How can i implement this function in a strategy? I have tried this: ....&& (CrossAbove(Close, SMA1, 1))) --->>> ......&& (CrossAbove(Close[0], SMA1[4], 1))), but of course it doesn't work :-) I'm newbee in programming NT.

    #2
    Hello Uwe1981,

    Thank you for your reply.

    You're right that displacement or distance for an indicator applied to a chart is strictly a visual manipulation. You can access these values in a strategy by using BarsAgo values, so SMA1[4] would give you the value of the SMA at the fifth bar on the chart. You can also apply a separate indicator with that displacement to the chart with the strategy to visually see it while you're running the strategy.

    What condition are you trying to create? Just if the SMA of the 5th bar crosses the close price?

    Thanks in advance; I look forward to assisting you further.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Hello Kate,

      thank you for your answer. Yes, at this moment I need to realize a crossover condition with Close[0] to SMA[x]. Of course, I could generate a separate indicator but is that necessary for such a simple condition? SMA1[4] works in a "higher as/lower as/equal"-condition without any problems, but unfortunately it does not work for crossover conditions. If I write "..&& (CrossAbove(Close[0], SMA1[4], 1)))" it generate an error while compiling. Maybe I do something wrong...? Greetings from Cracow :-)

      Comment


        #4
        Hello Uwe1981,

        Thank you for your reply.

        In this case you'd want to use something like this rather than CrossAbove():

        && (Close[0] > SMA1[4])

        This is because CrossAbove is really for when you want to know if the cross occurred any time during a range of bars. You can find more about CrossAbove ()in our help guide here:

        https://ninjatrader.com/support/help...crossabove.htm

        Please let us know if we may be of further assistance to you.
        Kate W.NinjaTrader Customer Service

        Comment


          #5
          Hello Kate,
          if I would take && (Close[0] > SMA1[4]) I will need a blocking funktion, because this condition triggers not only during a cross :-)

          Comment


            #6
            Hello Uwe1981,

            Thank you for your reply.

            You could do something like this to only trigger if the price crossed over the SMA since the previous bar:

            && (Close[0] > SMA1[4])
            && (Close[1] < SMA1[4])


            Please let us know if we may be of further assistance to you.
            Kate W.NinjaTrader Customer Service

            Comment


              #7
              Hello Kate, thank you for your reply and sorry for my late reply :-) The easiest ideas are of course always the best :-) Thank you for support

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by alenadruza, Today, 07:03 AM
              0 responses
              3 views
              0 likes
              Last Post alenadruza  
              Started by sidviciousX, Today, 06:47 AM
              0 responses
              2 views
              0 likes
              Last Post sidviciousX  
              Started by samir, 04-17-2019, 01:20 PM
              4 responses
              30 views
              0 likes
              Last Post gviand
              by gviand
               
              Started by Debayan Sen, Today, 01:50 AM
              0 responses
              7 views
              0 likes
              Last Post Debayan Sen  
              Started by eleven, Yesterday, 10:03 PM
              1 response
              11 views
              0 likes
              Last Post eleven
              by eleven
               
              Working...
              X