Double Reflection Indicator from Welles Wilder

Welles Wilder (the RSI creator) wrote a book called "The Adam Theory of Markets" where he talks about "double reflection charts". Back then he used acetate to do the trick.

Here are the instructions extracted from the book:
[1] Place a piece of clear acetate over your chart.
[2] With a pen that will write on acetate, begin with the most recent day and trace each day on your chart going back in history as far as you wish.
[3] Now turn the piece of acetate over just as you would turn the page of a book.
[4] Next grip the bottom edge of the acetate and turn it over from bottom to top so that your hand ends up at the top of the page of acetate.
[5] Now overlay the first day (on the left hand side) of the acetate
You have just constructed a double reflection chart!




It's a bit different from the rest of the indicators as it's not being printed on current bars, but future bars.

Could something like this be built in Amibroker?

In AmiBroker you can output any voodoo too.
So you can plot voodoo like that too.

Note, click End key on your keyboard multiple times to load more bars on the chart's right side.

Plot( C, "Price", colorDefault, styleBar );

// https://forum.amibroker.com/t/double-reflection-indicator-from-welles-wilder/36979/2
// Double reflection 
reversed = true;
period = 50;
xshift = 0;
yshift = 0;

bi = BarIndex();
lastc = LastVisibleValue(C);// lastvalue(C);
diff = lastc-LastVisibleValue(O);

C = IIf(bi<=period, Reverse(C), Null);
H = IIf(bi<=period, Reverse(H), Null);
L = IIf(bi<=period, Reverse(L), Null);
O = IIf(bi<=period, Reverse(O), Null);

ll = L;
hh = H;
op = O;
cl = C;

if ( reversed ) {
  H = 2*lastc-hh-diff;
  L = 2*lastc-ll-diff;
  O = 2*lastc-cl-diff;
  C = 2*lastc-op-diff;
}

O += yshift;
H += yshift;
L += yshift;
C += yshift;

Plot( C, "Price", colorGreen, styleBar, Null, Null, BarCount+xshift, 0, -10 );

RestorePriceArrays();

7 Likes

Ah, that's just perfect.. It works like a charm.
Thanks a million Fxshrat.

I'm wondering about the extent of the usability of these voodoo bars as they're not in the database.
Better ask here just to be sure: can we use these bars with indicators, backtests or explorations?

ie: an exploration with a custom column of the avg close of the next X bars.

Just shift the bars and combine the required arrays.
Then calculate indicator based on combined array.

Plot( C, "Price", colorDefault, styleBar, Null,Null, 0, 0, -10 );

// https://forum.amibroker.com/t/double-reflection-indicator-from-welles-wilder/36979/5
// Double reflection
reversed = 1;
period = 50;
xshift = 0;
yshift = 0;

bi = BarIndex();
dt = DateTime();
lastc = LastVisibleValue(C);// lastvalue(C);
diff = lastc-LastVisibleValue(O);

C = IIf(bi<period, Reverse(C), Null);
H = IIf(bi<period, Reverse(H), Null);
L = IIf(bi<period, Reverse(L), Null);
O = IIf(bi<period, Reverse(O), Null);

ll = L;
hh = H;
op = O;
cl = C;

if ( reversed ) {
  H = 2*lastc-hh-diff;
  L = 2*lastc-ll-diff;
  O = 2*lastc-cl-diff;
  C = 2*lastc-Op-diff;
}

O += yshift;
H += yshift;
L += yshift;
C += yshift;

O_reflect = Ref(O, -(BarCount-period));
H_reflect = Ref(H, -(BarCount-period));
L_reflect = Ref(L, -(BarCount-period));
C_reflect = Ref(C, -(BarCount-period));

Plot( C, "Price reflection", colorGreen, styleBar, Null, Null, BarCount+xshift, 0, -10 );

RestorePriceArrays();

C_combined = IIf(bi <= BarCount-period, Ref(C,period-1), C_reflect);
MA_combined = MA(C_combined, 100);

//Plot( C_combined, "Price_combined",  IIf(bi <= BarCount-period,colorOrange,colorGreen), styleLine, Null,Null, period+xshift, 0, -10 );
Plot( MA_combined, "MA_combined", colorRed, styleLine, Null,Null, period+xshift, 0, -10 );

dt_shiftback = Ref(dt,period-1);
dt_combined = dt_shiftback;
for( i = 0, n = 0; i < BarCount; i++ ) {
  if ( i > BarCount-period-1 ) {
    dt_combined[i] = DateTimeAdd(dt_shiftback[i], n, Interval());    
    n++;
  }
}

SetOption( "NoDefaultColumns", True );
SetSortColumns( 2 );
AddTextColumn( Name(), "Ticker", 1 );
AddColumn( dt_combined, "Date/Time combined", formatDateTime, IIf(bi <= BarCount-period, -1, colorGreen) );
AddColumn( C_combined, "C_combined", 1.2 );
AddColumn( MA_combined, "MA_combined", 1.2 );

Filter = 1; 

3 Likes

Thanks fxshrat, I've been studying it (and still trying to understand it).

When I do a code check I get:
"It seems that the formula references FUTURE quotes.
If you backtest this system you may receive outstanding results
that CAN NOT be reproduced in real trading.
6046 data bars used during this check. Total execution time: 0.004552534 sec.
Approximately 24114 past and 98 future quotes are needed to calculate the formula properly"

For what I see (please correct me if I'm wrong) it seems that these phantom bars appears only once at the very end of the last bar in the database.

MA_combined comes from C_combined, which comes from C.
And C before the last bar in the database was always C (peeks into the future), not these voodoo bars.
I'm trying to get the average of these voodoo bars (only) at any date without any repaint.

IDK, maybe using a rolling window or something?

The message just means that it uses Ref() with positive shift. This particular formula must do that because it plots into the future.

1 Like