Examples: Displaying of Support/Resistance Levels

 

New article Displaying of Support/Resistance Levels has been published:

The article deals with detecting and indicating Support/Resistance Levels in the MetaTrader 4 program. The convenient and universal indicator is based on a simple algorithm. The article also tackles such a useful topic as creation of a simple indicator that can display results from different timeframes in one workspace.

Author: Slobodov Gleb

 
Dear Friend,
I just downloaded your Findlevels indicator.
Indicator is fine.I applied it to 1M chart of GBP/USD.I appllied 15 and 60 min levels. It showed up nicely.I tried to apply 240 min level.It got stuck.It is not responding. When I tried to close that 1M chart,it closes the platform.
When I strat the MT4 again, the same screen of 1M appears,saying 'it is not responding'.
How can I delete this 1M chart only so that I can have platform running properly?
I would appriciate your kind and valued help.
Dilip
 
Heh =)
Today i found that my articles have been translated to english by MetaQuotes
This is realy nice =)

dlppat:

I hope that I understood the question in spite of my poor English =)
When you using bigmin charts (for ex. 240min) you should be shure that you have enough history size.  The indicator uses 1000bars of history by default (as i remember =)).  So if you dont have enough long history,  you shound change varaible MaxT.
 

Hello,

I like the indicator. It works on the different timeframes. What I can not get to work is the support/ resistance lines from different timeframes in one chart, as described in your report. Can you tell me what the settings must be ?

Thanks

Dropje

 
I have analyzed the code and found problems. In no particular order:
  1. #define MaxLines 1000
    string LineName[MaxLines];
    int LineIndex = 0;
    ...
         ObjectSet(LineName[LineIndex], OBJPROP_STYLE, LineStyle);
         LineIndex++;
    
    LineIndex and LineName[] is never adjusted when lines are moved.
  2. int counted_bars = IndicatorCounted();
    int limit = MathMin(Bars - counted_bars, MaxLimit);
     
    double d1 = prLow(iLowest(NULL, TimePeriod, MODE_LOW, limit, 0));
    double d2 = prHigh(iHighest(NULL, TimePeriod, MODE_HIGH, limit, 0));
    
    Except for the first pass, limit will be zero and d1,d2 garbage, and the rest of the algorithm fails.
  3. if(d1Num != d1 && d1Num != 0.0){
            ArrayCopy(CrossBarsNum, CrossBarsNum, 0, (d1Num - d1)*10000);
    
    The code assumes 4 digits, would be extremely slow on they Yen. I don't think that the copy moves counts in the correct direction (up or down is possible. )
  4.  if(Time[limit] != TMaxI&&TMaxI != 0)
            if(d > prLow(iBarShift(NULL, 0, TMaxI)) && 
               d < prHigh(iBarShift(NULL, 0, TMaxI)))
                CrossBarsNum[di]--;
      }
    TMaxI = Time[limit] - 1;
    Definitely should be Time[limit-1] but still has other problems such as moving multiple bars from counts.
  5. ArrayResize(CrossBarsNum, (d2 - d1)*10000);
    
    Array size one pip too small, need d1 to d2 inclusive.
  6. di = (d - d1)*10000;
        if(!CrossBarsMin[di] && CrossBarsNum[ArrayMaximum(CrossBarsNum, 2*l, di - l)]
    
    ArrayMaximum scans beyond array bounds

So I rewrote the code but kept the same functionality.
The original code took about ten seconds to refresh. My code is instantaneous.

 
I didn't like the MaxCrossesLevel and MaxR idea. For one it doesn't show the min/max lines because of long tails. I replaced that portion with different algorithm.
  1. Roll down hill and find the lowest low. Line found.
  2. Climb uphill after the lowest low.
  3. Roll down hill forward from the last highest high.
  4. ...
 
WHRoeder:
I have analyzed the code and found problems. In no particular order:
  1. #define MaxLines 1000
    string LineName[MaxLines];
    int LineIndex = 0;
    ...
         ObjectSet(LineName[LineIndex], OBJPROP_STYLE, LineStyle);
         LineIndex++;
    
    LineIndex and LineName[] is never adjusted when lines are moved.
  2. int counted_bars = IndicatorCounted();
    int limit = MathMin(Bars - counted_bars, MaxLimit);
     
    double d1 = prLow(iLowest(NULL, TimePeriod, MODE_LOW, limit, 0));
    double d2 = prHigh(iHighest(NULL, TimePeriod, MODE_HIGH, limit, 0));
    
    Except for the first pass, limit will be zero and d1,d2 garbage, and the rest of the algorithm fails.
  3. if(d1Num != d1 && d1Num != 0.0){
            ArrayCopy(CrossBarsNum, CrossBarsNum, 0, (d1Num - d1)*10000);
    
    The code assumes 4 digits, would be extremely slow on they Yen. I don't think that the copy moves counts in the correct direction (up or down is possible. )
  4.  if(Time[limit] != TMaxI&&TMaxI != 0)
            if(d > prLow(iBarShift(NULL, 0, TMaxI)) && 
               d < prHigh(iBarShift(NULL, 0, TMaxI)))
                CrossBarsNum[di]--;
      }
    TMaxI = Time[limit] - 1;
    Definitely should be Time[limit-1] but still has other problems such as moving multiple bars from counts.
  5. ArrayResize(CrossBarsNum, (d2 - d1)*10000);
    
    Array size one pip too small, need d1 to d2 inclusive.
  6. di = (d - d1)*10000;
        if(!CrossBarsMin[di] && CrossBarsNum[ArrayMaximum(CrossBarsNum, 2*l, di - l)]
    
    ArrayMaximum scans beyond array bounds

So I rewrote the code but kept the same functionality.
The original code took about ten seconds to refresh. My code is instantaneous.

Hi,  Have you tried to include the Fractal in the algoritm?. It would increase a filtering of low/high from the  indicator and let more accurated S/R levels. 
WHRoeder:
I didn't like the MaxCrossesLevel and MaxR idea. For one it doesn't show the min/max lines because of long tails. I replaced that portion with different algorithm.
  1. Roll down hill and find the lowest low. Line found.
  2. Climb uphill after the lowest low.
  3. Roll down hill forward from the last highest high.
  4. ...
 
whroeder1 2011.05.26 16:16: I have analyzed the code and found problems. ... So I rewrote the code but kept the same functionality.

Code was lost over the last 8 years. I've attached what I believe was the modified file.

Files:
 
William Roeder:

Code was lost over the last 8 years. I've attached what I believe was the modified file.

Good morning from Turkey. Good morning from Turkey. Thank yo very much for this usefull code.

The attached file works fine, except the lower horizontal line dissapers and not seen again after the backtest starts. I checked the code several times, still I didnt get why it happens. I gave my own inputs; 100,1,0.01,Yellow,0,3,5. Do I miss something about this code? Or is there something really wrong  and I cant catch it?

 
William Roeder #:

Code was lost over the last 8 years. I've attached what I believe was the modified file.

Good day!  Thank yo very much for your work!

The attached file does not work and I cannot understand what the problem is, could you tell me what needs to be fixed to make this indicator work? Thank you for your help.