_SECTION_BEGIN
//////////////////////////////// BAR SCALAR /////////////////////////////////
// When developing short-term trading systems that use complicated formulea
// it helps the be able to see system response to a changing bar. While you
// can step through a price chart to try and understand system behavior it is
// much easier to just place the cursor on the chart and modify the next bar
// accoring to some user input. The code below "scales" or "stretches" the bar:
// it magnifies HLC prices wrt the Open price of the bar. This allows you to
// test your system with gradual price changes and under controlled conditions.
// This is much easier then waiting for Real-Time price changes to show their
// effect.
SetBarsRequired
(1000000,1000000);
BI =
BarIndex();
SB =
Min(LastValue(ValueWhen(SelectedValue(BI)+1 == BI,BI)), BarCount-1);
EnableScaling =
ParamToggle("Apply Offset","DISABLED|ENABLED");
ScalingFactor =
Param("HLC Scaling Factor",1,0,5,0.01);
if
( EnableScaling )
{
Hd = H[sb]-O[sb];
Ld = O[sb]-L[sb];
Cd = C[sb]-O[sb];
Hd = ScalingFactor * Hd;
Ld = ScalingFactor * Ld;
Cd = ScalingFactor * Cd;
H[sb] = O[sb] + Hd;
L[sb] = O[sb] - Ld;
C[sb] = O[sb] + Cd;
}
Plot
(C,"",1,128);
_SECTION_END
|