Requests & Ideas, the beginning - page 145

 
nevar:

Mladen

I downloaded StepMA pdf 4_6.ex4 but .I can not attach it to the chart because I get constantly warning: '' you are trying to use renamed indicator contact TSD'' do you know how to deal with this?

Also what is the reason you excluded high-low mode?

I downloaded it just now (from this post : https://www.mql5.com/en/forum/general) and tested it and all works just fine for me (in bild 840 and in build 950 as well). Please check if the name is that exact name

 

Yes I checked everything but problem still exist.Anyway it is not a big deal.I will use the previous version in ex4 file.

 

hi guys i was thinkin about an idea to measure price moves to find out if trading them is profitable or not ?or tradable at all !! so every price move will start with a fractal (bill williams definition) and end up with a fractal ! each fractal consist 5 candle (or bar) & lets say these candles dont overlap (it's worst case scenario for my idea) with 3bar at leaft one in the middle and two on the right with the middle candle be a fractal (given the bill's definition) . we ,as traders, all want to take trends which is price movement between up/down fractals , right ? but we must wait for 2 candles in future to take place in order to decide . given that we started with 2candle lag in the beginning and 2 candle lag later we give up 4candle(timewise and pipwise) to decide entering and closing (maybe reverse)positions .

so theoretically speaking price move cycles must be at least 8 candle to be at least tradable !! why 8 ? cause risk/reward ratio must be at least 1 to 1 ! we're giving up 2 candle at the beggining of the trend and 2 candle at the end of the trend . it's the time issue of trading !!

 

okay there's another issue with range of candles which i recall later post , but what i'm asking is :

1)what's ur opinion ? (actually it doesnt matter u use fractals or not as long as u use candles for ur decision making process, you're involved)

2)can we use statistic in our advantage in this issue? & by that i mean measure the number of candles between fractals in a time frame for an instrument , and if that number in avg is over 8 candle then that individual time frame for that individual instrument is tradeble (profitable or not!)

i appreciate it if u guys reply .

p.s: for look back period the larger the better !

 

for candles range issue ,i think we must measure the the pips between neighbor fractals in opposite direction and they number must be at 4 to 8times the avg range of candles on that time frame . cause the candles at turning points can be huge right ? and we risk 4 of them for decision making process at the beginning for entering and at the end for exiting ,for maintaining 1 to 1 risk reward ratio & hope of breaking even if price change its direction fast and strong we must have enough pip available between those decision candles.

 
KumoBreake:
hi guys i was thinkin about an idea to measure price moves to find out if trading them is profitable or not ?or tradable at all !! so every price move will start with a fractal (bill williams definition) and end up with a fractal ! each fractal consist 5 candle (or bar) & lets say these candles dont overlap (it's worst case scenario for my idea) with 3bar at leaft one in the middle and two on the right with the middle candle be a fractal (given the bill's definition) . we ,as traders, all want to take trends which is price movement between up/down fractals , right ? but we must wait for 2 candles in future to take place in order to decide . given that we started with 2candle lag in the beginning and 2 candle lag later we give up 4candle(timewise and pipwise) to decide entering and closing (maybe reverse)positions . so theoretically speaking price move cycles must be at least 8 candle to be at least tradable !! why 8 ? cause risk/reward ratio must be at least 1 to 1 ! we're giving up 2 candle at the beggining of the trend and 2 candle at the end of the trend . it's the time issue of trading !!

KumoBreake

From your description those are 6 bars (not 5)

Also, from the Bill Wiliams' definition, nothing prevents fractals to be overlapped (they can happen at the same time - depends on the candles configuration, but it can and is happening more often than we know. Also, a lot of cases when there is no opposite direction fractal, but same direction fractals can happen - they are happening on a regular basis

 
nevar:

Yes I checked everything but problem still exist.Anyway it is not a big deal.I will use the previous version in ex4 file.

Did you solve the problem?
 
mladen:
Did you solve the problem?

Dearest MLADEN

i have a request regarding your new "onChart cci" for adding HA prices,kindly manage time for.already requested but i know your busy time.

regards

here is code "OnChart cci"

