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

Re: Help with array



PureBytes Links

Trading Reference Links

> But the object here is to identify a chart pattern, here it is an
> outside day. Then create an ordr active state where we buy oe sell
> at the high or low of the defined period. 

You don't need an array for this.  You just need to remember the High 
and Low of the outside day, and issue the orders based on that.

Try this:

        Inputs:  Ndays(9);
        
        Vars:  OutsideDay(-100), OutHigh(0), OutLow(0), 
               DaysBack(0), OneTick(MinMove points);
        
        If high > high[1] and low < low[1] then begin
          OutsideDay = CurrentBar;
          OutHigh = High;
          OutLow = Low;
          end;
        
        DaysBack = CurrentBar - OutsideDay;
        
        if (DaysBack <= Ndays) then begin
          Buy at OutHigh + OneTick stop;
          Sell at OutLow - OneTick stop;
          end;

You wouldn't even HAVE to use the OutHigh/OutLow variables -- you 
could use High[DaysBack] and Low[DaysBack] instead -- but I thought 
this made the code a little simpler to understand.

This code buys/sells one tick beyond the High/Low of the outside bar 
instead of exactly at the High/Low.

Gary