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

Developing Indicator to use in MA

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

    Developing Indicator to use in MA

    I want to develop an alert when the last price is within 10 cents of the 200 day SMA, but that's not possible in MA. Is it possible to develop an indicator that will tell me the distance (in cents) that the price is from the 200 SMA that I can then develop an alert from? If so, any help with the code?
    Last edited by mavrik2747; 06-15-2011, 04:31 AM.

    #2
    Welcome to our forums - I believe you could start for example with a MACD set to 1, 200, 1 as settings, so in essense you just see the difference of price vs the EMA used. For your version using a SMA the code would need to be changed / modified then. We have some great tutorials on getting started in custom coding:

    BertrandNinjaTrader Customer Service

    Comment


      #3
      Not sure if this is right or not, but here's what I've come up with for the code line from going through previous posts...

      (Math.Abs(Close[0] - SMA(200)[0]) < .1)
      or
      (Math.Abs(Close[0] - SMA(200)[0])=[0])

      Would the first one work for when to identify when the price is within 10 cents and the second one work for the absolute value of whatever the difference is?

      For alerts, I'm assuming I could set up a true/false alert for the first line and actual value alert for the second.

      Am I getting close or am I completely off?

      Comment


        #4
        You're very close, the first would work for detecting if it's within the range you set, while the other checks for the actual difference value - although it's likely never exactly 0, so some tolerance would be needed.
        BertrandNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by wzgy0920, 04-20-2024, 06:09 PM
        2 responses
        26 views
        0 likes
        Last Post wzgy0920  
        Started by wzgy0920, 02-22-2024, 01:11 AM
        5 responses
        32 views
        0 likes
        Last Post wzgy0920  
        Started by wzgy0920, Yesterday, 09:53 PM
        2 responses
        49 views
        0 likes
        Last Post wzgy0920  
        Started by Kensonprib, 04-28-2021, 10:11 AM
        5 responses
        192 views
        0 likes
        Last Post Hasadafa  
        Started by GussJ, 03-04-2020, 03:11 PM
        11 responses
        3,234 views
        0 likes
        Last Post xiinteractive  
        Working...
        X