//------------------------------------------------------------------
//
//------------------------------------------------------------------
#property indicator_chart_window
#property indicator_buffers 6
#property indicator_color1  clrDodgerBlue
#property indicator_color2  clrGray
#property indicator_color3  clrSandyBrown
#property indicator_color4  clrDodgerBlue
#property indicator_color5  clrSandyBrown
#property indicator_color6  clrSandyBrown
#property indicator_style1  STYLE_DOT
#property indicator_style2  STYLE_DOT
#property indicator_style3  STYLE_DOT
#property indicator_width4  2
#property indicator_width5  2
#property indicator_width6  2
#property strict

//
//
//
//
//

extern int                 CCIPeriod    = 50;             // CCI period
extern ENUM_APPLIED_PRICE  CCIPrice     = PRICE_TYPICAL;  // CCI price
extern double              CCILevel     = 200;            // CCI levels (+ and -, entyer as +)
extern int                 minMaxPeriod = 10;             // Channel period

double upper[], middle[], lower[], value[], valueda[], valuedb[], slope[], orvalue[];

//------------------------------------------------------------------
//
//------------------------------------------------------------------
//
//
//
//

int init()
{
   IndicatorBuffers(8);
   SetIndexBuffer(0,upper);
   SetIndexBuffer(1,middle);
   SetIndexBuffer(2,lower);
   SetIndexBuffer(3,value);
   SetIndexBuffer(4,valueda);
   SetIndexBuffer(5,valuedb);
   SetIndexBuffer(6,orvalue);
   SetIndexBuffer(7,slope);
   return(0);
}
int deinit() { return(0);  }

//------------------------------------------------------------------
//
//------------------------------------------------------------------
//
//
//
//

int start()
{
   int counted_bars=IndicatorCounted();
      if(counted_bars < 0) return(-1);
      if(counted_bars>0) counted_bars--;
         int limit = MathMin(Bars-counted_bars,Bars-1);

   if (slope[limit]==-1) CleanPoint(limit,valueda,valuedb);
   for(int i=limit; i>=0; i--)
   {
      double min = Low [ArrayMinimum(Low ,minMaxPeriod,i)];
      double max = High[ArrayMaximum(High,minMaxPeriod,i)];
      double rng = max-min;
     
      upper[i]   =  max;
      lower[i]   =  min;
      middle[i]  = (min+max)/2.0;
      orvalue[i] = iCCI(NULL,0,CCIPeriod,CCIPrice,i);
      value[i]   = middle[i]+rng*(orvalue[i]/(2*CCILevel));
      valueda[i] = EMPTY_VALUE;
      valuedb[i] = EMPTY_VALUE;
      if (i<Bars-1)
      {
         slope[i] = slope[i+1];
            if (orvalue[i]>orvalue[i+1]) slope[i] =  1;
            if (orvalue[i]<orvalue[i+1]) slope[i] = -1;
      }
      else slope[i] = 0;
      if (slope[i]== -1) PlotPoint(i,valueda,valuedb,value);
   }
   return(0);
}

//-------------------------------------------------------------------
//                                                                 
//-------------------------------------------------------------------
//
//
//
//
//

void CleanPoint(int i,double& first[],double& second[])
{
   if (i>=Bars-3) return;
   if ((second[i]  != EMPTY_VALUE) && (second[i+1] != EMPTY_VALUE))
        second[i+1] = EMPTY_VALUE;
   else
      if ((first[i] != EMPTY_VALUE) && (first[i+1] != EMPTY_VALUE) && (first[i+2] == EMPTY_VALUE))
          first[i+1] = EMPTY_VALUE;
}

void PlotPoint(int i,double& first[],double& second[],double& from[])
{
   if (i>=Bars-2) return;
   if (first[i+1] == EMPTY_VALUE)
      if (first[i+2] == EMPTY_VALUE)
            { first[i]  = from[i];  first[i+1]  = from[i+1]; second[i] = EMPTY_VALUE; }
      else  { second[i] =  from[i]; second[i+1] = from[i+1]; first[i]  = EMPTY_VALUE; }
   else     { first[i]  = from[i];                           second[i] = EMPTY_VALUE; }
}

 

Dear Mladen.

Thanks for your help in times past, and your untiring support to this forum.


I would like to have the classic Bollinger bands modified so that the inputs could be wider.

For instance the Moving average could be changed to EMA, SSMA, or LWMA instead of just the traditional SMA.

The Price field could have the options of Open, Close, High, Low, Median, typical and Weighted.

We would still retain the options to vary the Shift and Standard Deviation to suit the users purposes.

