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

Re: Easy Lang Prob



PureBytes Links

Trading Reference Links

Personally I suspect Dennis is right -- that pivot function probably 
returns a bar number, not a price.  But there might be another 
problem too.

> You won't get a buy or sell signal the way you have it set up. It
> is not the "crosses above" or "crosses below" or the ">" or the "<"
> that's the problem. It is the stops. You have to use a filter
> because the high of the bar cannot buy at itself on a stop. It
> cannot refer to itself. 

No, that's not the problem.  The code as he wrote it says:
  "Set a stop on the NEXT BAR at the high price of THIS BAR."

So if this bar has a high of 1491.5, the stop can be hit if the NEXT 
bar goes to 1491.5.  Which is apparently what he wants.

Tom, you said it "doesn't trade right" but you didn't say HOW it 
failed.  Does it trade sometimes, but not always when you think it 
should?

I suspect the problem is:  you forgot that TS forgets.  Stop orders 
apply to the NEXT BAR ONLY.  So in the example above, if the NEXT BAR 
hits 1491.5, the system should buy.  But if it takes two or more bars 
before the market hits 1491.5, TS "forgets" the order and your system 
doesn't buy.

So you need to remember the entry price for TS.  Try something like 
this:

  Inputs: PriceH(High), LStrenH(6), RStrenH(2);
  
  Vars: PivHigh(0), BuyStop(0);
  
  { Clear stops if hit }
  if BuyStop <> 0 and H >= BuyStop then BuyStop = 0;
  
  { Avoid calling the function twice }
  PivHigh = PivotHighVSBar(1, PriceH, LStrenH, RStrenH, RStrenH+1);
  if PivHigh <> -1 Then Begin
   If H crosses above PivHigh Then BuyStop = H;
  End;
  
  if BuyStop <> 0 then buy at BuyStop stop;

You might also want to clear the SellStop variable when you set up 
the BuyStop.

It's a pain to have to manage stops manually like this, but that's 
the way TS works.

Gary