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

General Programming - (Indicator Development)

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

    General Programming - (Indicator Development)

    OK, looking for any guidance here (I have attached a picture and labeled the areas I am talking about). No 1. I am using 2 EMA's one set at 14 and the other set at 25. What I am trying to do is that when the 2 EMA's are either similar (i would like to be able to adjust the inputs) or are at a certain close distance apart, the body of the bar changes to YELLOW (or any other color). basically to warn that the EMA's are on top of each other or getting close. Some significant moves tend to follow once this happens. No 2. I am trying to figure out how to produce an extreme signal once the security is a certain distance (again I would like to try to have this scale-able and input different variables for different markets) from these 2 EMA's. Again, I have attached a picture (it seems so) of an example of what I am trying to do. I have failed so far so looking for some help with the programming or suggestions.

    One last thing-is it possible to not have the EMA's on the actual chart?
    Attached Files
    Last edited by Labs905; 05-22-2015, 09:23 AM.

    #2
    Hello Labs905,

    Thanks for your post.

    For #1, one way to do this would be to use the tick difference between the EMAs and then you can set the minimum tick difference for the detection level. For example:

    Code:
    int tickdiff = Convert.ToInt32(Math.Abs(EMA(14)[0] - EMA(25)[0]) / TickSize);
    
    if (tickDiff < detectionLevel)
    {
    BarColor = Color.Yellow;  // color the bar yellow when below detectionLevel
    }
    Using Math.Abs() to get the absolute difference between the EMAs then converting that to Ticks with TickSize (makes it work on all instruments) and then converting it to an integer (you could use as double if you want to skip conversion step). The variable detectionLevel would be something you could set in the user interface to find what works for you.

    TickSize: http://www.ninjatrader.com/support/h...l?ticksize.htm

    Alternatively you might consider using CrossAbove() or CrossBelow();



    For #2 again you could use the tick difference but this time between perhaps the close of the current bar to one or the other of the EMAs.

    You do not need to show the EMAs on the chart.

    Please let me know if I can be of further assistance.
    Paul H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by mjairg, 07-20-2023, 11:57 PM
    3 responses
    213 views
    1 like
    Last Post PaulMohn  
    Started by TheWhiteDragon, 01-21-2019, 12:44 PM
    4 responses
    544 views
    0 likes
    Last Post PaulMohn  
    Started by GLFX005, Today, 03:23 AM
    0 responses
    3 views
    0 likes
    Last Post GLFX005
    by GLFX005
     
    Started by XXtrader, Yesterday, 11:30 PM
    2 responses
    12 views
    0 likes
    Last Post XXtrader  
    Started by Waxavi, Today, 02:10 AM
    0 responses
    7 views
    0 likes
    Last Post Waxavi
    by Waxavi
     
    Working...
    X