To make it truly exceptional, if the middle line could change colour to show Bullish/Bearish bias.

Thanks in advance.

 
mntiwana:

Dearest MLADEN

i have a request regarding your new "onChart cci" for adding HA prices,kindly manage time for.already requested but i know your busy time.

regards

here is code "OnChart cci"

//------------------------------------------------------------------
//
//------------------------------------------------------------------
#property indicator_chart_window
#property indicator_buffers 6
#property indicator_color1  clrDodgerBlue
#property indicator_color2  clrGray
#property indicator_color3  clrSandyBrown
#property indicator_color4  clrDodgerBlue
#property indicator_color5  clrSandyBrown
#property indicator_color6  clrSandyBrown
#property indicator_style1  STYLE_DOT
#property indicator_style2  STYLE_DOT
#property indicator_style3  STYLE_DOT
#property indicator_width4  2
#property indicator_width5  2
#property indicator_width6  2
#property strict

//
//
//
//
//

extern int                 CCIPeriod    = 50;             // CCI period
extern ENUM_APPLIED_PRICE  CCIPrice     = PRICE_TYPICAL;  // CCI price
extern double              CCILevel     = 200;            // CCI levels (+ and -, entyer as +)
extern int                 minMaxPeriod = 10;             // Channel period

double upper[], middle[], lower[], value[], valueda[], valuedb[], slope[], orvalue[];

//------------------------------------------------------------------
//
//------------------------------------------------------------------
//
//
//
//

int init()
{
   IndicatorBuffers(8);
   SetIndexBuffer(0,upper);
   SetIndexBuffer(1,middle);
   SetIndexBuffer(2,lower);
   SetIndexBuffer(3,value);
   SetIndexBuffer(4,valueda);
   SetIndexBuffer(5,valuedb);
   SetIndexBuffer(6,orvalue);
   SetIndexBuffer(7,slope);
   return(0);
}
int deinit() { return(0);  }

//------------------------------------------------------------------
//
//------------------------------------------------------------------
//
//
//
//

int start()
{
   int counted_bars=IndicatorCounted();
      if(counted_bars < 0) return(-1);
      if(counted_bars>0) counted_bars--;
         int limit = MathMin(Bars-counted_bars,Bars-1);

   if (slope[limit]==-1) CleanPoint(limit,valueda,valuedb);
   for(int i=limit; i>=0; i--)
   {
      double min = Low [ArrayMinimum(Low ,minMaxPeriod,i)];
      double max = High[ArrayMaximum(High,minMaxPeriod,i)];
      double rng = max-min;
     
      upper[i]   =  max;
      lower[i]   =  min;
      middle[i]  = (min+max)/2.0;
      orvalue[i] = iCCI(NULL,0,CCIPeriod,CCIPrice,i);
      value[i]   = middle[i]+rng*(orvalue[i]/(2*CCILevel));
      valueda[i] = EMPTY_VALUE;
      valuedb[i] = EMPTY_VALUE;
      if (i<Bars-1)
      {
         slope[i] = slope[i+1];
            if (orvalue[i]>orvalue[i+1]) slope[i] =  1;
            if (orvalue[i]<orvalue[i+1]) slope[i] = -1;
      }
      else slope[i] = 0;
      if (slope[i]== -1) PlotPoint(i,valueda,valuedb,value);
   }
   return(0);
}

//-------------------------------------------------------------------
//                                                                 
//-------------------------------------------------------------------
//
//
//
//
//

void CleanPoint(int i,double& first[],double& second[])
{
   if (i>=Bars-3) return;
   if ((second[i]  != EMPTY_VALUE) && (second[i+1] != EMPTY_VALUE))
        second[i+1] = EMPTY_VALUE;
   else
      if ((first[i] != EMPTY_VALUE) && (first[i+1] != EMPTY_VALUE) && (first[i+2] == EMPTY_VALUE))
          first[i+1] = EMPTY_VALUE;
}

void PlotPoint(int i,double& first[],double& second[],double& from[])
{
   if (i>=Bars-2) return;
   if (first[i+1] == EMPTY_VALUE)
      if (first[i+2] == EMPTY_VALUE)
            { first[i]  = from[i];  first[i+1]  = from[i+1]; second[i] = EMPTY_VALUE; }
      else  { second[i] =  from[i]; second[i+1] = from[i+1]; first[i]  = EMPTY_VALUE; }
   else     { first[i]  = from[i];                           second[i] = EMPTY_VALUE; }
}

