[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Coding help



PureBytes Links

Trading Reference Links

I *must* be missing something obvious here, but I've been staring at 
it for quite a while and I'm not seeing it.  Help, anyone?

Here is the code I'm testing:

======

Vars:  VarPts(4.0), LowHighLeft(999999), Highbar(0), HighBarHigh(0);

if (HighBar <> 0) and (H < HighBarHigh-VarPts) then begin
  value1 = CurrentBar - HighBar;
  print(d:6:0,t:5:0,": Right Low Found! = ",H:4:2,
        ", CB/HB/diff = ",Currentbar:5:0,HighBar:5:0,Value1:3:0);
  print("High = ",High[Value1]);

  plot1[CurrentBar-HighBar](High[CurrentBar-HighBar], "HIP");
  HighBar = 0;
  HighBarHigh = 0;
  LowHighLeft = H;
  end;

if (H < LowHighLeft) then begin
  LowHighLeft = H;
  HighBar = 0;
  print(d:6:0,t:5:0,": New Left Low High = ",H:4:2);
  end;

if (H > LowHighLeft+VarPts) and (H > HighBarHigh) then begin
  HighBar = CurrentBar;
  HighBarHigh = High;
  print(d:6:0,t:5:0,": High Bar? = ",H:4:2);
  end;

======

The problem is in the plot1 statement in the first section of code.  
I'm trying to detect a high point, defined as a point where the High 
is VarPts higher than highs on either side of it.

According to the print statements, the first "if" test does 
successfully find the desired high point.  The print statement 
correctly prints the High of the high-point bar.  So I'm sure my 
logic is working right.

But something is screwy with the plot1 statement.  If I remove the 
"[CurrentBar-HighBar]" offsets on the plot1 statement, it plots a dot 
at the High of the bar where the right-side lower High was found.  If 
I look at a specific instance, note the value of CurrentBar-HighBar 
as printed by the print statement, and add that constant offset into 
the plot1 statement:
  plot1[6](High[6],"HIP");

...then it correctly plots the dot on the High of the high-point bar.

But if I replace the constant "6" with "CurrentBar-HighBar", or with 
"Value1" -- both of which have the value 6 -- it plots NOTHING.

Help??
Gary