Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Dynamic Support and Resistance lines using HMA

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

  • NinjaTrader_JoshP
    replied
    1) The purpose of that line of code is to ensure you do not check bar indexes that do not exist. At the very beginning of your chart data there will not be any [1] or [2] index. Until you have more data it will add more indexes and then it will not cause problems when referencing that. You can read up more on this issue here.

    2) The algorithm you are using seems to be one designed for bar data rather than for moving averages. Your algorithm basically tries to find the top of the peaks and the bottom of the valleys. I don't know if using the same algorithm will be as effective on moving averages. Perhaps you can check out the algorithm involved in the Swing indicator provided by NinjaTrader.

    3) I am unaware of a way to do so yet, but it is on the list for future development.

    Leave a comment:


  • qitrader
    replied
    Thanks Josh,

    Some quick questions:

    1) what is the purpose of the following line and what does it do? It seems like when I remove this line, my indicator does not plot.

    Code:

    if ( CurrentBar < 1 || (ToDay(Time[0]) == ToDay(Time[CurrentBar]))) return;

    2) I have attached my indicator but it doesn't seem to be picking the major swing highs/lows.

    Is there a more efficient algorithm to recognize the highest swing highs and lowest swing lows? Mine seems to be picking non swing high points such as the one attached below under SAM.

    3) How do i remove the label of the indicator with parameters on the top left corner of my chart?

    Thanks
    Attached Files
    Last edited by qitrader; 09-30-2007, 12:41 PM.

    Leave a comment:


  • NinjaTrader_JoshP
    replied
    Hi qitrader,

    What you are trying to accomplish is very doable in NinjaTrader. Here are some pointers that should head you in the right direction.

    Take a look at my implementation of TRO Dynamic SR. In there you can see how the S and R lines are actually two plots. The plot style to acquire the effect shown is square.

    So you would start in the Initialize() method with
    Code:
    Add(new Plot(new Pen(Color.Red, 3), PlotStyle.Square, "Resistance"));
    and another one for the Support plot.

    You can then go into the OnBarUpdate() method and do something like
    Code:
    if(HMA(21)[0] > HMA(21)[1])
         Resistance.Set(Close[0]);
    Now, the exact code wouldn't be that because that algorithm is wrong, but you get the idea of how to set your plot values. The proper algorithm would probably be something similar to the one used in TRO Dynamic SR. It persists the SR levels unless something redefines them and then it will continue to persist until it gets redefined again.

    Remember you will also need to define your plot. You can do so with something like this
    Code:
    [Browsable(false)]    // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
    [XmlIgnore()]        // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
    public DataSeries Resistance
    {
        get { return Values[0]; }
    }
    Hope this helps.

    Leave a comment:


  • qitrader
    started a topic Dynamic Support and Resistance lines using HMA

    Dynamic Support and Resistance lines using HMA

    Hi all,

    Based on the swing hi/lo and TRO SR examples, how would I start coding a dynamic S&R based on a hull moving average. Using the example from SampleMulticolorPlot, I'm trying to draw horizontal lines to determine the swing highs and lows based on the color change conditions of a moving average of Hull moving average with a period of 21. I can change the sensitivity of the swing highs/lows by increasing or decreasing the period of the HMA.

    Example for upper line. When a HMA line turns RED, look for the highest swing high and start drawing the horizontal line until it reaches the next pivot swing.

    For lower line, when HMA turns green, then look for the lowest swing low and start drawing horizontal line until it reaches the next pivot swing.

    The horizontal line ends right before the HMA changes color.

    See my manually drawn screenshot below.

    Thanks
    Attached Files

Latest Posts

Collapse

Topics Statistics Last Post
Started by JakeOfSpades, Today, 08:55 AM
1 response
5 views
0 likes
Last Post JakeOfSpades  
Started by IndieTrader, Today, 05:29 AM
1 response
15 views
0 likes
Last Post NinjaTrader_BrandonH  
Started by ballboy11, Today, 08:09 AM
1 response
4 views
0 likes
Last Post NinjaTrader_BrandonH  
Started by kempotrader, 05-03-2019, 10:52 AM
9 responses
90 views
0 likes
Last Post DTSSTS
by DTSSTS
 
Started by waldoalvarez, Today, 07:53 AM
1 response
3 views
0 likes
Last Post NinjaTrader_ChrisL  
Working...
X