mntiwana


Here is the upgraded version :

//------------------------------------------------------------------
//
//------------------------------------------------------------------
#property indicator_chart_window
#property indicator_buffers 6
#property indicator_color1  clrDodgerBlue
#property indicator_color2  clrGray
#property indicator_color3  clrSandyBrown
#property indicator_color4  clrDodgerBlue
#property indicator_color5  clrSandyBrown
#property indicator_color6  clrSandyBrown
#property indicator_style1  STYLE_DOT
#property indicator_style2  STYLE_DOT
#property indicator_style3  STYLE_DOT
#property indicator_width4  2
#property indicator_width5  2
#property indicator_width6  2
#property strict

//
//
//
//
//

enum enPrices
{
   pr_close,      // Close
   pr_open,       // Open
   pr_high,       // High
   pr_low,        // Low
   pr_median,     // Median
   pr_typical,    // Typical
   pr_weighted,   // Weighted
   pr_average,    // Average (high+low+open+close)/4
   pr_medianb,    // Average median body (open+close)/2
   pr_tbiased,    // Trend biased price
   pr_haclose,    // Heiken ashi close
   pr_haopen ,    // Heiken ashi open
   pr_hahigh,     // Heiken ashi high
   pr_halow,      // Heiken ashi low
   pr_hamedian,   // Heiken ashi median
   pr_hatypical,  // Heiken ashi typical
   pr_haweighted, // Heiken ashi weighted
   pr_haaverage,  // Heiken ashi average
   pr_hamedianb,  // Heiken ashi median body
   pr_hatbiased   // Heiken ashi trend biased price
};

extern int      CCIPeriod    = 50;             // CCI period
extern enPrices CCIPrice     = pr_typical;     // CCI price
extern double   CCILevel     = 200;            // CCI levels (+ and -, entyer as +)
extern int      minMaxPeriod = 10;             // Channel period

double upper[], middle[], lower[], value[], valueda[], valuedb[], slope[], orvalue[], pricef[];

//------------------------------------------------------------------
//
//------------------------------------------------------------------
//
//
//
//

int init()
{
   IndicatorBuffers(9);
   SetIndexBuffer(0,upper);
   SetIndexBuffer(1,middle);
   SetIndexBuffer(2,lower);
   SetIndexBuffer(3,value);
   SetIndexBuffer(4,valueda);
   SetIndexBuffer(5,valuedb);
   SetIndexBuffer(6,orvalue);
   SetIndexBuffer(7,slope);
   SetIndexBuffer(8,pricef);
   return(0);
}
int deinit() { return(0);  }

//------------------------------------------------------------------
//
//------------------------------------------------------------------
//
//
//
//

int start()
{
   int counted_bars=IndicatorCounted();
      if(counted_bars < 0) return(-1);
      if(counted_bars>0) counted_bars--;
         int limit = MathMin(Bars-counted_bars,Bars-1);

   if (slope[limit]==-1) CleanPoint(limit,valueda,valuedb);
   for(int i=limit; i>=0; i--)
   {
      double min = Low [ArrayMinimum(Low ,minMaxPeriod,i)];
      double max = High[ArrayMaximum(High,minMaxPeriod,i)];
      double rng = max-min;
     
      upper[i]   =  max;
      lower[i]   =  min;
      middle[i]  = (min+max)/2.0;
      
      //
      //
      //
      //
      //
      
      pricef[i]  = getPrice(CCIPrice,Open,Close,High,Low,i);
         double avg = 0; 
         double dev = 0; 
            for(int k=0; k<CCIPeriod && (i+k)<Bars; k++) avg += pricef[i+k];              avg /= CCIPeriod;
            for(int k=0; k<CCIPeriod && (i+k)<Bars; k++) dev += MathAbs(pricef[i+k]-avg); dev /= CCIPeriod;
      
      if (dev!=0)
            orvalue[i] = (pricef[i]-avg)/(0.015*dev);
      else  orvalue[i] = 0;
      value[i]   = middle[i]+rng*(orvalue[i]/(2*CCILevel));
      valueda[i] = EMPTY_VALUE;
      valuedb[i] = EMPTY_VALUE;
      if (i<Bars-1)
      {
         slope[i] = slope[i+1];
            if (orvalue[i]>orvalue[i+1]) slope[i] =  1;
            if (orvalue[i]<orvalue[i+1]) slope[i] = -1;
      }
      else slope[i] = 0;
      if (slope[i]== -1) PlotPoint(i,valueda,valuedb,value);
   }
   return(0);
}

//-------------------------------------------------------------------
//                                                                 
//-------------------------------------------------------------------
//
//
//
//
//

void CleanPoint(int i,double& first[],double& second[])
{
   if (i>=Bars-3) return;
   if ((second[i]  != EMPTY_VALUE) && (second[i+1] != EMPTY_VALUE))
        second[i+1] = EMPTY_VALUE;
   else
      if ((first[i] != EMPTY_VALUE) && (first[i+1] != EMPTY_VALUE) && (first[i+2] == EMPTY_VALUE))
          first[i+1] = EMPTY_VALUE;
}

void PlotPoint(int i,double& first[],double& second[],double& from[])
{
   if (i>=Bars-2) return;
   if (first[i+1] == EMPTY_VALUE)
      if (first[i+2] == EMPTY_VALUE)
            { first[i]  = from[i];  first[i+1]  = from[i+1]; second[i] = EMPTY_VALUE; }
      else  { second[i] =  from[i]; second[i+1] = from[i+1]; first[i]  = EMPTY_VALUE; }
   else     { first[i]  = from[i];                           second[i] = EMPTY_VALUE; }
}

//------------------------------------------------------------------
//
//------------------------------------------------------------------
//
//
//
//
//
//

double workHa[][4];
double getPrice(int tprice, const double& open[], const double& close[], const double& high[], const double& low[], int i, int instanceNo=0)
{
  if (tprice>=pr_haclose)
   {
      if (ArrayRange(workHa,0)!= Bars) ArrayResize(workHa,Bars);
         int r = Bars-i-1;
         
         //
         //
         //
         //
         //
         
         double haOpen;
         if (r>0)
                haOpen  = (workHa[r-1][instanceNo+2] + workHa[r-1][instanceNo+3])/2.0;
         else   haOpen  = (open[i]+close[i])/2;
         double haClose = (open[i] + high[i] + low[i] + close[i]) / 4.0;
         double haHigh  = MathMax(high[i], MathMax(haOpen,haClose));
         double haLow   = MathMin(low[i] , MathMin(haOpen,haClose));

         if(haOpen  <haClose) { workHa[r][instanceNo+0] = haLow;  workHa[r][instanceNo+1] = haHigh; } 
         else                 { workHa[r][instanceNo+0] = haHigh; workHa[r][instanceNo+1] = haLow;  } 
                                workHa[r][instanceNo+2] = haOpen;
                                workHa[r][instanceNo+3] = haClose;
         //
         //
         //
         //
         //
         
         switch (tprice)
         {
            case pr_haclose:     return(haClose);
            case pr_haopen:      return(haOpen);
            case pr_hahigh:      return(haHigh);
            case pr_halow:       return(haLow);
            case pr_hamedian:    return((haHigh+haLow)/2.0);
            case pr_hamedianb:   return((haOpen+haClose)/2.0);
            case pr_hatypical:   return((haHigh+haLow+haClose)/3.0);
            case pr_haweighted:  return((haHigh+haLow+haClose+haClose)/4.0);
            case pr_haaverage:   return((haHigh+haLow+haClose+haOpen)/4.0);
            case pr_hatbiased:
               if (haClose>haOpen)
                     return((haHigh+haClose)/2.0);
               else  return((haLow+haClose)/2.0);        
         }
   }
   
   //
   //
   //
   //
   //
   
   switch (tprice)
   {
      case pr_close:     return(close[i]);
      case pr_open:      return(open[i]);
      case pr_high:      return(high[i]);
      case pr_low:       return(low[i]);
      case pr_median:    return((high[i]+low[i])/2.0);
      case pr_medianb:   return((open[i]+close[i])/2.0);
      case pr_typical:   return((high[i]+low[i]+close[i])/3.0);
      case pr_weighted:  return((high[i]+low[i]+close[i]+close[i])/4.0);
      case pr_average:   return((high[i]+low[i]+close[i]+open[i])/4.0);
      case pr_tbiased:   
               if (close[i]>open[i])
                     return((high[i]+close[i])/2.0);
               else  return((low[i]+close[i])/2.0);        
   }
   return(0);
}