High/Low Spread

This example will plot a simple average of the bar highs, and a simple average of the bar lows.  This could be done using two simple average studies.  But, the user who requested this example wants to see a spread plotted of these two averages.  Therefore, we whipped together an ESPL script so both averages are available for the spread.  Here is the script that will implement all this as a user defined study assigned to the #1 button on the drop down panel for studies.

The number of bars in the simple averages are obtained from the parameter form.  The spread is available automatically by checking the appropriate spread boxes on the parameter form.  We do not have to do anything special in the script to get the spread other than put one line to plot in User array #1 and a second line to plot in User array #2.

procedure SimpleAverage;
var i,period1,period2: integer;
begin
  SetUser(ePlot1,True);  SetUser(eShow1,True);
  SetUser(ePlot2,True);  SetUser(eShow2,True);
  period1:=GetUser(eParm1);
  period2:=GetUser(eParm2);
  for i:=BarBegin to BarEnd do begin
    Plot(1,Average(eHigh,i,period1),i);
    Plot(2,Average(eLow,i,period2),i);
  end;
end;

{----- MAIN PROGRAM -----}
begin
  if ESPL=51 then SimpleAverage;
end;