stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

MA of Hurst Target
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=4014
Page 1 of 1
Author:  Radar [ Fri Dec 26, 2014 9:13 am ]
Post subject:  MA of Hurst Target

Hey Gang,

I'm pretty crap at setting TP targets, so I am very happy that Pips400 shared his Hurst Target indi :)

I'd like to get a moving average of its output, so that I have an idea of whether I can scale-in on a move, how many times, and at what distance apart.

I'm not after code, just the steps ;) All I can think of is...

1. On init...
a. Look back through the history, and count the cross-overs until I reach MA_Period + 1.

b. Walk forward from there, storing the pip value of each target into an array.

c. Run iMAOnArray on that array.

2. On each new cross-over...
a. ArraySetAsSeries = false

b. Replace the last element with the current target.

c. ArraySetAsSeries = true.

d. Run iMAOnArray on the array.

e. Goto 2a.

Have I missed anything, (or added something that's not needed)?

Have fun!

Radar =8^)

edit... If you haven't looked at Hurst Target, what is does (for a cross Up) is...

1. Finds the lowest Low between the current cross up and the previous cross down.

2. Subtracts the price of the LL from the price of the cross up.

3. Adds a percentage (user configurable) of the result of step 2 to the price of the cross up, thereby giving you a potential TP point.
Author:  Radar [ Sun Jan 04, 2015 6:17 am ]
Post subject:  MA of Hurst Target

Done, but not quite the way set out above...

I have 2 functions called "void tma_centred_value". One takes a look-back parameter, and is called during init, the other doesn't/isn't.

Here's the code to find the crossovers (slightly modified from Pips400's original code (so all errors are mine, I tell you! All mine! Ahahahahahaaaa!))...

Code: Select all

void tma_centred_value (int lookback)
{
   x = 0;
   y = 0;
   samples = 0;
  
   for (int z = 0; z <= lookback; z++)
   {
      if ( iCustom(NULL, CTF, "TMAcentered", 5, 0, z) < iCustom(NULL, CTF, "TMAcentered", 10, 0, z) )
      {
         direction = "below";
         while ( iCustom(NULL, CTF, "TMAcentered", 5, 0, z) < iCustom(NULL, CTF, "TMAcentered", 10, 0, z) )
         {
            x++;
            z++;      
         }

         while ( iCustom(NULL, CTF, "TMAcentered", 5, 0, z + y) > iCustom(NULL, CTF, "TMAcentered", 10, 0, z + y) )
         {
            y++;
         }

         GetHurstInfo();
         samples++;
         if (samples == 14) break;
      }
   
      else
      {
         direction = "above";
         while ( iCustom(NULL, CTF, "TMAcentered", 5, 0, z) > iCustom(NULL, CTF, "TMAcentered", 10, 0, z) )
         {
            x++;
            z++;      
         }

         while ( iCustom(NULL, CTF, "TMAcentered", 5, 0, z + y) < iCustom(NULL, CTF, "TMAcentered", 10, 0, z + y) )
         {
            y++;
         }

         GetHurstInfo();
         samples++;
         if (samples == 14) break;
      }
   }
   return;
} // End void tma_centred_value ()
...and here's the code to get the extensions (again, modified version of Pips400's code)

Code: Select all

void GetHurstInfo()
{
   datetime HPTime = 0; // Bar time of Highest High.
   datetime LPTime = 0; // Bar time of Lowest Low.
   bool UpdateAverage = false;
   if (direction == "above") 
   {
      LowPoint[TFCount] = iLow(NULL, CTF, iLowest(NULL, CTF, MODE_LOW, y, x)); // get price at lowest point of swing
      LPTime = iTime(NULL, CTF, iLowest(NULL, CTF, MODE_LOW, y, x)); // get time of swing low
      if (LPTime > LowPointTime[TFCount])
      {
         LowPointTime[TFCount] = LPTime;
         UpdateAverage = true;
      }
   }

   if (direction == "below") 
   {
      HighPoint[TFCount] = iHigh (NULL, CTF, iHighest(NULL, CTF, MODE_HIGH, y, x)); // get price at highest point of swing
      HPTime = iTime(NULL, CTF, iHighest(NULL, CTF, MODE_HIGH, y, x)); // get time of swing high
      if (HPTime > HighPointTime[TFCount])
      {
         HighPointTime[TFCount] = HPTime;
         UpdateAverage = true;
      }
   }
   //Calculation of crossover value
   double a,b,c,d;
   
   a = iCustom (NULL, CTF, "TMAcentered", 5, 0, x - 1);
   b = iCustom (NULL, CTF, "TMAcentered", 10, 0, x - 1);
   c = iCustom (NULL, CTF, "TMAcentered", 5, 0, x);
   d = iCustom (NULL, CTF, "TMAcentered", 10, 0, x);
   
   CrossOverValue[TFCount] =    NormalizeDouble (((((a+b)/2) + ((c+d)/2))/2), Digits); // get value at crossover
   CrossOverTime1[TFCount] = iTime(NULL,CTF,x);
   CrossOverTime2[TFCount] = iTime(NULL,CTF,x+y);   

   if (direction == "below")
   {
      HurstExtension[TFCount] = MathAbs(CrossOverValue[TFCount] - HighPoint[TFCount]);
   }

   if (direction == "above")
   {
      HurstExtension[TFCount] = MathAbs(CrossOverValue[TFCount] - LowPoint[TFCount]);
   }
//Alert(TimeFrame2String(CTF), "Hurst = ", DoubleToString((HurstExtension[TFCount] * factor), 2));

   if (!(ED)) // ED = Entry Detection
   {
      MATally += (HurstExtension[TFCount] * factor);
      AvgExt[TFCount] = (MATally / 14);
      gvs(cat(esp, "AvgExt"), AvgExt[TFCount]); // Set a GlobalVariable (only used for monitoring).
   }
   else if (UpdateAverage)
   {
   MATally = AvgExt[TFCount];
   AvgExt[TFCount] = (MATally / 13) + (HurstExtension[TFCount] * factor);
   gvs(cat(esp, "AvgExt"), AvgExt[TFCount]); // To be removed before EA release.
   }

} // End void GetHurstInfo()
So now I can crunch the numbers required for trade management prior to entering a trade by using the average extension, and re-crunch them after a new crossover :)

I hope the code's right, and can be of some use to us all.

Have fun!

Radar =8^)
All times are UTC Page 1 of 1