Help on Goodman Swing Chart

 

Hi, my general objective is a Goodman Swing Chart indicator as those described by Michael Archer. So I was thinking of starting with analyzing directions, it’s worth noticing that I reorganize the array I store them in for a future synchronization, but it is totally disposable. The problem I have is that when the indicator is drawn it doesn’t show all changing direction points (or inflexion points), a problem of concept I think. Any help in this code or in the general guideline will be very much appreciated.

//+------------------------------------------------------------------+
//|                                                  DrawingTest.mq4 |
//|                      Copyright © 2009, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Red
#include <stdlib.mqh>

int direccion[3];
int dirNew;
int i;

double buff[];

void reorg_direc()                  //Function which makes the new element first and all others take one numerically higher place 
{

   direccion[2] = direccion[1];     //Last element is lost
   direccion[1] = direccion[0];
   direccion[0] = dirNew;           //New element takes first place, given by variable

}

void close2dir()                 //Creates a trend direction from closing price
{

   if (Close[i] > Close[i+1])            //If last closing price is greater than the second to last
   {   
      dirNew = 111;                    //Then direction will be upward, given by a 111 code stored in this variable
      reorg_direc();                   //Reorganizes direction array 
   }
   else if (Close[i] < Close[i+1])       //If second to last closing price is greater than the last
   {
      dirNew = 222;                    //Then direction will be downward, given by a 222 code stored in this variable
      reorg_direc();                   //Reorganizes direction array
   }
   else
   {
      dirNew = 333;                    //Otherwise direction is the same as the previous one
      reorg_direc();                   //Reorganizes direction array
   }

}

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexBuffer (0, buff);
   SetIndexStyle (0,DRAW_LINE,STYLE_SOLID,2);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int err;
   int counted_bars=IndicatorCounted();
   i = Bars-counted_bars-1;           
//----
   Comment("Counted Bars: " + counted_bars, "\n", "Bars: " + Bars, "\n", "Dir 2: " + direccion[2], "\n","Dir 1: " + direccion[1], "\n","Dir 0: " + direccion[0], "\n","Dir New: " + dirNew);
   
   
   
   while(i>0)
   {
     close2dir();
     Print("Dir New: " + dirNew);
     Print("Close first: " + Close[i+1]," ", "Close second: " + Close[i]);
     if(dirNew!= direccion[1])
      buff[i] = Close[i];
     Print("i: " + i); 
     Print("Buffer i: " + buff[i]);
     i--;                 //Step down until current bar reached
   }
   //Print("i: " + i);
   err = GetLastError();
   
   if(err>0)
      Print("ERROR: " + ErrorDescription(err));
//----
   return(0);
  }
//+------------------------------------------------------------------+

 
JTowers wrote >>

Hi, my general objective is a Goodman Swing Chart indicator as those described by Michael Archer. So I was thinking of starting with analyzing directions, it’s worth noticing that I reorganize the array I store them in for a future synchronization, but it is totally disposable. The problem I have is that when the indicator is drawn it doesn’t show all changing direction points (or inflexion points), a problem of concept I think. Any help in this code or in the general guideline will be very much appreciated.

can u point out where this goodman can be read so that we know the principles before we can comment on the code

 

The book that best describes it is Forex Chartist by the author mentioned above. Yet I’m trying to get permission to post an image from the book or, on its failiure, a replica of it. Basically it concerns swing charting on the fact that it filters noise by two external variables which are the box size and the reversal amount. The difference is that this chart is attached to a bar chart (mostly), making a transition from price specific to time specific charting. I’ll have the image posted by tomorrow whether it be the book’s or my replica of it.

Thanks for the reply ronaldosim.

Reason: