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 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:



        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 Barry Milan, Yesterday, 10:35 PM
              5 responses
              16 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Started by DanielSanMartin, Yesterday, 02:37 PM
              2 responses
              13 views
              0 likes
              Last Post DanielSanMartin  
              Started by DJ888, 04-16-2024, 06:09 PM
              4 responses
              12 views
              0 likes
              Last Post DJ888
              by DJ888
               
              Started by terofs, Today, 04:18 PM
              0 responses
              11 views
              0 likes
              Last Post terofs
              by terofs
               
              Started by nandhumca, Today, 03:41 PM
              0 responses
              8 views
              0 likes
              Last Post nandhumca  
              Working...
              X