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

Mystery Code



PureBytes Links

Trading Reference Links

Hi,

I got this code from someone who shall remain anonymous. I have looked at it
for awhile and I was wondering if someone recognizes it or knows anything
about how it is supposed to be used or any other details. Thanks

Brent

   INPUT:  Dayz(4), SigExpir(50);

   VAR:    MarketHigh(-99999), MarketLow(999999), PHi(0), PLo(0), Idx(0),
           PrevPHiBar(0), PBarCount(0), LowestPLo(0), LowestPLoBar(0),
           PLoFound(FALSE), Lo2HiDays(0), TempBuyPrice(0), TempBuyBar(0),
           TempBuyON(FALSE), PrevPLoBar(0), HighestPHi(0),
           HighestPHiBar(0), PHiFound(FALSE), Hi2LoDays(0),
           TempSellPrice(0), TempSellBar(0), TempSellON(FALSE);

   ARRAY:  PHiBar[1500](0), PHiPrice[1500](0),
           PLoBar[1500](0), PLoPrice[1500](0);


   { -------------------------------------------------------------------- }

   PLoFound = FALSE;
   PHiFound = FALSE;

   IF High > MarketHigh THEN        { Capture Highest High of Market }
     MarketHigh = High
   ELSE
     MarketHigh = MarketHigh[1];

   IF Low < MarketLow THEN          { Capture Lowest Low of Market }
     MarketLow = Low
   ELSE
     MarketLow = MarketLow[1];


   IF High < High[1] AND High[1] > High[2] THEN  { Identify Pivot Highs }
     BEGIN
       PHi = PHi + 1;                    { Pivot High Counter }
       PHiBar[PHi] = CurrentBar - 1;   { Most Recent Pivot High Bar }
       PHiPrice[PHi] = High[1];       { Most Recent Pivot High Price }
     END;

   IF Low > Low[1] AND Low[1] < Low[2] THEN   { Identify Pivot Lows }
     BEGIN
       PLo = PLo + 1;                   { Pivot Low Counter }
       PLoBar[PLo] = CurrentBar - 1;    { Most Recent Pivot Low Bar }
       PLoPrice[PLo] = Low[1];         { Most Recent Pivot Low Price }
     END;


   IF PHiBar[PHi] = CurrentBar - 1 AND
      PHiPrice[PHi] < MarketHigh AND
      PHi > 1 AND PLo > 1 THEN         { Test Each New Pivot High }
     BEGIN

       FOR Idx = PHi - 1 DownTo 1      { Do we have a Higher Pivot}
         BEGIN

           IF PHiPrice[PHi] < PHiPrice[Idx] THEN { Is it Higher ? }
             BEGIN
               PrevPHiBar = PHiBar[Idx]; { Yes, at this Bar Location }
               Idx = 1;                     { Stop Looking }
             END;
         END;

       PBarCount = PHiBar[PHi] - PrevPHiBar;  { Bars between Pivots }

       IF PBarCount >= Dayz THEN       { Are there enough Days ? }
         BEGIN
           LowestPLo = PLoPrice[PLo];    { Initialize with Last P-Low}
           LowestPLoBar = PLoBar[PLo];     { Remember the Bar Number}

           FOR Idx = PLo - 1 DownTo 1   { Search for Pivot Low Point }
             BEGIN

          IF PLoBar[Idx] > PrevPHiBar THEN {Are we within Pivot Range}
                 BEGIN

              IF LowestPLo > PLoPrice[Idx] THEN {Is This Low Lower ?}
                     BEGIN
                   LowestPLo = PLoPrice[Idx];   { Yes, Get its Price }
                  LowestPLoBar = PLoBar[Idx];  { & Get its Bar Number}
                       PLoFound = TRUE;             { Turn Flag On }
                     END;
                 END
               ELSE
                 Idx = 1;                         { Stop Looking }
             END;
         END;   { END - PBarCount >= Dayz }

       IF PLoFound THEN BEGIN            { If there was a Pivot Low }

       Lo2HiDays = PHiBar[PHi] - LowestPLoBar; { Determine Day to Low}

         IF Lo2HiDays >= Dayz AND
          PHiBar[Phi] > TempBuyBar THEN   { Does this Pivot Qualify ?}
             BEGIN
             TempBuyPrice = PHiPrice[Phi]; { Yes, Set Buy STOP Price }
               TempBuyBar = PHiBar[Phi];     { Remember When }
               TempBuyOn = TRUE;               { Turn Buy Flag ON }
             END;
         END;

     END;  { END - Pivot High Testing }


  { ---------------------  SHOW BUY POINTS  --------------------------- }

   IF TempBuyON THEN
     BEGIN

       IF High < TempBuyPrice AND
          CurrentBar - TempBuyBar <= SigExpir THEN
         PLOT1(TempBuyPrice + 1 * MinMove POINT,"PHi")
       ELSE
         TEMPBuyON = FALSE;
     END;

  { ---------------------  SHORT SETUP TEST  -------------------------- }

IF PLoBar[PLo] = CurrentBar - 1 AND
      PLoPrice[PLo] > MarketLow AND
      PHi > 1 AND PLo > 1 THEN         { Test Each New Pivot High }
     BEGIN

       PBarCount = 0;

       FOR Idx = PLo - 1 DownTo 1     { Do we have a Higher Pivot }
         BEGIN

           IF PLoPrice[PLo] > PLoPrice[Idx] THEN { Is it Lower ? }
             BEGIN
               PrevPLoBar = PLoBar[Idx];  { Yes, at this Bar Location }
               PBarCount = PLoBar[PLo] - PrevPLoBar;  { Bars between Pivots}
               Idx = 1;                     { Stop Looking }
             END;
         END;

       IF PBarCount >= Dayz THEN       { Are there enough Days ? }
         BEGIN
         HighestPHi = PHiPrice[PHi];     { Initialize with Last P-Low}
           HighestPHiBar = PHiBar[PHi];     { Remember the Bar Number}

           FOR Idx = PHi - 1 DownTo 1   { Search for Pivot Low Point }
             BEGIN

           IF PHiBar[Idx] > PrevPLoBar THEN {Are we within PivotRange}
                 BEGIN

                IF HighestPHi < PHiPrice[Idx] THEN { Is High Higher ?}
                     BEGIN
                  HighestPHi = PHiPrice[Idx];   { Yes, Get its Price }
                   HighestPHiBar = PHiBar[Idx];  { Get its Bar Number}
                       PHiFound = TRUE;              { Turn Flag On }
                     END;
                 END
               ELSE
                 Idx = 1;                         { Stop Looking }
             END;
         END;   { END - PBarCount >= Dayz }

     IF PHiFound THEN                  { If there was a Pivot High }
         BEGIN
      Hi2LoDays = PLoBar[PLo] - HighestPHiBar;{ Determine Day to High}

        IF Hi2LoDays >= Dayz AND
          PLoBar[PLo] > TempSellBar THEN  { Does this Pivot Qualify ?}
             BEGIN
          TempSellPrice = PLoPrice[PLo]; { Yes, Set Sell STOP Price }
               TempSellBar = PLoBar[PLo];     { Remember When }
               TempSellOn = TRUE;               { Turn Buy Flag ON }
             END;
         END;

     END;  { END - Pivot High Testing }


  { --------------------------  SHOW SELL POINTS  ----------------------  }


   IF TempSellON THEN
     BEGIN

       IF Low > TempSellPrice AND
          CurrentBar - TempSellBar <= SigExpir THEN
         PLOT2((TempSellPrice - 1 * MinMove POINT),"PLo")
       ELSE
         TEMPSellON = FALSE;
     END;