Focal Candle Light

Keeping the candle lit on a low burner.

A quick, 1-hour conversion of my routine Focal Candle Histogram’s main signals from ThinkOrSwim.

#property copyright   "2019, Macdulio"
#property link        "https://forexfore.blog"
#property description "Focal Candle Light"
#property strict
extern double FSize=32;
double FMax = FSize*6/5;
#property indicator_separate_window
#property indicator_minimum    6
#property indicator_maximum    24
#property indicator_buffers    2
#property indicator_color1     Blue
#property indicator_color2     Red

extern int multi = 5;
double span = 0.003;
double zz_h[];  //iCustom (NULL,0,"ZigZag", 12,5,3, 1,0); 
double zz_l[]; //iCustom (NULL,0,"ZigZag", 12,5,3, 2,0);
bool c[], c2[];
double SLK[],SLKD[];
double NONE[],ONE[];
double dlin[],dl[];
double average[];
int register[], summation[];
//---------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit(void)
  {
   string symbol = Symbol();
   IndicatorBuffers(2);
   SetIndexStyle(0,DRAW_LINE,EMPTY,18,indicator_color1);
   SetIndexBuffer(0, ONE);
   SetIndexStyle(1,DRAW_LINE,EMPTY,18,indicator_color2);
   SetIndexBuffer(1,NONE);

//---
    return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Stochastic oscillator                                            |
//+------------------------------------------------------------------+
int start()
  {
   int    i,j;
   string symbol = Symbol();
      ArrayResize(dl, 600);   
 ArrayInitialize(dl, EMPTY_VALUE); 
     ArrayResize(dlin, 600);   
 ArrayInitialize(dlin, 0); 
      ArrayResize(zz_h, 600);   
 ArrayInitialize(zz_h, 0); 
      ArrayResize(zz_l, 600);   
 ArrayInitialize(zz_l, 0);  
    ArrayResize(NONE, 600);   
 ArrayInitialize(NONE, EMPTY_VALUE);  
     ArrayResize(ONE, 600);   
 ArrayInitialize(ONE, EMPTY_VALUE); 
  ArrayResize(SLK, 600);   
 ArrayInitialize(SLK, EMPTY_VALUE);  
  ArrayResize(SLKD, 600);   
 ArrayInitialize(SLKD, EMPTY_VALUE);  
   ArrayResize(c, 600);   
 ArrayInitialize(c, false); 
   ArrayResize(c2, 600);   
 ArrayInitialize(c2, false);
   ArrayResize(summation, 600);   
 ArrayInitialize(summation,  0);  
   ArrayResize(register, 600);   
 ArrayInitialize(register,  0);  
    ArrayResize(average, 600);   
 ArrayInitialize(average,  0);  


   dlin[598]=1000;
   for(i=597; i>=0; i--){
      dlin[i]=dlin[i+1];
      dl[i]=dl[i+1];
      register[i]=register[i+1];
         c[i] = (High[i+2]-Low[i+2])*multi<(High[i+1]-Low[i+1]);
         c2[i] = (High[i+3]-Low[i+3])*multi<(High[i+2]-Low[i+2]); 
         SLK[i]=iStochastic(symbol,0,14,3,3,MODE_SMA,0,MODE_MAIN,i);
         SLKD[i]=iStochastic(symbol,0,14,3,3,MODE_SMA,0,MODE_SIGNAL,i);
         zz_h[i]=iCustom (NULL,0,"ZigZag", 12,5,3, 1,i); 
         zz_l[i]=iCustom (NULL,0,"ZigZag", 12,5,3, 2,0);
         if (zz_h[i]==0 && zz_h[i+1]>0) dlin[i]=iLow(symbol,0,iLowest(symbol,0,MODE_LOW,4,i+1));
         if (dlin[i]<.02) dl[i]=Low[i];
         else dl[i]=dlin[i];
         if (dl[i]>High[i]) register[i]=-1;  
         else register[i]=1;
         if (i<500) { for(j=i; j<=i+16; j++) summation[i] += register[j];}
              
    
     } 
     
deletetxt1("ONE");
deletetxt1("NONE");

///One (blue) None (red)

for(i=300; i>=0; i--){
   if (SLK[i]>80) ONE[i]=20;   
   
   if (ONE[i]!=20 && ONE[i+1]==20 && ONE[i+2]==20) {
   ObjectCreate("ONEx"+IntegerToString(i), OBJ_TEXT, 0, Time[i+8], iHigh(symbol,0,iHighest(symbol,0,MODE_HIGH,5,i))+55*Point);  
      ObjectSetText("ONEx"+IntegerToString(i), "Sell thrust into resistance "+NormalizeDouble(iHigh(symbol,0,iHighest(symbol,0,MODE_HIGH,5,i)),4), 18, "Arial Black",  clrBlue);
      ObjectCreate("ONE"+IntegerToString(i), OBJ_TEXT, 0, Time[i+8], iHigh(symbol,0,iHighest(symbol,0,MODE_HIGH,5,i))+55*Point);  
      ObjectSetText("ONE"+IntegerToString(i), " Sell thrust into resistance "+NormalizeDouble(iHigh(symbol,0,iHighest(symbol,0,MODE_HIGH,5,i)),4), 18, "Arial Black",  clrWhite);}
    
   if (summation[i]<0 && SLK[i]<20 && Low[i]<iMA(NULL,0,828,0,MODE_EMA, PRICE_LOW,i)-FMax*2.5*10*Point) NONE[i]=10;
   
   if (NONE[i]!=10 && NONE[i+1]==10 && NONE[i+2]==10) {
    ObjectCreate("NONEx"+IntegerToString(i), OBJ_TEXT, 0, Time[i+8], iLow(symbol,0,iLowest(symbol,0,MODE_LOW,5,i))-25*Point);  
      ObjectSetText("NONEx"+IntegerToString(i), "Buy thrust into support "+NormalizeDouble(iLow(symbol,0,iLowest(symbol,0,MODE_LOW,5,i)),4), 18, "Arial Black",  clrCrimson);
    ObjectCreate("NONE"+IntegerToString(i), OBJ_TEXT, 0, Time[i+8], iLow(symbol,0,iLowest(symbol,0,MODE_LOW,5,i))-25*Point);  
      ObjectSetText("NONE"+IntegerToString(i), " Buy thrust into support "+NormalizeDouble(iLow(symbol,0,iLowest(symbol,0,MODE_LOW,5,i)),4), 18, "Arial Black",  clrWhite);}
   
}
  return(0);
}
//+------------------------------------------------------------------+
    void deletetxt1(string text){
   for(int iObj=ObjectsTotal()-1; iObj >= 0; iObj--){
      string   on = ObjectName(iObj);
      if(StringFind(on, text) == 0)  ObjectDelete(on);
}  }

Current support and resistance levels listed below

Playing it right could had yielded 200% gains on Friday, not the measly 22% that I made. I had to eliminate the re-targeting for magic number 0 and I needed to figure out how to stay in the market. This indicator is my answer.

As for the how far you can go – these numbers were on the screen before even the two sell-off dips occurred>

1.11532 was in the ballpark, don’t you think?

Support – Resistance

This is a program on your own section – well, almost.

 RSI2[i]=iRSI(symbol,0,2,PRICE_MEDIAN,i);
j2=1;
   while (j2<100 ){
    j=j2+2; 
      if (DML[j]==EMPTY_VALUE && RSI2[j2]<RSI2[j2+1] && RSI2[j2-1]>RSI2[j2] && RSI2[j2]<32) 
         while (j<j2+26){
               if (DML[j]!=EMPTY_VALUE && RSI2[j2]>RSI2[j] && Low[j2]<=Low[j]+40*Point && RSI2[j2]<RSI2[j2+1]  && RSI2[j2-1]>RSI2[j2] ) break;
      j++;}
    if (DML[j]!=EMPTY_VALUE && RSI2[j2]>RSI2[j] && Low[j2]<=Low[j]+40*Point && RSI2[j2]<RSI2[j2+1]  && RSI2[j2-1]>RSI2[j2]) break;
     j2++;}  


if (j2<100 && DML[j]!=EMPTY_VALUE && Low[j2]<=Low[j]+40*Point ) {LowFractalTime_2=iTime(NULL, 0,j2);    LowFractalTime_1=iTime(NULL, 0,j);    }





 if (j<100 && j<j2+26)   {
 
 if(j2-4>=0){
            ObjectCreate(0,"TRIAGE"+j,OBJ_TRIANGLE,0,Time[j],Low[j],Time[j],iLow(symbol,0,iLowest(symbol,0,MODE_LOW,4,j2-1)),Time[j2-4],(iLow(symbol,0,iLowest(symbol,0,MODE_LOW,4,j2-1))+Low[j])/2);
            ObjectSetInteger(0,"TRIAGE"+j,OBJPROP_COLOR,clrGray);  ObjectSetInteger(0,"TRIAGE"+j,OBJPROP_WIDTH,2); ObjectSetInteger(0,"TRIAGE"+j,OBJPROP_BACK,1); 
             ObjectCreate("ANGLi"+j, OBJ_TEXT, 0, Time[j2],  ((iLow(symbol,0,iLowest(symbol,0,MODE_LOW,4,j2-1))+Low[j])/2)+28*Point);  
             ObjectSetText("ANGLi"+j, "Sup->"+NormalizeDouble((iLow(symbol,0,iLowest(symbol,0,MODE_LOW,4,j2-1))+Low[j])/2,4), 22, "Arial Black",  Black);  
 }
   
      ObjectDelete(0,"cNNN3_2");
     ObjectCreate(0,"cNNN3_2",OBJ_TREND,2,LowFractalTime_1,RSI2[j],LowFractalTime_2,RSI2[j2]);
    ObjectSetInteger(0,"cNNN3_2",OBJPROP_RAY_RIGHT,false);
    if (stoch2[j]<20 && stoch2[j2-1]<20 && RSI2[j2]>23)  ObjectSet("cNNN3_2",OBJPROP_COLOR,clrRed);
      else   ObjectSet("cNNN3_2",OBJPROP_COLOR,indicator_color1);
         ObjectSet("cNNN3_2",OBJPROP_WIDTH,8); 
         ObjectSet("cNNN3_2",OBJPROP_BACK,1); }
 



i2=1;
   while (i2<100 ){
    i=i2+2; 
      if (UML[i]==EMPTY_VALUE && RSI2[i2]>RSI2[i2+1] && RSI2[i2-1]<RSI2[i2] && RSI2[i2]>70) 
         while (i<i2+26){
               if (UML[i]!=EMPTY_VALUE && RSI2[i2]<RSI2[i] && High[i2]>=High[i]-40*Point && RSI2[i2]>RSI2[i2+1]  && RSI2[i2-1]<RSI2[i2] ) break;
      i++;}
    if (UML[i]!=EMPTY_VALUE && RSI2[i2]<RSI2[i] && High[i2]>=High[i]-40*Point && RSI2[i2]>RSI2[i2+1]  && RSI2[i2-1]<RSI2[i2]) break;
     i2++;}  


if (i2<100 && UML[i]!=EMPTY_VALUE && High[i2]>=High[i]-40*Point ) {UpFractalTime_2=iTime(NULL, 0,i2);    UpFractalTime_1=iTime(NULL, 0,i);    }


 if (i<100 && i<i2+26)   {
 
  if(i2-4>=0){
            ObjectCreate(0,"TRIAGE"+i,OBJ_TRIANGLE,0,Time[i],High[i],Time[i],iHigh(symbol,0,iHighest(symbol,0,MODE_HIGH,4,i2)),Time[i2-4],(iHigh(symbol,0,iHighest(symbol,0,MODE_HIGH,4,i2))+High[i])/2);
            ObjectSetInteger(0,"TRIAGE"+i,OBJPROP_COLOR,clrGray);  ObjectSetInteger(0,"TRIAGE"+i,OBJPROP_WIDTH,2); ObjectSetInteger(0,"TRIAGE"+i,OBJPROP_BACK,1); 
             ObjectCreate("ANGL"+i, OBJ_TEXT, 0, Time[i2],  ((iHigh(symbol,0,iHighest(symbol,0,MODE_HIGH,4,i2))+High[i])/2)+88*Point);  
             ObjectSetText("ANGL"+i, "Res->"+NormalizeDouble((iHigh(symbol,0,iHighest(symbol,0,MODE_HIGH,4,i2))+High[i])/2,4), 22, "Arial Black",  Black);  
 }
 
 ObjectDelete(0,"ccNN3_2");
     ObjectCreate(0,"ccNN3_2",OBJ_TREND,2,UpFractalTime_1,RSI2[i],UpFractalTime_2,RSI2[i2]);
    ObjectSetInteger(0,"ccNN3_2",OBJPROP_RAY_RIGHT,false);
    if (stoch2[i]>75 && stoch2[i2]>75 && RSI2[i2]<77)  ObjectSet("ccNN3_2",OBJPROP_COLOR,clrGreen);
     else    ObjectSet("ccNN3_2",OBJPROP_COLOR,indicator_color1);
         ObjectSet("ccNN3_2",OBJPROP_WIDTH,8); 
         ObjectSet("ccNN3_2",OBJPROP_BACK,1); }


int keepj2=j2+4;
int keepi2=i2+4; 
White ticker-tocker: support and resistance levels
As for the thin white line, it is c0[i]=(c11[i+7]+c22[i+7])/2

Anticipation of a Reversal

What makes price turn around?

A change (a break) in the order flow.

Market profile is one tool that can point out possible areas of a stall / reaction that may ultimately result in a reversal.

Number of 30-minute blocks spent at a given price level. Price usually skids a bit further.

The order flow isn’t visible for forex traders in general, this is something to have to qualify for, and is called Level 2 – the typical use is Futures trading.

You can imagine the “at ladder screen” showing the number of contracts requested / offered at the given level.

Although most larger firms go out of their ways to hide the volume they are trying to accumulate without unintentionally triggering a reversal, there are others with different intentions: they are trying to spoof the market into a reversal by placing an outrageous sized pending order – that they usually pull at the last second – what can you lose, the broker would only give you a partial fill at the maximum size your account can afford, as a worst case scenario.

Your anticipation therefore should be an educated guess of the level where a likely change in behaviour / order flow can happen.

Another hint, that is actually accessible on top of the fore mentioned two, is the RSI2 reversal divergence.

The triangle sharp ends are the averages of the 4H divergences. What are the support and resistance levels, if not these?

The reason for a divergence is that the trajectory of an incline/decline was broken by an accumulation / distribution, and since there are now participants holding the bag – they are under water ever since they opened, they would likely want to get rid of their unwanted positions for a break even, plus those, whom are in gains, may just have their 1-pip beyond the opening price protective stop loss placed. These events may tip the fragile balance of the scale that has been fueling the progress in a direction.

If you can point out these levels before hand then you can prepare on time to make the necessary changes.

Pompideu (Ci below vol bracket)

My idea for the day is utilizing the spike below the volatility bracket of the 7-sample consolidation indicator for a well determined entry point to start defying a move.

It is so simple, that it is almost elegant. You would need to have it as the first indicator below to have the plots show right.

#property copyright "Copyright © 2009, David Moser, Copyright © 2019, Macdulio"
#property link      "https://forexfore.blog"
#property description "Choppiness indicator with daily reversal signals"

// This Indicator is NEVER to be SOLD individually 
// This Indicator is NEVER to be INCLUDED as part of a collection that is SOLD

//---- common control defaults
#property indicator_separate_window
#property indicator_minimum 24
#property indicator_maximum 64
#property indicator_buffers 3
#property indicator_color1 Cyan
#property indicator_color2 Yellow
#property indicator_color3 Crimson
#property indicator_width1 3
#property indicator_style1 0
#property indicator_color2 Navy
#property indicator_width2 1
#property indicator_style2 0
#property indicator_color3 Navy
#property indicator_width3 1
#property indicator_style3 0
#property indicator_level1  34
#property indicator_level2  53
#property indicator_levelstyle 2
#property indicator_levelcolor Maroon
 
//---- indicator parameters
// Main Parameters
extern int ChoppinessPeriod=7;        // Number of bars to evaluation CI
extern int SmoothingPeriod=1;          // Number of bars to apply SMA
extern int StdDevPeriod=7;            // Number of bars to evaluate Standard Deviation of the CI
extern bool StdDevFollowPrice=false;   // True, StdDev bars follow price, False, StdDev bars centered on 50
extern bool EnableAlertOnHigh=false;   // Alert setting for entering time of choppiness
extern double AlertHighVal=62;       // Default value based on fib numbers
extern bool EnableAlertOnLow=false;    // Alert setting for entering time of trending
extern double AlertLowVal=34;        // Default value based on fib numbers
extern int MaxCalcBars=100;           // Limit calculations back this many bars
extern bool plot_reminders = false;
//---- indicator buffers
double ExtMapBuffer[];
double CI[];
double StdDevHiBuffer[];
double StdDevLoBuffer[];
double IntMapBuffer[];
double IntStdDevBuffer[];
extern bool plot_CI_divergences = true;
//---- variables
string symbol = Symbol();
string TimeFrame;
datetime LastAlert=0;
datetime LowFractalTime_1, LowFractalTime_2;
datetime UpFractalTime_1, UpFractalTime_2;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
 
   IndicatorBuffers(5);
   SetIndexStyle(0,DRAW_LINE,EMPTY,5);
   SetIndexBuffer(0,ExtMapBuffer);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,StdDevHiBuffer);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,StdDevLoBuffer);
   SetIndexBuffer(3,IntMapBuffer);
   SetIndexBuffer(4,IntStdDevBuffer);
   
   if (ChoppinessPeriod<2) ChoppinessPeriod = 2;   // Any lower and this indicator isn't relevant
   if (SmoothingPeriod<1) SmoothingPeriod = 1;     // Avoid configuration errors
   if (StdDevPeriod<2) StdDevPeriod = 2;           // Any lower and the Standard Deviation isn't relevant
   if (MaxCalcBars>10000) MaxCalcBars = 10000;     // Any higher and may adversely affect performance on multi-chart setups
   
   SetIndexDrawBegin(0,ChoppinessPeriod+SmoothingPeriod);
   SetIndexDrawBegin(1,ChoppinessPeriod+SmoothingPeriod+StdDevPeriod);
   SetIndexDrawBegin(2,ChoppinessPeriod+SmoothingPeriod+StdDevPeriod);
   
   string short_name="Choppiness Index ("+ChoppinessPeriod+","+SmoothingPeriod+","+StdDevPeriod+")";
   IndicatorShortName(short_name);

   switch (Period())
     {
     case     1: TimeFrame = "M1";  break;
     case     5: TimeFrame = "M5";  break;
     case    15: TimeFrame = "M15"; break;
     case    30: TimeFrame = "M30"; break;
     case    60: TimeFrame = "H1";  break;
     case   240: TimeFrame = "H4";  break;
     case  1440: TimeFrame = "D1";  break;
     case 10080: TimeFrame = "W1";  break;
     case 43200: TimeFrame = "MN";  break;
   }

//---- initial zero
   for(int i=0;i<=Bars;i++) ExtMapBuffer[i]=0;  // Smoothed & visible main indicator line
   for(i=0;i<=Bars;i++) StdDevHiBuffer[i]=0;    // Upper StdDev band, visible
   for(i=0;i<=Bars;i++) StdDevLoBuffer[i]=0;    // Lower StdDev band, visible
   for(i=0;i<=Bars;i++) IntMapBuffer[i]=0;      // Raw CI, not smoothed, not visible
   for(i=0;i<=Bars;i++) IntStdDevBuffer[i]=0;   // Raw StdDev of Smoothed & visible main indicator line (ExtMapBuffer)

   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
  ArrayResize(CI, Bars);
  ArrayInitialize(CI, EMPTY_VALUE); 
  int counted_bars=IndicatorCounted();
  int i, i2,j2, z,limit;
  double bufferTemp1, bufferTemp2;

  if (counted_bars<0) return(-1); 
  if (counted_bars>0) counted_bars--; 
  limit=Bars-counted_bars;
  if (limit>MaxCalcBars) limit=MaxCalcBars;
  
  for (i=limit-1; i>=0; i--) 
    {
    IntMapBuffer[i] = ChoppinessIndex(ChoppinessPeriod,i);
    bufferTemp1 = 0;
    for(int j=0; j<SmoothingPeriod; j++) { z=i+j; bufferTemp1 += IntMapBuffer[z]; }
    ExtMapBuffer[i] = bufferTemp1 / SmoothingPeriod;
    IntStdDevBuffer[i] = StdDev(i,StdDevPeriod);
    bufferTemp1 = 0;
    bufferTemp2 = 0;
    for(int n=0; n<StdDevPeriod; n++)
      {
      z=i+n;
      if (StdDevFollowPrice)
        {
        bufferTemp1 += ExtMapBuffer[z];
        bufferTemp2 += ExtMapBuffer[z];
        }
      else
        {
        bufferTemp1 += 50;
        bufferTemp2 += 50;
        }
      bufferTemp1 += IntStdDevBuffer[i]*2;
      bufferTemp2 -= IntStdDevBuffer[i]*2;
      }
    StdDevHiBuffer[i] = bufferTemp1 / StdDevPeriod;
    StdDevLoBuffer[i] = bufferTemp2 / StdDevPeriod;
    }

    if (EnableAlertOnHigh)
      if (LastAlert != Time[0])
        if ((ExtMapBuffer[1]>AlertHighVal) && (ExtMapBuffer[2]<AlertHighVal))
          {
          LastAlert = Time[0]; // No more alerts on the current bar
          Alert(Symbol()+","+TimeFrame+":Choppiness greater than "+DoubleToStr(AlertHighVal,1));
          }
    
    if (EnableAlertOnLow)
      if (LastAlert != Time[0])
        if ((ExtMapBuffer[1]<AlertLowVal) && (ExtMapBuffer[2]>AlertLowVal))
          {
          LastAlert = Time[0]; // No more alerts on the current bar
          Alert(Symbol()+","+TimeFrame+":Choppiness less than "+DoubleToStr(AlertLowVal,1));
          }

  for (i = 310 ; i >= 0; i--) 
      CI[i]=ChoppinessIndex(7,i);


deletetxt1("Take");

deletetxt1("Push");

 if ( Period()==30 && (
   (ChoppinessIndex240(7,1)>53 && ChoppinessIndex240(7,0)<53)
  || (ChoppinessIndex240(7,2)>53 && ChoppinessIndex240(7,1)<53)
  || (ChoppinessIndex240(7,3)>53 && ChoppinessIndex240(7,2)<53)
   || (ChoppinessIndex240(7,4)>53 && ChoppinessIndex240(7,3)<53)
   || (ChoppinessIndex240(7,5)>53 && ChoppinessIndex240(7,4)<53)
    || (ChoppinessIndex240(7,6)>53 && ChoppinessIndex240(7,5)<53)
     || (ChoppinessIndex240(7,7)>53 && ChoppinessIndex240(7,6)<53)
  )){
 ObjectCreate("Takeni",OBJ_TEXT, 1, Time[14], 64);
                 ObjectSetText("Takeni", "4H in Push - Do not close Hedge until ", 23, "Arial Black", clrWhite);

 ObjectCreate("Pushi",OBJ_TEXT, 1, Time[14], 54);
                 ObjectSetText("Pushi", "Red Tail New Low/High and CI4H<36", 23, "Arial Black", clrPurple);
}

if (plot_reminders){
   ObjectCreate("Taken",OBJ_TEXT, 1, Time[14], 64);
                 ObjectSetText("Taken", "Take a position", 33, "Arial Black", clrWhite);

 ObjectCreate("Push",OBJ_TEXT, 1, Time[14], 54);
                 ObjectSetText("Push", "Push Against OB/OS Line", 23, "Arial Black", clrMoccasin);}
                 

i=1;

deletetxt1("HLLN");

while (i<100 && !(ChoppinessIndexD(7,i)<38 && ChoppinessIndexD(7,i+1)>38 && iLow(symbol,1440,i+1)>iLow(symbol,1440,i+2) && iLow(symbol,1440,i+2)>iLow(symbol,1440,i+3) && iLow(symbol,1440,i+3)>iLow(symbol,1440,i+4)))
   i++;
   
if (ChoppinessIndexD(7,i)<38 && ChoppinessIndexD(7,i+1)>38 && iLow(symbol,1440,i+1)>iLow(symbol,1440,i+2) && iLow(symbol,1440,i+2)>iLow(symbol,1440,i+3) && iLow(symbol,1440,i+3)>iLow(symbol,1440,i+4) && i<100)   {
               
               
               ObjectCreate( "HLLN"+IntegerToString(i), OBJ_HLINE, 0, Time[0], iHigh(symbol,1440,iHighest(symbol,1440,MODE_HIGH,6,i-1)) );
               ObjectSet("HLLN"+IntegerToString(i), OBJPROP_COLOR, clrWhite );
               ObjectSet("HLLN"+IntegerToString(i), OBJPROP_STYLE, 4 );
               
               
               for (j=1; j<=7; j++) {
               
               ObjectCreate( "HLLNj"+IntegerToString(j), OBJ_HLINE, 0, Time[0],  iHigh(symbol,1440,iHighest(symbol,1440,MODE_HIGH,6,i-1))-160*j*Point );
               ObjectSet("HLLNj"+IntegerToString(j), OBJPROP_COLOR, clrWhite );
               ObjectSet("HLLNj"+IntegerToString(j), OBJPROP_STYLE, 4 );
               }
               
               
                 for (j=1; j<=6; j++) {
               
               ObjectCreate( "HLLNjj"+IntegerToString(j), OBJ_HLINE, 0, Time[0],  iHigh(symbol,1440,iHighest(symbol,1440,MODE_HIGH,6,i-1))+160*j*Point );
               ObjectSet("HLLNjj"+IntegerToString(j), OBJPROP_COLOR, clrPink );
               ObjectSet("HLLNjj"+IntegerToString(j), OBJPROP_STYLE, 4 );
               }
           
               
               }     

i=1;               

while (i<100 && !(ChoppinessIndexD(7,i)<38 && ChoppinessIndexD(7,i+1)>38 && iLow(symbol,1440,i+1)<iLow(symbol,1440,i+2) && iLow(symbol,1440,i+2)<iLow(symbol,1440,i+3) && iLow(symbol,1440,i+3)<iLow(symbol,1440,i+4)))
   i++;


if (ChoppinessIndexD(7,i)<38 && ChoppinessIndexD(7,i+1)>38 && iLow(symbol,1440,i+1)<iLow(symbol,1440,i+2) && iLow(symbol,1440,i+2)<iLow(symbol,1440,i+3) && iLow(symbol,1440,i+3)<iLow(symbol,1440,i+4) && i<100)   {
               
               
               ObjectCreate( "HLLNx"+IntegerToString(i), OBJ_HLINE, 0, Time[0], iLow(symbol,1440,iLowest(symbol,1440,MODE_LOW,6,i-1)) );
               ObjectSet("HLLNx"+IntegerToString(i), OBJPROP_COLOR, clrYellow );
               ObjectSet("HLLNx"+IntegerToString(i), OBJPROP_STYLE, 4 );
               
               
               for (j=1; j<=7; j++) {
               
               ObjectCreate( "HLLNjx"+IntegerToString(j), OBJ_HLINE, 0, Time[0],  iLow(symbol,1440,iLowest(symbol,1440,MODE_LOW,6,i-1))+160*j*Point );
               ObjectSet("HLLNjx"+IntegerToString(j), OBJPROP_COLOR, clrYellow );
               ObjectSet("HLLNjx"+IntegerToString(j), OBJPROP_STYLE, 4 );
               }
               
               
                  for (j=1; j<=6; j++) {
               
               ObjectCreate( "HLLNjxx"+IntegerToString(j), OBJ_HLINE, 0, Time[0],  iLow(symbol,1440,iLowest(symbol,1440,MODE_LOW,6,i-1))-160*j*Point );
               ObjectSet("HLLNjxx"+IntegerToString(j), OBJPROP_COLOR, clrOrange );
               ObjectSet("HLLNjxx"+IntegerToString(j), OBJPROP_STYLE, 4 );
               }
               
           
               
               }     
                           
                 

deletetxt1("bNNN");

if (plot_CI_divergences){ 

i2=1;
   while (i2<300 ){
    i=i2+2; 
      if (Low[i2]<Low[i2+2] && Low[i2+2]<Low[i2+3] && CI[i2]<CI[i2+1] && CI[i2-1]>CI[i2] && CI[i2]<45) 
         while (i<i2+30){
               if (CI[i2]>CI[i] && CI[i]<CI[i-1] && CI[i]<CI[i+1] && CI[i]<33 && Low[i]<Low[i+1] && Low[i+1]<Low[i+2] && Low[i2]<Low[i2+2] && Low[i2+2]<Low[i2+3] && CI[i2]<CI[i2+1] && CI[i2-1]>CI[i2] && CI[i2]<45 ) break;
      i++;}
    if (CI[i2]>CI[i] && CI[i]<CI[i-1] && CI[i]<CI[i+1] && CI[i]<33 && Low[i]<Low[i+1] && Low[i+1]<Low[i+2] && Low[i2]<Low[i2+1] && Low[i2+2]<Low[i2+3] && CI[i2]<CI[i2+1] && CI[i2-1]>CI[i2] && CI[i2]<45 ) break;
     i2++;}  


if (i2<300 &&  High[i]>High[i+2] && High[i+2]>High[i+3] ) {UpFractalTime_2=iTime(NULL, 0,i2);    UpFractalTime_1=iTime(NULL, 0,i);    }


 if (i<300 && i<i2+30)   {ObjectDelete(0,"bNNN3_2");
     ObjectCreate(0,"bNNNm3_2",OBJ_TREND,1,UpFractalTime_1,CI[i],UpFractalTime_2,CI[i2]);
    ObjectSetInteger(0,"bNNNm3_2",OBJPROP_RAY_RIGHT,false);
         ObjectSet("bNNNm3_2",OBJPROP_COLOR,indicator_color3);
         ObjectSet("bNNNm3_2",OBJPROP_WIDTH,8); 
         ObjectSet("bNNNm3_2",OBJPROP_BACK,1); }



j2=1;
   while (j2<300 ){
    j=j2+2; 
      if (Low[j2]<Low[j2+2] && Low[j2+2]<Low[j2+3] && CI[j2]<CI[j2+1] && CI[j2-1]>CI[j2] && CI[j2]<45) 
         while (j<j2+30){
               if (CI[j2]>CI[j] && CI[j]<CI[j-1] && CI[j]<CI[j+1] && CI[j]<33 && Low[j]<Low[j+1] && Low[j+1]<Low[j+2] && Low[j2]<Low[j2+2] && Low[j2+2]<Low[j2+3] && CI[j2]<CI[j2+1] && CI[j2-1]>CI[j2] && CI[j2]<45 ) break;
      j++;}
    if (CI[j2]>CI[j] && CI[j]<CI[j-1] && CI[j]<CI[j+1] && CI[j]<33 && Low[j]<Low[j+1] && Low[j+1]<Low[j+2] && Low[j2]<Low[j2+2] && Low[j2+2]<Low[j2+3] && CI[j2]<CI[j2+1] && CI[j2-1]>CI[j2] && CI[j2]<45 ) break;
     j2++;}  


if (j2<300 &&  Low[j]<Low[j+2] && Low[j+2]<Low[j+3] ) {LowFractalTime_2=iTime(NULL, 0,j2);    LowFractalTime_1=iTime(NULL, 0,j);    }


 if (j<300 && j<j2+30)   {ObjectDelete(0,"bNNN3_2");
     ObjectCreate(0,"bNNN3_2",OBJ_TREND,1,LowFractalTime_1,CI[j],LowFractalTime_2,CI[j2]);
    ObjectSetInteger(0,"bNNN3_2",OBJPROP_RAY_RIGHT,false);
         ObjectSet("bNNN3_2",OBJPROP_COLOR,indicator_color2);
         ObjectSet("bNNN3_2",OBJPROP_WIDTH,8); 
         ObjectSet("bNNN3_2",OBJPROP_BACK,1); }
         
         
int keepj2 = j2;         


j2=keepj2+30;
   while (j2<300 ){
    j=j2+2; 
      if (Low[j2]<Low[j2+2] && Low[j2+2]<Low[j2+3] && CI[j2]<CI[j2+1] && CI[j2-1]>CI[j2] && CI[j2]<45) 
         while (j<j2+30){
               if (CI[j2]>CI[j] && CI[j]<CI[j-1] && CI[j]<CI[j+1] && CI[j]<33 && Low[j]<Low[j+1] && Low[j+1]<Low[j+2] && Low[j2]<Low[j2+2] && Low[j2+2]<Low[j2+3] && CI[j2]<CI[j2+1] && CI[j2-1]>CI[j2] && CI[j2]<45 ) break;
      j++;}
    if (CI[j2]>CI[j] && CI[j]<CI[j-1] && CI[j]<CI[j+1] && CI[j]<33 && Low[j]<Low[j+1] && Low[j+1]<Low[j+2] && Low[j2]<Low[j2+2] && Low[j2+2]<Low[j2+3] && CI[j2]<CI[j2+1] && CI[j2-1]>CI[j2] && CI[j2]<45 ) break;
     j2++;}  


if (j2<300 &&  Low[j]<Low[j+1] && Low[j+1]<Low[j+2] ) {LowFractalTime_2=iTime(NULL, 0,j2);    LowFractalTime_1=iTime(NULL, 0,j);    }


 if (j<300 && j<j2+30)   {ObjectDelete(0,"bNNN3_3");
     ObjectCreate(0,"bNNN3_3",OBJ_TREND,1,LowFractalTime_1,CI[j],LowFractalTime_2,CI[j2]);
    ObjectSetInteger(0,"bNNN3_3",OBJPROP_RAY_RIGHT,false);
         ObjectSet("bNNN3_3",OBJPROP_COLOR,indicator_color2);
         ObjectSet("bNNN3_3",OBJPROP_WIDTH,8); 
         ObjectSet("bNNN3_3",OBJPROP_BACK,1); }
       
       
keepj2 = j2;         


j2=keepj2+30;
   while (j2<300 ){
    j=j2+2; 
      if (Low[j2]<Low[j2+2] && Low[j2+2]<Low[j2+3] && CI[j2]<CI[j2+1] && CI[j2-1]>CI[j2] && CI[j2]<45) 
         while (j<j2+32){
               if (CI[j2]>CI[j] && CI[j]<CI[j-1] && CI[j]<CI[j+1] && CI[j]<33 && Low[j]<Low[j+1] && Low[j+1]<Low[j+2] && Low[j2]<Low[j2+2] && Low[j2+2]<Low[j2+3] && CI[j2]<CI[j2+1] && CI[j2-1]>CI[j2] && CI[j2]<45 ) break;
      j++;}
    if (CI[j2]>CI[j] && CI[j]<CI[j-1] && CI[j]<CI[j+1] && CI[j]<33 && Low[j]<Low[j+1] && Low[j+1]<Low[j+2] && Low[j2]<Low[j2+2] && Low[j2+2]<Low[j2+3] && CI[j2]<CI[j2+1] && CI[j2-1]>CI[j2] && CI[j2]<45 ) break;
     j2++;}  


if (j2<300 &&  Low[j]<Low[j+1] && Low[j+1]<Low[j+2] ) {LowFractalTime_2=iTime(NULL, 0,j2);    LowFractalTime_1=iTime(NULL, 0,j);    }


 if (j<300 && j<j2+32)   {ObjectDelete(0,"bNNN3_4");
     ObjectCreate(0,"bNNN3_4",OBJ_TREND,1,LowFractalTime_1,CI[j],LowFractalTime_2,CI[j2]);
    ObjectSetInteger(0,"bNNN3_4",OBJPROP_RAY_RIGHT,false);
         ObjectSet("bNNN3_4",OBJPROP_COLOR,indicator_color2);
         ObjectSet("bNNN3_4",OBJPROP_WIDTH,8); 
         ObjectSet("bNNN3_4",OBJPROP_BACK,1); }
         


}

deletetxt1("hOPITAL");

if (Period()==1440){
for(i=200; i>=1; i--){
   if (ExtMapBuffer[i]<StdDevLoBuffer[i] && ExtMapBuffer[i+1]>StdDevLoBuffer[i+1]){
      if (MathAbs(Close[i+1]-iLow(NULL,0,iLowest(NULL,0,MODE_LOW,3,i)))<MathAbs(Close[i+1]-iHigh(NULL,0,iHighest(NULL,0,MODE_HIGH,3,i))) )
         {ObjectCreate("hOPITAL"+IntegerToString(i), OBJ_TEXT, 1, Time[i+2], 60);  
                ObjectSetText("hOPITAL"+IntegerToString(i), "Buy Below:", 10, "Arial Black",  clrNavy);
                ObjectCreate("hOPITALl"+IntegerToString(i), OBJ_TEXT, 1, Time[i+2], 40);  
                ObjectSetText("hOPITALl"+IntegerToString(i), NormalizeDouble(iLow(NULL,0,iLowest(NULL,0,MODE_LOW,2,i)),4), 16, "Arial Black",  clrNavy);
         }
          if (MathAbs(Close[i+1]-iLow(NULL,0,iLowest(NULL,0,MODE_LOW,3,i)))>MathAbs(Close[i+1]-iHigh(NULL,0,iHighest(NULL,0,MODE_HIGH,3,i))) )
         {ObjectCreate("hOPITAL"+IntegerToString(i), OBJ_TEXT, 1, Time[i+2], 60);  
                ObjectSetText("hOPITAL"+IntegerToString(i), "Sell Above:", 10, "Arial Black",  clrNavy);
                ObjectCreate("hOPITALl"+IntegerToString(i), OBJ_TEXT, 1, Time[i+2], 40);  
                ObjectSetText("hOPITALl"+IntegerToString(i), NormalizeDouble(iHigh(NULL,0,iHighest(NULL,0,MODE_HIGH,2,i)),4), 16, "Arial Black",  clrNavy);
         }
   }}

}


  return(0);
  }
  
  
double ChoppinessIndex(int period, int bar)
  {
    double Low0 = 0, High0 = 0, Close1 = 0;
    double TrueRangeLow = 0, TrueRangeHigh = 0, TrueRangeSum = 0, Input = 0;
    double PeriodTrueRangeLow = 999999999, PeriodTrueRangeHigh = 0, PeriodTrueRange = 0;

    for(int k=bar; k<bar+period; k++)
    {
      Low0   = iLow(NULL,0,k);
      High0  = iHigh(NULL,0,k);
      Close1 = iClose(NULL,0,k+1);

      if (Low0<Close1)  TrueRangeLow  = Low0;  else TrueRangeLow  = Close1;
      if (High0>Close1) TrueRangeHigh = High0; else TrueRangeHigh = Close1;
      
      if (TrueRangeLow <PeriodTrueRangeLow)  PeriodTrueRangeLow  = TrueRangeLow;  // find true low of period
      if (TrueRangeHigh>PeriodTrueRangeHigh) PeriodTrueRangeHigh = TrueRangeHigh; // find true high of period

      TrueRangeSum += TrueRangeHigh;
      TrueRangeSum -= TrueRangeLow;
    }

    PeriodTrueRange = PeriodTrueRangeHigh - PeriodTrueRangeLow;
    if (PeriodTrueRange==0) PeriodTrueRange = MathPow(10, -12); // avoid possibility of division by zero
    Input = TrueRangeSum / PeriodTrueRange;
    return ((logN(Input, 10, MathPow(10, -12)) / logN(period, 10, MathPow(10, -12))) * 100);
  }


double ChoppinessIndexD(int period, int bar)
  {
    double Low0 = 0, High0 = 0, Close1 = 0;
    double TrueRangeLow = 0, TrueRangeHigh = 0, TrueRangeSum = 0, Input = 0;
    double PeriodTrueRangeLow = 999999999, PeriodTrueRangeHigh = 0, PeriodTrueRange = 0;

    for(int k=bar; k<bar+period; k++)
    {
      Low0   = iLow(NULL,1440,k);
      High0  = iHigh(NULL,1440,k);
      Close1 = iClose(NULL,1440,k+1);

      if (Low0<Close1)  TrueRangeLow  = Low0;  else TrueRangeLow  = Close1;
      if (High0>Close1) TrueRangeHigh = High0; else TrueRangeHigh = Close1;
      
      if (TrueRangeLow <PeriodTrueRangeLow)  PeriodTrueRangeLow  = TrueRangeLow;  // find true low of period
      if (TrueRangeHigh>PeriodTrueRangeHigh) PeriodTrueRangeHigh = TrueRangeHigh; // find true high of period

      TrueRangeSum += TrueRangeHigh;
      TrueRangeSum -= TrueRangeLow;
    }

    PeriodTrueRange = PeriodTrueRangeHigh - PeriodTrueRangeLow;
    if (PeriodTrueRange==0) PeriodTrueRange = MathPow(10, -12); // avoid possibility of division by zero
    Input = TrueRangeSum / PeriodTrueRange;
    return ((logN(Input, 10, MathPow(10, -12)) / logN(period, 10, MathPow(10, -12))) * 100);
  }


double ChoppinessIndex240(int period, int bar)
  {
    double Low0 = 0, High0 = 0, Close1 = 0;
    double TrueRangeLow = 0, TrueRangeHigh = 0, TrueRangeSum = 0, Input = 0;
    double PeriodTrueRangeLow = 999999999, PeriodTrueRangeHigh = 0, PeriodTrueRange = 0;

    for(int k=bar; k<bar+period; k++)
    {
      Low0   = iLow(NULL,240,k);
      High0  = iHigh(NULL,240,k);
      Close1 = iClose(NULL,240,k+1);

      if (Low0<Close1)  TrueRangeLow  = Low0;  else TrueRangeLow  = Close1;
      if (High0>Close1) TrueRangeHigh = High0; else TrueRangeHigh = Close1;
      
      if (TrueRangeLow <PeriodTrueRangeLow)  PeriodTrueRangeLow  = TrueRangeLow;  // find true low of period
      if (TrueRangeHigh>PeriodTrueRangeHigh) PeriodTrueRangeHigh = TrueRangeHigh; // find true high of period

      TrueRangeSum += TrueRangeHigh;
      TrueRangeSum -= TrueRangeLow;
    }

    PeriodTrueRange = PeriodTrueRangeHigh - PeriodTrueRangeLow;
    if (PeriodTrueRange==0) PeriodTrueRange = MathPow(10, -12); // avoid possibility of division by zero
    Input = TrueRangeSum / PeriodTrueRange;
    return ((logN(Input, 10, MathPow(10, -12)) / logN(period, 10, MathPow(10, -12))) * 100);
  }  

double logN(double x, double base, double epsilon)
  {
    double integer = 0.0;
    if ((x < 1) || (base < 1)) return(0);

    while (x < 1)
    {
      integer -= 1;
      x *= base;
    }
  
    while (x >= base)
    {
      integer += 1;
      x /= base;
    }
  
    double partial = 0.5;
    x *= x;
    double decimal = 0.0;

    while (partial > epsilon)
    {
      if (x >= base)
      {
        decimal += partial;
        x = x / base;
      }
      partial *= 0.5;
      x *= x;
    }
    
    return (integer + decimal);
  } 


double StdDev(int shift, int samples)
  {
  double x0=0, x1=0, x2=0;
  for (int m=0; m<samples; m++)
    {
    x0 = ExtMapBuffer[m+shift];
    x1 += x0;
    x2 += MathPow(x0,2);
    }
  return(MathSqrt((x2-(x1*x1/samples))/(samples-1))); // minimum samples is 2, enforced in the init section
  }
  
    void deletetxt1(string text){
   for(int iObj=ObjectsTotal()-1; iObj >= 0; iObj--){
      string   on = ObjectName(iObj);
      if(StringFind(on, text) == 0)  ObjectDelete(on);
}  }

From 0 to 100, 100, 100

Once a bona fide turn has taken place, all you have to do is accelerate three times. Or decelerate, depending on the direction.

From 100 to 0, 0, 0

#property copyright "Copyright © 2019, Macdulio" 
#property link      "https://forexfore.blog" 
#property description "V1.0"
#property description "LEMA 30N RF Zero to 100"
#property description "All the moving average pairs"
#property description "you will ever need for trading."
#property description "For further information turn to"
#property description "my blog or my book,"
#property description "Computer Aided Trading"
#property strict;
#property indicator_chart_window
#property indicator_buffers 34
#property indicator_color1 Crimson
#property indicator_color2 Blue
#define  NL    "\n"
extern int lookback = 500;
extern double zero = 6.0;
extern double hundred = 94.0;
extern double FSize=32;
extern bool plot_Spark_Sones = true;
extern bool plot_polarities = true;
extern bool plot_ricochets = false;
extern bool plot_losing_status = true;
extern bool plot_Hull = false;
extern bool plot_Hull_Arrows = false;
extern bool plot_fluctuation_brackets = false;
double FMax = FSize*6/5;
int sample=828;
int       Range_n=34;
int shift = 5;
double ExtMapBuffer[];
double conso[], conso2[];
  double iHi[];
  double iLo[]; 
  double iHi2[];
  double iLo2[];
    double iHi3[];
  double iLo3[];    
    double iHi4[];
  double iLo4[];    
      double iHi5[];
  double iLo5[];  
        double iHi6[];
  double iLo6[];  
double HiBuffer[],LoBuffer[];
double plus[],minus[],vbrl[],vbru[];
double sup[],sdn[],RSI2[],stoch[];
double ExtUpFractalsBuffer[];
double ExtDownFractalsBuffer[];
int fodir[];
double buy[];
double sell[];
double ramp[];
double UR[];
double DR[];
double URE[];
double BE[];
double SE[];
double SE60[];
double BU[];
double BU60[];
  int Hi20[];
  int Lo20[]; 
  double HPR[];
  double LPR[];
  double LCR[];
  double HCR[];
  double bline[];
  double sline[];
  double guardrailu[],guardraild[],guardraildplus[],guardraildminus[];
  double pbrainu[],pbraind[];
   double lowest_price[];
  double highest_price[]; 
  double triu[], trid[];
  extern int HULL = 33;  
  double HighBuffer[],HighBuffer2[];
double LowBuffer[],LowBuffer2[];
double dt14, db14, pacing;
  double HULLU[], HULLD[], MHULL[], inner[], HU[], HD[];
int init()
  {
  
        SetIndexBuffer(0,HighBuffer);
   SetIndexBuffer(1,LowBuffer);   
   SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,4,clrRed);
   SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,4,clrRed);
  
  
          SetIndexBuffer(2,HighBuffer2);
   SetIndexBuffer(3,LowBuffer2);   
   SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_SOLID,4,clrGreen);
   SetIndexStyle(3,DRAW_HISTOGRAM,STYLE_SOLID,4,clrGreen);
  
  
   SetIndexBuffer(29,iHi);
   SetIndexStyle(29,DRAW_LINE,2,8,Blue);
   SetIndexLabel(29, "Highest(" + DoubleToStr(Range_n,0)+")");

   SetIndexBuffer(30,iLo);
   SetIndexStyle(30,DRAW_LINE,2,8,Blue);
   SetIndexLabel(30, "Lowest(" + DoubleToStr(Range_n,0)+")");
   
   SetIndexBuffer(31,bline);
   SetIndexStyle(31,DRAW_LINE,2,5,clrNONE);
 //  SetIndexArrow(2,221);
   SetIndexLabel(31, "Bline(" + DoubleToStr(Range_n,0)+")");
   
   SetIndexBuffer(32,sline);   
   SetIndexStyle(32,DRAW_LINE,2,5,clrNONE);
   SetIndexLabel(32, "Sline(" + DoubleToStr(Range_n,0)+")");
 //  SetIndexArrow(3,222);

   
   SetIndexStyle(4,DRAW_ARROW,EMPTY,7,DarkGreen);
   SetIndexArrow(4,217);
   SetIndexBuffer(4,LCR);
   SetIndexEmptyValue(4,0.0);
   
   SetIndexStyle(5,DRAW_ARROW,EMPTY,7,Yellow);
   SetIndexArrow(5,218);
   SetIndexBuffer(5,HCR);
   SetIndexEmptyValue(5,0.0);

   SetIndexStyle(6,DRAW_ARROW,EMPTY,3,Cyan);
   SetIndexArrow(6,233);
   SetIndexBuffer(6,BE);
   SetIndexEmptyValue(6,0.0);


   SetIndexBuffer(7,iHi2);
   SetIndexStyle(7,DRAW_LINE,2,8,Magenta);
   SetIndexLabel(7, "Highest(" + DoubleToStr(Range_n,0)+")");

   SetIndexBuffer(8,iLo2);
   SetIndexStyle(8,DRAW_LINE,2,8,Magenta);
   SetIndexLabel(8, "Lowest(" + DoubleToStr(Range_n,0)+")");



   SetIndexBuffer(9,iHi3);
   SetIndexStyle(9,DRAW_LINE,2,8,Peru);
 //  SetIndexLabel(9, "Highest(" + DoubleToStr(Range_n,0)+")");

   SetIndexBuffer(10,iLo3);
   SetIndexStyle(10,DRAW_LINE,2,8,Peru);
 //  SetIndexLabel(10, "Lowest(" + DoubleToStr(Range_n,0)+")");


   SetIndexBuffer(11,iHi4);
   SetIndexStyle(11,DRAW_LINE,2,8,MediumSpringGreen);
 //  SetIndexLabel(9, "Highest(" + DoubleToStr(Range_n,0)+")");

   SetIndexBuffer(12,iLo4);
   SetIndexStyle(12,DRAW_LINE,2,8,MediumSpringGreen);
 //  SetIndexLabel(10, "Lowest(" + DoubleToStr(Range_n,0)+")");



   SetIndexBuffer(13,conso2);
   SetIndexStyle(13,DRAW_LINE,2,12,clrNONE);
 //  SetIndexLabel(11, "Lowest(" + DoubleToStr(Range_n,0)+")");

   SetIndexBuffer(14,conso);
   SetIndexStyle(14,DRAW_LINE,2,5,clrNONE);
  // SetIndexLabel(12, "Lowest(" + DoubleToStr(Range_n,0)+")");


   SetIndexBuffer(15,iHi5);
   SetIndexStyle(15,DRAW_LINE,2,8,clrMaroon);


   SetIndexBuffer(16,iLo5);
   SetIndexStyle(16,DRAW_LINE,2,8,clrMaroon);


   SetIndexBuffer(17,iHi6);
   SetIndexStyle(17,DRAW_LINE,2,8,DeepPink);


   SetIndexBuffer(18,iLo6);
   SetIndexStyle(18,DRAW_LINE,2,8,DeepPink);


 SetIndexBuffer(19,guardrailu);
   SetIndexStyle(19,DRAW_LINE,2,12,clrChartreuse);
    SetIndexBuffer(20,guardraild);
   SetIndexStyle(20,DRAW_LINE,2,12,clrChartreuse);
   
   
 SetIndexBuffer(21,pbrainu);
   SetIndexStyle(21,DRAW_LINE,2,12,Purple);
    SetIndexBuffer(22,pbraind);
   SetIndexStyle(22,DRAW_LINE,2,12,Purple);
   
   SetIndexBuffer(23,triu);
   SetIndexStyle(23,DRAW_LINE,2,12,White);
    SetIndexBuffer(24,trid);
   SetIndexStyle(24,DRAW_LINE,2,12,White);
  
       SetIndexBuffer(33,inner);
   SetIndexStyle(33,DRAW_LINE,3,6,clrNONE);
  
  
     SetIndexBuffer(25,HULLU);
   SetIndexStyle(25,DRAW_LINE,3,6,Navy);
   
       SetIndexBuffer(26,HULLD);
   SetIndexStyle(26,DRAW_LINE,3,6,Yellow);
   
   
    SetIndexStyle(27,DRAW_ARROW,EMPTY,5,Yellow);
       SetIndexBuffer(27,HD);
   SetIndexArrow(27,242);

 //  SetIndexEmptyValue(27,0.0);

   SetIndexStyle(28,DRAW_ARROW,EMPTY,5,Cyan);
      SetIndexBuffer(28,HU);
   SetIndexArrow(28,241);


    SetIndexBuffer(29,guardraildplus);
   SetIndexStyle(29,DRAW_LINE,2,6,clrLime);

SetIndexBuffer(30,guardraildminus);
   SetIndexStyle(30,DRAW_LINE,2,6,clrLime);


 //  SetIndexEmptyValue(28,0.0);
   
   
  
//----
   return(0);
  }


int start()
  {
   int    i,j ;     
  

  double xHi[];
  double xLo[];  
  int SPRD[];  
   
  
  string symbol = Symbol();
  ArrayResize(fodir, 300);
ArrayInitialize(fodir, 0);   
  ArrayResize(plus, 500);   
ArrayInitialize(plus, EMPTY_VALUE); 
ArrayResize(minus, 500);   
ArrayInitialize(minus, EMPTY_VALUE);
  ArrayResize(vbru, 200);   
ArrayInitialize(vbru, EMPTY_VALUE);
ArrayResize(vbrl, 200);   
ArrayInitialize(vbrl, EMPTY_VALUE);
  ArrayResize(buy, Bars);
  ArrayResize(sell, Bars);
  ArrayResize(ramp, Bars);
  ArrayInitialize(buy, 0);
  ArrayInitialize(sell, 0);
  ArrayInitialize(ramp, 0);      
  ArrayResize(iHi, Bars);
  ArrayResize(iLo, Bars);
  ArrayInitialize(iHi, EMPTY_VALUE);
  ArrayInitialize(iLo, EMPTY_VALUE);
  ArrayResize(iHi2, Bars);
  ArrayResize(iLo2, Bars);
  ArrayInitialize(iHi2, EMPTY_VALUE);
  ArrayInitialize(iLo2, EMPTY_VALUE);     
  ArrayResize(iHi3, Bars);
  ArrayResize(iLo3, Bars);
  ArrayInitialize(iHi3, EMPTY_VALUE);
  ArrayInitialize(iLo3, EMPTY_VALUE);   
    ArrayResize(iHi4, Bars);
  ArrayResize(iLo4, Bars);
  ArrayInitialize(iHi4, EMPTY_VALUE);
  ArrayInitialize(iLo4, EMPTY_VALUE);     
   ArrayResize(iHi5, Bars);
  ArrayResize(iLo5, Bars);
  ArrayInitialize(iHi5, EMPTY_VALUE);
  ArrayInitialize(iLo5, EMPTY_VALUE);   
   ArrayResize(iHi6, Bars);
  ArrayResize(iLo6, Bars);
  ArrayInitialize(iHi6, EMPTY_VALUE);
  ArrayInitialize(iLo6, EMPTY_VALUE);          
  ArrayResize(xHi, Bars);
  ArrayResize(xLo, Bars);
  ArrayInitialize(xHi, 0);
  ArrayInitialize(xLo, 0);   
  ArrayResize(UR, Bars); 
  ArrayInitialize(UR, 0);    
  ArrayResize(DR, Bars); 
  ArrayInitialize(DR, 0);       
  ArrayResize(URE, Bars); 
  ArrayInitialize(URE, 0);
  ArrayResize(SE, Bars); 
  ArrayInitialize(SE, 0);  
  ArrayResize(BE, Bars); 
  ArrayInitialize(BE, 0);   
  ArrayResize(BU, Bars); 
  ArrayInitialize(BU, 0);     
  ArrayResize(SE60, Bars); 
  ArrayInitialize(SE60, 0);      
  ArrayResize(BU60, Bars); 
  ArrayInitialize(BU60, 0);     
  ArrayResize(SPRD, Bars); 
  ArrayInitialize(SPRD, 0);    
  ArrayResize(Hi20, Bars);
  ArrayResize(Lo20, Bars);
  ArrayInitialize(Hi20, 0);
  ArrayInitialize(Lo20, 0);       
   
  ArrayResize(LPR, Bars); 
  ArrayInitialize(LPR, 0); 
  ArrayResize(HPR, Bars); 
  ArrayInitialize(HPR, 0); 
  
  
  ArrayResize(LCR, Bars); 
  ArrayInitialize(LCR, 0); 
  ArrayResize(HCR, Bars); 
  ArrayInitialize(HCR, 0);
  ArrayResize(ExtUpFractalsBuffer, Bars);   
 ArrayInitialize(ExtUpFractalsBuffer, EMPTY_VALUE);  
  ArrayResize(ExtDownFractalsBuffer, Bars);   
 ArrayInitialize(ExtDownFractalsBuffer, EMPTY_VALUE);  
  
  ArrayResize(bline, Bars); 
  ArrayInitialize(bline, 0); 
  ArrayResize(sline, Bars); 
  ArrayInitialize(sline, 0); 
  ArrayResize(ExtMapBuffer, Bars); 
  ArrayInitialize(ExtMapBuffer, 0); 
  
    ArrayResize(HighBuffer, Bars); 
  ArrayInitialize(HighBuffer, EMPTY_VALUE);   
      ArrayResize(LowBuffer, Bars); 
  ArrayInitialize(LowBuffer, EMPTY_VALUE); 
     ArrayResize(HighBuffer2, Bars); 
  ArrayInitialize(HighBuffer2, EMPTY_VALUE);   
      ArrayResize(LowBuffer2, Bars); 
  ArrayInitialize(LowBuffer2, EMPTY_VALUE); 
  
    ArrayResize(guardrailu, Bars); 
  ArrayInitialize(guardrailu, EMPTY_VALUE);   
   ArrayResize(guardraild, Bars); 
  ArrayInitialize(guardraild, EMPTY_VALUE);  
    ArrayResize(guardraildplus, Bars); 
  ArrayInitialize(guardraildplus, EMPTY_VALUE);   
     ArrayResize(guardraildminus, Bars); 
  ArrayInitialize(guardraildminus, EMPTY_VALUE);  
  
  ArrayResize(conso, Bars); 
  ArrayInitialize(conso, EMPTY_VALUE);   
   ArrayResize(conso2, Bars); 
  ArrayInitialize(conso2, EMPTY_VALUE);  
      ArrayResize(HU, Bars); 
  ArrayInitialize(HU, EMPTY_VALUE);   
   ArrayResize(HD, Bars); 
  ArrayInitialize(HD, EMPTY_VALUE);   
    ArrayResize(HULLU, Bars); 
  ArrayInitialize(HULLU, EMPTY_VALUE);   
   ArrayResize(HULLD, Bars); 
  ArrayInitialize(HULLD, EMPTY_VALUE);  
    ArrayResize(MHULL, Bars); 
  ArrayInitialize(MHULL, EMPTY_VALUE);  
      ArrayResize(inner, Bars); 
  ArrayInitialize(inner, EMPTY_VALUE);  
 ArrayResize(sup, 500);   
ArrayInitialize(sup, 0); 
ArrayResize(sdn, 500);   
ArrayInitialize(sdn, 0); 
ArrayResize(RSI2, Bars);
ArrayInitialize(RSI2, 0);
ArrayResize(stoch, Bars);
ArrayInitialize(stoch, 0);       
//--------------------------------------------------------------------

//  highest_price[0] =  High[iHighest(NULL, 0, MODE_HIGH, 3,1)];
//   lowest_price[0] =  Low[iLowest(NULL, 0, MODE_LOW, 3,1)];


dt14 = iHigh(symbol,240,iHighest(symbol,240,MODE_HIGH,1590));
db14 = iLow(symbol,240,iLowest(symbol,240,MODE_LOW,1590));
pacing = (dt14-db14)*.1;

bool embeddedoversold = (iClose(symbol,1440,1)<db14+2*pacing && iClose(symbol,1440,2)<db14+2*pacing && iClose(symbol,1440,3)<db14+2*pacing);
bool embeddedoverbought = (iClose(symbol,1440,1)>dt14-2*pacing && iClose(symbol,1440,2)>dt14-2*pacing && iClose(symbol,1440,3)>dt14-2*pacing);


string addon;
if (embeddedoversold) addon = "-";
else if (embeddedoverbought) addon = "+";
else addon = "0";

int    nCountedBars, o, n, bar;
   bool   bFound;
   double dCurrent;
   nCountedBars=IndicatorCounted();
//---- last counted bar will be recounted    
   if(nCountedBars<=2)
      i=Bars-nCountedBars-3;
   if(nCountedBars>2)
     {
      nCountedBars--;
      i=500;
     }
//----Up and Down Fractals
   while(i>=2)
     {
      //----Fractals up
      bFound=false;
      dCurrent=High[i];
      if(dCurrent>High[i+1]  && dCurrent>High[i-1] && dCurrent>High[i-2])
       //&& dCurrent>High[i+2]
        {
         bFound=true;
         ExtUpFractalsBuffer[i]=dCurrent;
        }
      //----6 bars Fractal
      if(!bFound && (Bars-i-1)>=3)
        {
         if(dCurrent==High[i+1] && dCurrent>High[i+2]  
         //&& dCurrent>High[i+3]
            && dCurrent>High[i-1] && dCurrent>High[i-2])
           {
            bFound=true;
            ExtUpFractalsBuffer[i]=dCurrent;
           }
        }        
      //----7 bars Fractal
      if(!bFound && (Bars-i-1)>=4)
        {  
         if(dCurrent>=High[i+1]  && dCurrent>High[i+3] && dCurrent>High[i+4] &&  dCurrent==High[i+2]
            && dCurrent>High[i-1] && dCurrent>High[i-2])
           {
            bFound=true;
            ExtUpFractalsBuffer[i]=dCurrent;
           }
        }  
      //----8 bars Fractal                          
      if(!bFound && (Bars-i-1)>=5)
        {  
         if(dCurrent>=High[i+1] && dCurrent==High[i+2] && dCurrent==High[i+3] && dCurrent>High[i+4]  &&
         
        //&& dCurrent>High[i+5]
            dCurrent>High[i-1] && dCurrent>High[i-2])
           {
            bFound=true;
            ExtUpFractalsBuffer[i]=dCurrent;
           }
        }
      //----9 bars Fractal                                        
      if(!bFound && (Bars-i-1)>=6)
        {  
         if(dCurrent>=High[i+1] && dCurrent==High[i+2] && dCurrent>=High[i+3] && dCurrent==High[i+4] && dCurrent>High[i+5]  && dCurrent>High[i-1] && dCurrent>High[i-2])
           //&&             dCurrent>High[i+6]
           {
            bFound=true;
            ExtUpFractalsBuffer[i]=dCurrent;
           }
        }                                    
      //----Fractals down
      bFound=false;
      dCurrent=Low[i];
      if(dCurrent<Low[i+1]  && dCurrent<Low[i-1] && dCurrent<Low[i-2])
        //&& dCurrent<Low[i+2]
        {
         bFound=true;
         ExtDownFractalsBuffer[i]=dCurrent;
        }
      //----6 bars Fractal
      if(!bFound && (Bars-i-1)>=3)
        {
         if(dCurrent==Low[i+1] && dCurrent<Low[i+2]  &&
            dCurrent<Low[i-1] && dCurrent<Low[i-2])
           //&& dCurrent<Low[i+3]
           {
            bFound=true;
            ExtDownFractalsBuffer[i]=dCurrent;
           }                      
        }        
      //----7 bars Fractal
      if(!bFound && (Bars-i-1)>=4)
        {  
         if(dCurrent<=Low[i+1] && dCurrent==Low[i+2] && dCurrent<Low[i+3]  &&
            dCurrent<Low[i-1] && dCurrent<Low[i-2])
          //&& dCurrent<Low[i+4]  
           {
            bFound=true;
            ExtDownFractalsBuffer[i]=dCurrent;
           }                      
        }  
      //----8 bars Fractal                          
      if(!bFound && (Bars-i-1)>=5)
        {  
         if(dCurrent<=Low[i+1] && dCurrent==Low[i+2] && dCurrent==Low[i+3] && dCurrent<Low[i+4]  &&
            dCurrent<Low[i-1] && dCurrent<Low[i-2])
           //&& dCurrent<Low[i+5] 
           {
            bFound=true;
            ExtDownFractalsBuffer[i]=dCurrent;
           }                      
        }
      //----9 bars Fractal                                        
      if(!bFound && (Bars-i-1)>=6)
        {  
         if(dCurrent<=Low[i+1] && dCurrent==Low[i+2] && dCurrent<=Low[i+3] && dCurrent==Low[i+4] && dCurrent<Low[i+5]  && dCurrent<Low[i-1] && dCurrent<Low[i-2])
           //&&             dCurrent<Low[i+6]
           {
            bFound=true;
            ExtDownFractalsBuffer[i]=dCurrent;
           }                      
        }                                    
      i--;
     }

for (i = 300 ; i >= 0; i--){ 
   RSI2[i]=iRSI(symbol,0,2,PRICE_MEDIAN,i);
   stoch[i]=iStochastic(symbol,0,8,3,3,MODE_SMA,1,MODE_SIGNAL,i);
}   

for (i=240; i>=1; i--){

if(stoch[i+1]<23 && RSI2[i+1]<16  && RSI2[i+3]>5 && !(stoch[i]<5 && RSI2[i]<5)&& 
ExtDownFractalsBuffer[i+1]!=EMPTY_VALUE) sdn[i+1]=iLow(symbol,30,i+1); 
if(stoch[i+1]<23 && RSI2[i+1]<16  && !(stoch[i]<5 && RSI2[i]<5)&& 
ExtDownFractalsBuffer[i+1]!=EMPTY_VALUE)sdn[i+1]=iLow(symbol,30,i+1); 
if(stoch[i+1]<44 && stoch[i+1]>5 && RSI2[i+1]>5 && !(stoch[i]>15 && RSI2[i]>15) && 
ExtDownFractalsBuffer[i+1]!=EMPTY_VALUE) sdn[i+1]=iLow(symbol,30,i+1);
if(stoch[i+1]<5 && RSI2[i+1]<5 && !(stoch[i]>15 && RSI2[i]>15) && 
ExtDownFractalsBuffer[i+1]!=EMPTY_VALUE) sdn[i+1]=iLow(symbol,30,i+1);
if( ((stoch[i+1]>64 && stoch[i]<85 && RSI2[i+2]>85) ||  (stoch[i+1]>72 && stoch[i+1]<75 )  ||  (stoch[i]>44 && stoch[i+1]<35 && stoch[i-1]<44  && RSI2[i+1]>85 )) && RSI2[i+1]>70 && !(stoch[i-1]>95 && RSI2[i-1]>95) && 
ExtUpFractalsBuffer[i+1]!=EMPTY_VALUE && !sup[i+2]) sup[i+1]=iHigh(symbol,30,i+1);
if(stoch[i+1]>64 && stoch[i+2]<64 && RSI2[i+1]>85 && !(stoch[i]>70 && RSI2[i]>95) && 
ExtUpFractalsBuffer[i+2]!=EMPTY_VALUE && !sup[i+2]) sup[i+1]=iHigh(symbol,30,i+1);
if(stoch[i+1]>85 && RSI2[i+1]>85 && !(stoch[i]>85 && RSI2[i]>95) &&  
ExtUpFractalsBuffer[i+1]!=EMPTY_VALUE && !sup[i+2]) sup[i+1]=iHigh(symbol,30,i+1);
        
minus[i]=minus[i+1];
plus[i]=plus[i+1];     

     if (sdn[i+1]!=0) minus[i]=Low[i+1]-110*Point+FSize/2*10*Point;
     if (sup[i+1]!=0) plus[i]=High[i+1]+100*Point-FSize/2*10*Point; 
 }



deletetxt1("Rack");
if (Period()<=1440) {
   for (i = lookback ; i >= 0; i--) {
   
  
   iHi[i]=EMPTY_VALUE;
   iLo[i]=EMPTY_VALUE;
   guardrailu[i] = EMPTY_VALUE;
   guardraild[i] = EMPTY_VALUE;
   
   HULLU[i]=EMPTY_VALUE;
   HULLD[i]=EMPTY_VALUE;
   MHULL[i]=EMPTY_VALUE;
   inner[i]=EMPTY_VALUE;
   HU[i]=EMPTY_VALUE;
   HD[i]=EMPTY_VALUE;
   
   
//     highest_price[i] =  iHigh(NULL,0,iHighest(NULL, 0, MODE_HIGH, 2,i+3));
 //  lowest_price[i] =  iLow(NULL,0,iLowest(NULL, 0, MODE_LOW, 2,i+3));
    if (i<lookback) iHi[i]=iMA(NULL,0,828,0,MODE_EMA, PRICE_HIGH,i);
    if (i<lookback) iLo[i]=iMA(NULL,0,828,0,MODE_EMA, PRICE_LOW,i);
    if (i<lookback) iHi2[i]=iMA(NULL,0,1556,0,MODE_EMA, PRICE_HIGH,i);
    if (i<lookback) iLo2[i]=iMA(NULL,0,1556,0,MODE_EMA, PRICE_LOW,i);
 if (i<lookback) iHi3[i]=iMA(NULL,0,sample*48,0,MODE_EMA, PRICE_HIGH,i);
    if (i<lookback) iLo3[i]=iMA(NULL,0,sample*48,0,MODE_EMA, PRICE_LOW,i);
     if (i<lookback) iHi4[i]=iMA(NULL,0,414,0,MODE_EMA, PRICE_HIGH,i);
    if (i<lookback) iLo4[i]=iMA(NULL,0,414,0,MODE_EMA, PRICE_LOW,i);

     if (i<lookback) iHi5[i]=iMA(NULL,0,135,0,MODE_EMA, PRICE_HIGH,i);
    if (i<lookback) iLo5[i]=iMA(NULL,0,135,0,MODE_EMA, PRICE_LOW,i);
    
        if (i<lookback) iHi6[i]=iMA(NULL,0,sample*8,0,MODE_EMA, PRICE_HIGH,i);
    if (i<lookback) iLo6[i]=iMA(NULL,0,sample*8,0,MODE_EMA, PRICE_LOW,i);
    
   if (Period()==30){ 
    
    guardrailu[i] =  iMA(symbol,0,414,0,MODE_EMA, PRICE_HIGH,i)+FMax*10*Point;
    
    guardraild[i] =  iMA(symbol,0,414,0,MODE_EMA, PRICE_LOW,i)-FMax*10*Point;
    
     guardraildplus[i] =  guardraild[i]+90*Point;
     guardraildminus[i] =  guardraild[i]-90*Point;
    
    
    pbrainu[i] =  iMA(symbol,0,414,0,MODE_EMA, PRICE_HIGH,i)+3*FMax*10*Point;
    pbraind[i] =  iMA(symbol,0,414,0,MODE_EMA, PRICE_LOW,i)-3*FMax*10*Point;
    
 triu[i] =  iMA(symbol,0,414,0,MODE_EMA, PRICE_HIGH,i)+5*FMax*10*Point;
    trid[i] =  iMA(symbol,0,414,0,MODE_EMA, PRICE_LOW,i)-5*FMax*10*Point;}

inner[i]=2*iMA(NULL,0,HULL/2,8,MODE_LWMA,PRICE_MEDIAN,i)- iMA(NULL,0,HULL,8,MODE_LWMA,PRICE_MEDIAN,i);

MHULL[i] = iMA(NULL,0,MathRound(MathSqrt(HULL)),8,MODE_LWMA,inner[i],i);

if (i<200){
//Low[i+9]<minus[i+9] && Low[i+8]<minus[i+8] && Low[i+7]<minus[i+7] && 
          if (Low[i+6]<minus[i+6] && Low[i+5]<minus[i+5] && Low[i+4]<minus[i+4] && Low[i+3]<minus[i+3]  && Low[i+2]<minus[i+2] && iLow(symbol,0,i+1)>minus[i+1] && i>=1 ){
           if (iLow(symbol,0,i+2)<minus[i+2]) if (plot_losing_status){ {ObjectCreate("Rack"+i, OBJ_RECTANGLE, 0, Time[i+2], Low[i+1], Time[i], iLow(Symbol(),0,iLowest(Symbol(),0,MODE_LOW,8,i+2)));
           ObjectSet("Rack"+i,OBJPROP_BACK,1);
            ObjectSetInteger(0,"Rack"+i,OBJPROP_COLOR,clrGreen); } fodir[i]=1; }}
//High[i+8]>plus[i+8] && High[i+7]>plus[i+7] &&                  
              if ( High[i+6]>plus[i+6] && High[i+5]>plus[i+5] && High[i+4]>plus[i+4] && High[i+3]>plus[i+3] && High[i+2]>plus[i+2] && High[i+3]>plus[i+3] && High[i+2]>plus[i+2] && iHigh(symbol,0,i+1)<plus[i+1] && i>=1 ){
         if (iHigh(symbol,0,i+2)>plus[i+2])if (plot_losing_status){ {ObjectCreate("Rack"+i, OBJ_RECTANGLE, 0, Time[i+2], High[i+1], Time[i], iHigh(Symbol(),0,iHighest(Symbol(),0,MODE_HIGH,8,i+2)));
          ObjectSet("Rack"+i,OBJPROP_BACK,1);
            ObjectSetInteger(0,"Rack"+i,OBJPROP_COLOR,clrMagenta);} } fodir[i]=-1;  }}


if (plot_Hull){
if (MHULL[i]<MHULL[i+1] && MHULL[i]!=0) HULLD[i]=MHULL[i];
else if (MHULL[i]>MHULL[i+1] && MHULL[i]!=0) HULLU[i]=MHULL[i];
}

if (plot_Hull_Arrows){
   
if (HULLU[i+6]!=EMPTY_VALUE && HULLU[i+3]!=EMPTY_VALUE && HULLU[i+4]!=EMPTY_VALUE && HULLU[i+5]!=EMPTY_VALUE && HULLD[i]!=EMPTY_VALUE && HULLD[i+1]!=EMPTY_VALUE && Period()==30) HD[i]=HULLD[i]+FSize/4*10*Point;
else HD[i]=EMPTY_VALUE;
if   (HULLD[i+6]!=EMPTY_VALUE && HULLD[i+3]!=EMPTY_VALUE && HULLD[i+4]!=EMPTY_VALUE && HULLD[i+5]!=EMPTY_VALUE && HULLU[i]!=EMPTY_VALUE && HULLU[i+1]!=EMPTY_VALUE && Period()==30 ) HU[i]=HULLU[i]-FSize/4*10*Point;
else HU[i]=EMPTY_VALUE;}

if (plot_Spark_Sones){

 ///Maroon Above Green River
     if ( iMA(symbol,0,135,0,MODE_EMA, PRICE_LOW,i)>iMA(symbol,0,414,0,MODE_EMA, PRICE_HIGH,i) && iMA(symbol,0,135,0,MODE_EMA, PRICE_LOW,i)-iMA(symbol,0,414,0,MODE_EMA, PRICE_HIGH,i)<FSize/1.4*10*Point
           && LowComparison(i,30) == False) {HighBuffer2[i]=iMA(symbol,0,135,0,MODE_EMA, PRICE_LOW,i); LowBuffer2[i]=iMA(symbol,0,414,0,MODE_EMA, PRICE_HIGH,i);}
 
 ///Maroon Below Green River
     if ( iMA(symbol,0,135,0,MODE_EMA, PRICE_HIGH,i)<iMA(symbol,0,414,0,MODE_EMA, PRICE_LOW,i) && iMA(symbol,0,414,0,MODE_EMA, PRICE_LOW,i)-iMA(symbol,0,135,0,MODE_EMA, PRICE_HIGH,i)<FSize/1.4*10*Point
            && HighComparison(i,30) == False) {HighBuffer[i]=iMA(symbol,0,414,0,MODE_EMA, PRICE_LOW,i); LowBuffer[i]=iMA(symbol,0,135,0,MODE_EMA, PRICE_HIGH,i);}
     }
     
     }
     
   for (i = 120 ; i >= 0; i--) {
     bline[i]=EMPTY_VALUE;
     sline[i]=EMPTY_VALUE;
     if (i<108) bline[i]=iHi[i]+ MathAbs(((iHi[i]-iHi[i+36])/36)*60);
    // MathAbs((iHi[i]-iHi[i+36])/36*60);
     if (i<108) sline[i]=iLo[i]-MathAbs(((iLo[i+36]-iLo[i])/36)*60);
  //   MathAbs((iLo[i+36]-iLo[i])/36*60);
     }


   for (i = 100 ; i >=0 ; i--) {
     if ((Open[i]>sline[i] &&  Bid<=sline[i]) && Close[i+2]>sline[i+2] ) sell[i]=sline[i];
    // MathAbs((iHi[i]-iHi[i+36])/36*60);
    if (sell[i]>0 && sell[i+1]==0 && Low[iLowest(NULL, 0, MODE_LOW, 3,i+1)]<sline[i]) HCR[i]=Low[iLowest(NULL, 0, MODE_LOW, 2,i+3)]+.001;
        if ((Close[i]>bline[i]&&Low[i+1]<bline[i+1])  ||  (Close[i+1]<sline[i+1] && Close[i+2]<sline[i+2] && Ask>=sline[i])) buy[i]=bline[i];
    if (buy[i]>0 && buy[i+1]==0 && High[iHighest(NULL, 0, MODE_HIGH, 3,i+1)]>bline[i]) LCR[i]=High[iHighest(NULL, 0, MODE_HIGH, 2,i+3)]-.001;    
  //   MathAbs((iLo[i+36]-iLo[i])/36*60);
     }


   
   
      for (i = 0 ; i <= 420; i++) {
      //conso[i]=EMPTY_VALUE;
    //  Print("MathAbs((ChoppinessIndex(14,i)-ChoppinessIndex(14,i+5))<1) ",i,"]:", MathAbs((ChoppinessIndex(14,i)-ChoppinessIndex(14,i+5)))); 
               if ((MathAbs((ChoppinessIndex(14,i)-ChoppinessIndex(14,i+4))>6) && MathAbs((ChoppinessIndex(14,i)-ChoppinessIndex(14,i+8))>6) && Period()==30)
                   ||  (MathAbs((ChoppinessIndex(7,i)-ChoppinessIndex(7,i+2))>5) && MathAbs((ChoppinessIndex(7,i)-ChoppinessIndex(7,i+4))>5) && Period()>30 ))
                   
                {
                     for (j=i; j <= i+3; j++){
                        conso[j]=(High[i]+High[i+1]+High[i+2]+High[i+3]+Low[i]+Low[i+1]+Low[i+2]+Low[i+3])/8;  conso2[j]=conso[j];}}
     }

   
   }

deletetxt1("Rake");
deletetxt1("Fake");
deletetxt1("ZERO");
deletetxt1("HUNDRA");

if (Period()==30){  
for(i = 240; i >= 0; i--){     


if (i>=0 && RSI2[i+1]>hundred && RSI2[i]<RSI2[i+1]){
               ObjectCreate("HUNDRA"+i,OBJ_TEXT, 0, Time[i+1], High[i+1]+250*Point);
                 ObjectSetText("HUNDRA"+i, "100", 53, "Arial Black", clrPink);
                 ObjectCreate("HUNDRAz"+i,OBJ_TEXT, 0, Time[i+1], High[i+1]+250*Point);
                 ObjectSetText("HUNDRAz"+i, " 100", 53, "Arial Black", clrNavy);}    


if (i==0 && RSI2[i]>hundred){
               ObjectCreate("HUNDRA"+i,OBJ_TEXT, 0, Time[i], High[i]+250*Point);
                 ObjectSetText("HUNDRA"+i, "100", 53, "Arial Black", clrPink);
                 ObjectCreate("HUNDRAz"+i,OBJ_TEXT, 0, Time[i], High[i]+250*Point);
                 ObjectSetText("HUNDRAz"+i, " 100", 53, "Arial Black", clrPowderBlue);}    




if (i>=0 && RSI2[i+1]<zero && RSI2[i]>RSI2[i+1]){
               ObjectCreate("ZERO"+i,OBJ_TEXT, 0, Time[i+1], Low[i+1]-5*Point);
                 ObjectSetText("ZERO"+i, "0", 53, "Arial Black", clrPink);
                 ObjectCreate("ZEROz"+i,OBJ_TEXT, 0, Time[i+1], Low[i+1]-5*Point);
                 ObjectSetText("ZEROz"+i, " 0", 53, "Arial Black", clrNavy);}    


if (i==0 && RSI2[i]<zero){
               ObjectCreate("ZERO"+i,OBJ_TEXT, 0, Time[i], Low[i]-5*Point);
                 ObjectSetText("ZERO"+i, "0", 53, "Arial Black", clrPink);
                 ObjectCreate("ZEROz"+i,OBJ_TEXT, 0, Time[i], Low[i]-5*Point);
                 ObjectSetText("ZEROz"+i, " 0", 53, "Arial Black", PowderBlue);}    


if (plot_ricochets){
    
                 
///////RAKE

////Maroon                 
//Low[i+2]>Low[i+1] 
if ( Low[i+1]< iMA(symbol,0,135,0,MODE_EMA, PRICE_HIGH,i+1)+40*Point && Low[i+1]> iMA(symbol,0,135,0,MODE_EMA, PRICE_HIGH,i+1)-20*Point
     && Close[i+1]> iMA(symbol,0,135,0,MODE_EMA, PRICE_HIGH,i+1)+50*Point && Low[i]>Low[i+1] &&
     !(Low[i+3]>Low[i+2] && Low[i+2]< iMA(symbol,0,135,0,MODE_EMA, PRICE_CLOSE,i+2)+30*Point && Low[i+2]> iMA(symbol,0,135,0,MODE_EMA, PRICE_HIGH,i+2)-80*Point
     && Close[i+2]> iMA(symbol,0,135,0,MODE_EMA, PRICE_CLOSE,i+2)+50*Point && Low[i+1]>Low[i+2])){
                 ObjectCreate("Rakei"+i,OBJ_TEXT, 0, Time[i+1], Low[i+1]-10*Point);
                 ObjectSetText("Rakei"+i, "R", 33, "Arial Black", clrYellow);
                 ObjectCreate("Raker"+i,OBJ_TEXT, 0, Time[i+1], Low[i+1]-10*Point);
                 ObjectSetText("Raker"+i, " R", 33, "Arial Black", clrBlack);}
        

///////2H Lema

if (Low[i+2]>Low[i+1] && Low[i+1]< iMA(symbol,0,1556,0,MODE_EMA, PRICE_HIGH,i+1)-30*Point && Low[i+1]> iMA(symbol,0,1556,0,MODE_EMA, PRICE_HIGH,i+1)+20*Point
     && Close[i+1]> iMA(symbol,0,1556,0,MODE_EMA, PRICE_HIGH,i+1)+50*Point && Low[i]>Low[i+1] &&
     !(Low[i+3]>Low[i+2] && Low[i+2]< iMA(symbol,30,1556,0,MODE_EMA, PRICE_CLOSE,i+2)+30*Point && Low[i+2]> iMA(symbol,0,1556,0,MODE_EMA, PRICE_HIGH,i+2)-80*Point
     && Close[i+2]> iMA(symbol,0,1556,0,MODE_EMA, PRICE_CLOSE,i+2)+50*Point && Low[i+1]>Low[i+2])){
                 ObjectCreate("Rakei"+i,OBJ_TEXT, 0, Time[i+1], Low[i+1]-10*Point);
                 ObjectSetText("Rakei"+i, "R", 33, "Arial Black", clrYellow);
                 ObjectCreate("Raker"+i,OBJ_TEXT, 0, Time[i+1], Low[i+1]-10*Point);
                 ObjectSetText("Raker"+i, " R", 33, "Arial Black", clrBlack);}


//////19872

if (Low[i+2]>Low[i+1] && Low[i+1]< iMA(symbol,0,19872,0,MODE_EMA, PRICE_HIGH,i+1)-30*Point && Low[i+1]> iMA(symbol,0,19872,0,MODE_EMA, PRICE_HIGH,i+1)+20*Point
     && Close[i+1]> iMA(symbol,0,19872,0,MODE_EMA, PRICE_HIGH,i+1)+50*Point && Low[i]>Low[i+1] &&
     !(Low[i+3]>Low[i+2] && Low[i+2]< iMA(symbol,0,19872,0,MODE_EMA, PRICE_CLOSE,i+2)+30*Point && Low[i+2]> iMA(symbol,0,19872,0,MODE_EMA, PRICE_HIGH,i+2)-80*Point
     && Close[i+2]> iMA(symbol,0,19872,0,MODE_EMA, PRICE_CLOSE,i+2)+50*Point && Low[i+1]>Low[i+2])){
                 ObjectCreate("Rakei"+i,OBJ_TEXT, 0, Time[i+1], Low[i+1]-40*Point);
                 ObjectSetText("Rakei"+i, "R", 33, "Arial Black", clrYellow);
                 ObjectCreate("Raker"+i,OBJ_TEXT, 0, Time[i+1], Low[i+1]-40*Point);
                 ObjectSetText("Raker"+i, " R", 33, "Arial Black", clrBlack);}


//////39744

if (Low[i+2]>Low[i+1] && Low[i+1]< iMA(symbol,0,39744,0,MODE_EMA, PRICE_HIGH,i+1)-30*Point && Low[i+1]> iMA(symbol,0,39744,0,MODE_EMA, PRICE_HIGH,i+1)+20*Point
     && Close[i+1]> iMA(symbol,0,39744,0,MODE_EMA, PRICE_HIGH,i+1)+50*Point && Low[i]>Low[i+1] &&
     !(Low[i+3]>Low[i+2] && Low[i+2]< iMA(symbol,0,39744,0,MODE_EMA, PRICE_CLOSE,i+2)+30*Point && Low[i+2]> iMA(symbol,0,39744,0,MODE_EMA, PRICE_HIGH,i+2)-80*Point
     && Close[i+2]> iMA(symbol,0,39744,0,MODE_EMA, PRICE_CLOSE,i+2)+50*Point && Low[i+1]>Low[i+2])){
                 ObjectCreate("Rakei"+i,OBJ_TEXT, 0, Time[i+1], Low[i+1]-40*Point);
                 ObjectSetText("Rakei"+i, "R", 33, "Arial Black", clrMagenta);
                 ObjectCreate("Raker"+i,OBJ_TEXT, 0, Time[i+1], Low[i+1]-40*Point);
                 ObjectSetText("Raker"+i, " R", 33, "Arial Black", clrBlack);}

////30m Lema 
if (Low[i+2]>Low[i+1] && Low[i+1]< iMA(symbol,0,828,0,MODE_EMA, PRICE_HIGH,i+1)-30*Point && Low[i+1]> iMA(symbol,0,828,0,MODE_EMA, PRICE_HIGH,i+1)+20*Point
     && Close[i+1]> iMA(symbol,0,828,0,MODE_EMA, PRICE_HIGH,i+1)+50*Point && Low[i]>Low[i+1] &&
     !(Low[i+3]>Low[i+2] && Low[i+2]< iMA(symbol,0,828,0,MODE_EMA, PRICE_CLOSE,i+2)+30*Point && Low[i+2]> iMA(symbol,0,828,0,MODE_EMA, PRICE_HIGH,i+2)-80*Point
     && Close[i+2]> iMA(symbol,0,828,0,MODE_EMA, PRICE_CLOSE,i+2)+50*Point && Low[i+1]>Low[i+2])){
                 ObjectCreate("Rakei"+i,OBJ_TEXT, 0, Time[i+1], Low[i+1]-10*Point);
                 ObjectSetText("Rakei"+i, "R", 33, "Arial Black", clrYellow);
                 ObjectCreate("Raker"+i,OBJ_TEXT, 0, Time[i+1], Low[i+1]-10*Point);
                 ObjectSetText("Raker"+i, " R", 33, "Arial Black", clrBlack);} 

////Green River
if (Low[i+2]>Low[i+1] && Low[i+1]< iMA(symbol,0,414,0,MODE_EMA, PRICE_HIGH,i+1)-30*Point && Low[i+1]> iMA(symbol,0,414,0,MODE_EMA, PRICE_HIGH,i+1)+20*Point
     && Close[i+1]> iMA(symbol,0,414,0,MODE_EMA, PRICE_HIGH,i+1)+50*Point && Low[i]>Low[i+1] &&
     !(Low[i+3]>Low[i+2] && Low[i+2]< iMA(symbol,0,414,0,MODE_EMA, PRICE_CLOSE,i+2)+30*Point && Low[i+2]> iMA(symbol,0,414,0,MODE_EMA, PRICE_HIGH,i+2)-80*Point
     && Close[i+2]> iMA(symbol,0,414,0,MODE_EMA, PRICE_CLOSE,i+2)+50*Point && Low[i+1]>Low[i+2])){
                 ObjectCreate("Rakei"+i,OBJ_TEXT, 0, Time[i+1], Low[i+1]-10*Point);
                 ObjectSetText("Rakei"+i, "R", 33, "Arial Black", clrYellow);
                 ObjectCreate("Raker"+i,OBJ_TEXT, 0, Time[i+1], Low[i+1]-10*Point);
                 ObjectSetText("Raker"+i, " R", 33, "Arial Black", clrBlack);}  
 




                 


//////////////////Rebound from above


///Maroon
 if (High[i+2]<High[i+1] && High[i+1]< iMA(symbol,0,135,0,MODE_EMA, PRICE_LOW,i+1)+30*Point && High[i+1]> iMA(symbol,0,135,0,MODE_EMA, PRICE_LOW,i+1)-20*Point
     && Close[i+1]< iMA(symbol,0,135,0,MODE_EMA, PRICE_LOW,i+1)+50*Point && High[i]<High[i+1] &&
     !(High[i+3]<High[i+2] && High[i+2]< iMA(symbol,0,135,0,MODE_EMA, PRICE_LOW,i+2)+30*Point && High[i+2]> iMA(symbol,0,135,0,MODE_EMA, PRICE_LOW,i+2)-20*Point
     && Close[i+2]< iMA(symbol,0,135,0,MODE_EMA, PRICE_LOW,i+2)+50*Point && High[i+1]<High[i+2])){
               ObjectCreate("Raken"+i,OBJ_TEXT, 0, Time[i+1], High[i+1]+20*Point);
                 ObjectSetText("Raken"+i, "R", 33, "Arial Black", clrBlack);
                 ObjectCreate("Rakez"+i,OBJ_TEXT, 0, Time[i+1], High[i+1]+20*Point);
                 ObjectSetText("Rakez"+i, " R", 33, "Arial Black", clrYellow);}

/////2H Lema
 if (High[i+2]<High[i+1] && High[i+1]< iMA(symbol,0,1556,0,MODE_EMA, PRICE_LOW,i+1)+30*Point && High[i+1]> iMA(symbol,0,1556,0,MODE_EMA, PRICE_LOW,i+1)-20*Point
     && Close[i+1]< iMA(symbol,0,1556,0,MODE_EMA, PRICE_LOW,i+1)+50*Point && High[i]<High[i+1] &&
     !(High[i+3]<High[i+2] && High[i+2]< iMA(symbol,0,1556,0,MODE_EMA, PRICE_LOW,i+2)+30*Point && High[i+2]> iMA(symbol,0,1556,0,MODE_EMA, PRICE_LOW,i+2)-20*Point
     && Close[i+2]< iMA(symbol,0,1556,0,MODE_EMA, PRICE_LOW,i+2)+50*Point && High[i+1]<High[i+2])){
               ObjectCreate("Raken"+i,OBJ_TEXT, 0, Time[i+2], High[i+2]+20*Point);
                 ObjectSetText("Raken"+i, "R", 33, "Arial Black", clrBlack);
                 ObjectCreate("Rakez"+i,OBJ_TEXT, 0, Time[i+2], High[i+2]+20*Point);
                 ObjectSetText("Rakez"+i, " R", 33, "Arial Black", clrYellow);}

                 
////19872       
 if (High[i+2]<High[i+1] && High[i+1]< iMA(symbol,0,19872,0,MODE_EMA, PRICE_LOW,i+1)+30*Point && High[i+1]> iMA(symbol,0,19872,0,MODE_EMA, PRICE_LOW,i+1)-20*Point
     && Close[i+1]< iMA(symbol,0,19872,0,MODE_EMA, PRICE_LOW,i+1)+50*Point && High[i]<High[i+1] &&
     !(High[i+3]<High[i+2] && High[i+2]< iMA(symbol,0,19872,0,MODE_EMA, PRICE_LOW,i+2)+30*Point && High[i+2]> iMA(symbol,0,19872,0,MODE_EMA, PRICE_LOW,i+2)-20*Point
     && Close[i+2]< iMA(symbol,0,19872,0,MODE_EMA, PRICE_LOW,i+2)+50*Point && High[i+1]<High[i+2])){
               ObjectCreate("Raken"+i,OBJ_TEXT, 0, Time[i+2], High[i+2]+20*Point);
                 ObjectSetText("Raken"+i, "R", 33, "Arial Black", clrBlack);
                 ObjectCreate("Rakez"+i,OBJ_TEXT, 0, Time[i+2], High[i+2]+20*Point);
                 ObjectSetText("Rakez"+i, " R", 33, "Arial Black", clrYellow);}               
                 
/////39744
    if (High[i+2]<High[i+1] && High[i+1]< iMA(symbol,0,39744,0,MODE_EMA, PRICE_LOW,i+1)+30*Point && High[i+1]> iMA(symbol,0,39744,0,MODE_EMA, PRICE_LOW,i+1)-20*Point
     && Close[i+1]< iMA(symbol,0,39744,0,MODE_EMA, PRICE_LOW,i+1)+50*Point && High[i]<High[i+1] &&
     !(High[i+3]<High[i+2] && High[i+2]< iMA(symbol,0,39744,0,MODE_EMA, PRICE_LOW,i+2)+30*Point && High[i+2]> iMA(symbol,0,39744,0,MODE_EMA, PRICE_LOW,i+2)-20*Point
     && Close[i+2]< iMA(symbol,0,39744,0,MODE_EMA, PRICE_LOW,i+2)+50*Point && High[i+1]<High[i+2])){
               ObjectCreate("Raken"+i,OBJ_TEXT, 0, Time[i+2], High[i+2]+20*Point);
                 ObjectSetText("Raken"+i, "R", 33, "Arial Black", clrBlack);
                 ObjectCreate("Rakez"+i,OBJ_TEXT, 0, Time[i+2], High[i+2]-20*Point);
                 ObjectSetText("Rakez"+i, " R", 33, "Arial Black", clrMagenta);}                    
                 
////30m Lema      
  if (High[i+2]<High[i+1] && High[i+1]< iMA(symbol,0,828,0,MODE_EMA, PRICE_LOW,i+1)+30*Point && High[i+1]> iMA(symbol,0,828,0,MODE_EMA, PRICE_LOW,i+1)-20*Point
     && Close[i+1]< iMA(symbol,0,828,0,MODE_EMA, PRICE_LOW,i+1)+50*Point && High[i]<High[i+1] &&
     !(High[i+3]<High[i+2] && High[i+2]< iMA(symbol,0,828,0,MODE_EMA, PRICE_LOW,i+2)+30*Point && High[i+2]> iMA(symbol,0,828,0,MODE_EMA, PRICE_LOW,i+2)-20*Point
     && Close[i+2]< iMA(symbol,0,828,0,MODE_EMA, PRICE_LOW,i+2)+50*Point && High[i+1]<High[i+2])){
                ObjectCreate("Raken"+i,OBJ_TEXT, 0, Time[i+1], High[i+1]+20*Point);
                 ObjectSetText("Raken"+i, "R", 33, "Arial Black", clrBlack);
                 ObjectCreate("Rakez"+i,OBJ_TEXT, 0, Time[i+1], High[i+1]+20*Point);
                 ObjectSetText("Rakez"+i, " R", 33, "Arial Black", clrYellow);}               


////Green River     
   if (High[i+2]<High[i+1] && High[i+1]< iMA(symbol,0,414,0,MODE_EMA, PRICE_LOW,i+1)+30*Point && High[i+1]> iMA(symbol,0,414,0,MODE_EMA, PRICE_LOW,i+1)-20*Point
     && Close[i+1]< iMA(symbol,0,414,0,MODE_EMA, PRICE_LOW,i+1)+50*Point && High[i]<High[i+1] &&
     !(High[i+3]<High[i+2] && High[i+2]< iMA(symbol,0,414,0,MODE_EMA, PRICE_LOW,i+2)+30*Point && High[i+2]> iMA(symbol,0,414,0,MODE_EMA, PRICE_LOW,i+2)-20*Point
     && Close[i+2]< iMA(symbol,0,414,0,MODE_EMA, PRICE_LOW,i+2)+50*Point && High[i+1]<High[i+2])){
               ObjectCreate("Raken"+i,OBJ_TEXT, 0, Time[i+1], High[i+1]+40*Point);
                 ObjectSetText("Raken"+i, "R", 33, "Arial Black", clrBlack);
                 ObjectCreate("Rakez"+i,OBJ_TEXT, 0, Time[i+1], High[i+1]+40*Point);
                 ObjectSetText("Rakez"+i, " R", 33, "Arial Black", clrYellow);}   


////Lower Guard Rail
 if (High[i+2]<High[i+1] && High[i+1]< iMA(symbol,0,414,0,MODE_EMA, PRICE_LOW,i+1)-FMax*10*Point+30*Point && High[i+1]> iMA(symbol,0,414,0,MODE_EMA, PRICE_LOW,i+1)-20*Point
     && Close[i+1]< iMA(symbol,0,414,0,MODE_EMA, PRICE_LOW,i+1)-FMax*10*Point+50*Point && High[i]<High[i+1] &&
     !(High[i+3]<High[i+2] && High[i+2]< iMA(symbol,0,414,0,MODE_EMA, PRICE_LOW,i+2)-FMax*10*Point+30*Point && High[i+2]> iMA(symbol,0,414,0,MODE_EMA, PRICE_LOW,i+2)-20*Point
     && Close[i+2]< iMA(symbol,0,414,0,MODE_EMA, PRICE_LOW,i+2)-FMax*10*Point+50*Point && High[i+1]<High[i+2])){
                ObjectCreate("Rakent"+i,OBJ_TEXT, 0, Time[i+1], High[i+1]+40*Point);
                 ObjectSetText("Rakent"+i, "R", 33, "Arial Black", clrBlack);
                 ObjectCreate("Rakezt"+i,OBJ_TEXT, 0, Time[i+1], High[i+1]+40*Point);
                 ObjectSetText("Rakezt"+i, " R", 33, "Arial Black", clrYellow);}   
}


 ////////////////
//Fake
/////////////////
    
    ////Maroon                 

       if ( High[i+1]> iMA(symbol,30,135,0,MODE_EMA, PRICE_HIGH,i+1)-30*Point && High[i+1]< iMA(symbol,30,135,0,MODE_EMA, PRICE_HIGH,i+1)+80*Point
     && Close[i+1]< iMA(symbol,30,135,0,MODE_EMA, PRICE_HIGH,i+1)-30*Point && High[i]<High[i+1]
     && Low[i+1]<Low[i+2] && Low[i+5]<iMA(symbol,30,135,0,MODE_EMA, PRICE_LOW,i+5)
     && Low[i+3]<iMA(symbol,30,135,0,MODE_EMA, PRICE_HIGH,i+3)
    && !(High[i+2]> iMA(symbol,30,135,0,MODE_EMA, PRICE_HIGH,i+2)-30*Point && High[i+2]< iMA(symbol,30,135,0,MODE_EMA, PRICE_HIGH,i+2)+80*Point
    && Close[i+2]< iMA(symbol,30,135,0,MODE_EMA, PRICE_HIGH,i+2)-50*Point && High[i+1]<High[i+2])
    ) {
                 ObjectCreate("Fakei"+i,OBJ_TEXT, 0, Time[i+1], High[i+1]+50*Point);
                 ObjectSetText("Fakei"+i, "F", 33, "Arial Black", clrYellow);
                 ObjectCreate("Faker"+i,OBJ_TEXT, 0, Time[i+1], High[i+1]+50*Point);
                 ObjectSetText("Faker"+i, " F", 33, "Arial Black", clrBlue);
                 fodir[i]=-1;
                 }
        

///////2H Lema

 if (Low[i+2]<Low[i+1] && High[i+1]> iMA(symbol,30,1556,0,MODE_EMA, PRICE_HIGH,i+1)-30*Point && High[i+1]< iMA(symbol,30,1556,0,MODE_EMA, PRICE_HIGH,i+1)+20*Point
     && Close[i+1]< iMA(symbol,30,1556,0,MODE_EMA, PRICE_HIGH,i+1)-50*Point && High[i]<High[i+1]
     && !(High[i+2]> iMA(symbol,30,1556,0,MODE_EMA, PRICE_HIGH,i+2)-30*Point && High[i+2]< iMA(symbol,30,1556,0,MODE_EMA, PRICE_HIGH,i+2)+20*Point
     && Close[i+2]< iMA(symbol,30,1556,0,MODE_EMA, PRICE_HIGH,i+2)-50*Point && High[i+1]<High[i+2])){
                 ObjectCreate("Fakei"+i,OBJ_TEXT, 0, Time[i+1], High[i+1]+40*Point);
                 ObjectSetText("Fakei"+i, "F", 33, "Arial Black", clrYellow);
                 ObjectCreate("Faker"+i,OBJ_TEXT, 0, Time[i+1], High[i+1]+40*Point);
                 ObjectSetText("Faker"+i, " F", 33, "Arial Black", clrBlack);
                 fodir[i]=-1;}


//////19872

if (Low[i+2]<Low[i+1] && High[i+1]> iMA(symbol,30,19872,0,MODE_EMA, PRICE_HIGH,i+1)-30*Point && High[i+1]< iMA(symbol,30,19872,0,MODE_EMA, PRICE_HIGH,i+1)+20*Point
     && Close[i+1]< iMA(symbol,30,19872,0,MODE_EMA, PRICE_HIGH,i+1)-10*Point && High[i]<High[i+1]
     && !(High[i+2]> iMA(symbol,30,19872,0,MODE_EMA, PRICE_HIGH,i+2)-30*Point && High[i+2]< iMA(symbol,30,19872,0,MODE_EMA, PRICE_HIGH,i+2)+20*Point
     && Close[i+2]< iMA(symbol,30,19872,0,MODE_EMA, PRICE_HIGH,i+2)-10*Point && High[i+1]<High[i+2])){
                 ObjectCreate("Fakei"+i,OBJ_TEXT, 0, Time[i+1], High[i+1]+40*Point);
                 ObjectSetText("Fakei"+i, "F", 33, "Arial Black", clrYellow);
                 ObjectCreate("Faker"+i,OBJ_TEXT, 0, Time[i+1], High[i+1]+40*Point);
                 ObjectSetText("Faker"+i, " F", 33, "Arial Black", clrBlack);
                 fodir[i]=-1;}


//////39744

if (Low[i+2]<Low[i+1] && High[i+1]> iMA(symbol,30,39744,0,MODE_EMA, PRICE_HIGH,i+1)-30*Point && High[i+1]< iMA(symbol,30,39744,0,MODE_EMA, PRICE_HIGH,i+1)+20*Point
     && Close[i+1]< iMA(symbol,30,39744,0,MODE_EMA, PRICE_HIGH,i+1)-10*Point && High[i]<High[i+1]
     && !(High[i+2]> iMA(symbol,30,39744,0,MODE_EMA, PRICE_HIGH,i+2)-30*Point && High[i+2]< iMA(symbol,30,39744,0,MODE_EMA, PRICE_HIGH,i+2)+20*Point
     && Close[i+2]< iMA(symbol,30,39744,0,MODE_EMA, PRICE_HIGH,i+2)-10*Point && High[i+1]<High[i+2])){
                 ObjectCreate("Fakei"+i,OBJ_TEXT, 0, Time[i+1], High[i+1]+40*Point);
                 ObjectSetText("Fakei"+i, "F", 33, "Arial Black", clrMagenta);
                 ObjectCreate("Faker"+i,OBJ_TEXT, 0, Time[i+1], High[i+1]+40*Point);
                 ObjectSetText("Faker"+i, " F", 33, "Arial Black", clrBlack);
                 fodir[i]=-1;}

////30m Lema 
if (Low[i+2]<Low[i+1] && High[i+1]> iMA(symbol,30,828,0,MODE_EMA, PRICE_HIGH,i+1)-30*Point && High[i+1]< iMA(symbol,30,828,0,MODE_EMA, PRICE_HIGH,i+1)+20*Point
     && Close[i+1]< iMA(symbol,30,828,0,MODE_EMA, PRICE_HIGH,i+1)-10*Point && High[i]<High[i+1]
     && !(High[i+2]> iMA(symbol,30,828,0,MODE_EMA, PRICE_HIGH,i+2)-30*Point && High[i+2]< iMA(symbol,30,828,0,MODE_EMA, PRICE_HIGH,i+2)+20*Point
     && Close[i+2]< iMA(symbol,30,828,0,MODE_EMA, PRICE_HIGH,i+2)-10*Point && High[i+1]<High[i+2])){
                 ObjectCreate("Fakei"+i,OBJ_TEXT, 0, Time[i+1], High[i+1]+40*Point);
                 ObjectSetText("Fakei"+i, "F", 33, "Arial Black", clrYellow);
                 ObjectCreate("Faker"+i,OBJ_TEXT, 0, Time[i+1], High[i+1]+40*Point);
                 ObjectSetText("Faker"+i, " F", 33, "Arial Black", clrBlack);
                 fodir[i]=-1;} 

////Green River
if (High[i+2]<High[i+1] && High[i+1]> iMA(symbol,30,414,0,MODE_EMA, PRICE_HIGH,i+1)-35*Point && High[i+1]< iMA(symbol,30,414,0,MODE_EMA, PRICE_HIGH,i+1)+20*Point
     && Close[i+1]< iMA(symbol,30,414,0,MODE_EMA, PRICE_HIGH,i+1)-50*Point && High[i]<High[i+1] 
     && (Low[i+3]<iMA(symbol,30,414,0,MODE_EMA, PRICE_LOW,i+3)  || Low[i+4]<iMA(symbol,30,414,0,MODE_EMA, PRICE_LOW,i+4) ||  Low[i+5]<iMA(symbol,30,414,0,MODE_EMA, PRICE_LOW,i+5))
     && !(High[i+2]> iMA(symbol,30,414,0,MODE_EMA, PRICE_HIGH,i+2)-35*Point && High[i+2]< iMA(symbol,30,414,0,MODE_EMA, PRICE_HIGH,i+2)+20*Point
     && Close[i+2]< iMA(symbol,30,414,0,MODE_EMA, PRICE_HIGH,i+2)-50*Point && High[i+1]<High[i+2])
         
      ){
                 ObjectCreate("Fakei"+i,OBJ_TEXT, 0, Time[i+1], High[i+1]+40*Point);
                 ObjectSetText("Fakei"+i, "F", 33, "Arial Black", clrYellow);
                 ObjectCreate("Faker"+i,OBJ_TEXT, 0, Time[i+1], High[i+1]+40*Point);
                 ObjectSetText("Faker"+i, " F", 33, "Arial Black", clrBlack);
                 fodir[i]=-1;}  
                 
////Lower Guard Rail
  if (High[i+2]>High[i+1] && High[i+1]< iMA(symbol,30,414,0,MODE_EMA, PRICE_LOW,i+1)-FMax*10*Point+100*Point && High[i+1]> iMA(symbol,30,414,0,MODE_EMA, PRICE_LOW,i+1)-FMax*10*Point-20*Point
     && Close[i+1]> iMA(symbol,30,414,0,MODE_EMA, PRICE_LOW,i+1)-FMax*10*Point+50*Point && Low[i]>Low[i+1]
     && Low[i+2]<iMA(symbol,30,414,0,MODE_EMA, PRICE_LOW,i+1)-FMax*10*Point
     && !(Low[i+2]< iMA(symbol,30,414,0,MODE_EMA, PRICE_LOW,i+2)-FMax*10*Point+30*Point && Low[i+2]> iMA(symbol,30,414,0,MODE_EMA, PRICE_LOW,i+2)-FMax*10*Point-20*Point
     && Close[i+2]> iMA(symbol,30,414,0,MODE_EMA, PRICE_LOW,i+2)-FMax*10*Point+50*Point && Low[i+1]>Low[i+2])
     && (Open[i+2]<iMA(symbol,30,414,0,MODE_EMA, PRICE_LOW,i+2)-FMax*10*Point  || Open[i+1]<iMA(symbol,30,414,0,MODE_EMA, PRICE_LOW,i+2)-FMax*10*Point)
     ){
                ObjectCreate("Fakeii"+i,OBJ_TEXT, 0, Time[i+2], High[i+2]+50*Point);
                 ObjectSetText("Fakeii"+i, "F", 33, "Arial Black", clrYellow);
                 ObjectCreate("Fakeri"+i,OBJ_TEXT, 0, Time[i+2], High[i+2]+50*Point);
                 ObjectSetText("Fakeri"+i, " F", 33, "Arial Black", clrBlue);
                 fodir[i]=-1;}  



////Upper Guard Rail
  if (High[i+2]>High[i+1] 
  && High[i+1]< iMA(symbol,30,414,0,MODE_EMA, PRICE_HIGH,i+1)+FMax*10*Point+100*Point && High[i+1]> iMA(symbol,30,414,0,MODE_EMA, PRICE_HIGH,i+1)+FMax*10*Point-20*Point
     && Close[i+1]< iMA(symbol,30,414,0,MODE_EMA, PRICE_HIGH,i+1)+FMax*10*Point+50*Point && Low[i]<Low[i+1]
     && Low[i+2]<iMA(symbol,30,414,0,MODE_EMA, PRICE_HIGH,i+1)+FMax*10*Point
 //    && !(Low[i+2]< iMA(symbol,30,414,0,MODE_EMA, PRICE_LOW,i+2)+FMax*10*Point+30*Point && Low[i+2]> iMA(symbol,30,414,0,MODE_EMA, PRICE_LOW,i+2)+FMax*10*Point-20*Point
//     && Close[i+2]> iMA(symbol,30,414,0,MODE_EMA, PRICE_LOW,i+2)+FMax*10*Point+50*Point && Low[i+1]>Low[i+2])
){
                ObjectCreate("Fakeiii"+i,OBJ_TEXT, 0, Time[i+2], High[i+2]+40*Point);
                 ObjectSetText("Fakeiii"+i, "F", 33, "Arial Black", clrYellow);
                 ObjectCreate("Fakerii"+i,OBJ_TEXT, 0, Time[i+2], High[i+2]+40*Point);
                 ObjectSetText("Fakerii"+i, " F", 33, "Arial Black", clrNavy);
                 fodir[i]=-1;
                 }  
                 
                 
////Upper PHaze Rail
  if (High[i+2]<High[i+1] &&
   High[i+1]< iMA(symbol,30,414,0,MODE_EMA, PRICE_HIGH,i+1)+3*FMax*10*Point+100*Point && High[i+1]> iMA(symbol,30,414,0,MODE_EMA, PRICE_HIGH,i+1)+3*FMax*10*Point-20*Point
     && Close[i+1]< iMA(symbol,30,414,0,MODE_EMA, PRICE_HIGH,i+1)+3*FMax*10*Point+50*Point && Low[i+1]<Low[i+2]
     && Low[i+2]<iMA(symbol,30,414,0,MODE_EMA, PRICE_HIGH,i+1)+3*FMax*10*Point
     && !(Low[i+2]< iMA(symbol,30,414,0,MODE_EMA, PRICE_LOW,i+2)+3*FMax*10*Point+30*Point && Low[i+2]> iMA(symbol,30,414,0,MODE_EMA, PRICE_LOW,i+2)+3*FMax*10*Point-20*Point
     && Close[i+2]> iMA(symbol,30,414,0,MODE_EMA, PRICE_LOW,i+2)+3*FMax*10*Point+50*Point && Low[i+1]>Low[i+2])
){
                ObjectCreate("Fakeiiii"+i,OBJ_TEXT, 0, Time[i+2], High[i+2]+50*Point);
                 ObjectSetText("Fakeiiii"+i, "F", 33, "Arial Black", clrYellow);
                 ObjectCreate("Fakeriii"+i,OBJ_TEXT, 0, Time[i+2], High[i+2]+50*Point);
                 ObjectSetText("Fakeriii"+i, " F", 33, "Arial Black", clrNavy);
                 fodir[i]=-1;}                   



/////////////////////////////////


///Maroon
//High[i+2]>High[i+1] &&
 if ( Low[i+1]< iMA(symbol,30,135,0,MODE_EMA, PRICE_LOW,i+1)+30*Point && Low[i+1]> iMA(symbol,30,135,0,MODE_EMA, PRICE_LOW,i+1)-70*Point
     && Close[i+1]> iMA(symbol,30,135,0,MODE_EMA, PRICE_LOW,i+1)-10*Point && Low[i]>Low[i+1] 
     && (High[i+2]> iMA(symbol,30,135,0,MODE_EMA, PRICE_HIGH,i+2)-10*Point  || High[i+3]> iMA(symbol,30,135,0,MODE_EMA, PRICE_HIGH,i+3)-10*Point )
     && !(Low[i+2]< iMA(symbol,30,135,0,MODE_EMA, PRICE_LOW,i+2)+30*Point && Low[i+2]> iMA(symbol,30,135,0,MODE_EMA, PRICE_LOW,i+2)-70*Point
     && Close[i+2]> iMA(symbol,30,135,0,MODE_EMA, PRICE_LOW,i+2)-10*Point && Low[i+1]>Low[i+2] )
     
//    && !(Low[i+2]< iMA(symbol,30,135,0,MODE_EMA, PRICE_LOW,i+2)+30*Point && Low[i+2]> iMA(symbol,30,135,0,MODE_EMA, PRICE_LOW,i+2)-50*Point
//     && Close[i+2]> iMA(symbol,30,135,0,MODE_EMA, PRICE_LOW,i+2)+30*Point && Low[i+1]<Low[i+2])
     
     ){
               ObjectCreate("Faken"+i,OBJ_TEXT, 0, Time[i+1], Low[i+1]+10*Point);
                 ObjectSetText("Faken"+i, "F", 33, "Arial Black", clrBlack);
                 ObjectCreate("Fakez"+i,OBJ_TEXT, 0, Time[i+1], Low[i+1]+10*Point);
                 ObjectSetText("Fakez"+i, " F", 33, "Arial Black", clrYellow);
                 fodir[i]=1;}

/////2H Lema

 if (High[i]>High[i+1] && Low[i+1]< iMA(symbol,30,1556,0,MODE_EMA, PRICE_LOW,i+1)+20*Point && Low[i+1]> iMA(symbol,30,1556,0,MODE_EMA, PRICE_LOW,i+1)-40*Point
     && Close[i+1]> iMA(symbol,30,1556,0,MODE_EMA, PRICE_LOW,i+1)+10*Point && Low[i]>Low[i+1]
     && !(Low[i+2]< iMA(symbol,30,1556,0,MODE_EMA, PRICE_LOW,i+2)+20*Point && Low[i+2]> iMA(symbol,30,1556,0,MODE_EMA, PRICE_LOW,i+2)-40*Point
     && Close[i+2]> iMA(symbol,30,1556,0,MODE_EMA, PRICE_LOW,i+2)+50*Point && Low[i+1]>Low[i+2])){
               ObjectCreate("Faken"+i,OBJ_TEXT, 0, Time[i+1], Low[i+1]+10*Point);
                 ObjectSetText("Faken"+i, "F", 33, "Arial Black", clrBlack);
                 ObjectCreate("Fakez"+i,OBJ_TEXT, 0, Time[i+1], Low[i+1]+10*Point);
                 ObjectSetText("Fakez"+i, " F", 33, "Arial Black", clrYellow);
                 fodir[i]=1;}
                 
////19872       
  if (High[i+2]>High[i+1] && Low[i+1]< iMA(symbol,30,19872,0,MODE_EMA, PRICE_LOW,i+1)+20*Point && Low[i+1]> iMA(symbol,30,19872,0,MODE_EMA, PRICE_LOW,i+1)-30*Point
     && Close[i+1]> iMA(symbol,30,19872,0,MODE_EMA, PRICE_LOW,i+1)+10*Point && Low[i]>Low[i+1]
     && !(Low[i+2]< iMA(symbol,30,19872,0,MODE_EMA, PRICE_LOW,i+2)+20*Point && Low[i+2]> iMA(symbol,30,19872,0,MODE_EMA, PRICE_LOW,i+2)-30*Point
     && Close[i+2]> iMA(symbol,30,19872,0,MODE_EMA, PRICE_LOW,i+2)+50*Point && Low[i+1]>Low[i+2])){
               ObjectCreate("Faken"+i,OBJ_TEXT, 0, Time[i+1], Low[i+1]+10*Point);
                 ObjectSetText("Faken"+i, "F", 33, "Arial Black", clrBlack);
                 ObjectCreate("Fakez"+i,OBJ_TEXT, 0, Time[i+1], Low[i+1]+10*Point);
                 ObjectSetText("Fakez"+i, " F", 33, "Arial Black", clrYellow);
                 fodir[i]=1;}               
                 
/////39744
  if (Low[i+1]< iMA(symbol,30,39744,0,MODE_EMA, PRICE_LOW,i+1)+20*Point && Low[i+1]> iMA(symbol,30,39744,0,MODE_EMA, PRICE_LOW,i+1)-30*Point
     && Close[i+1]> iMA(symbol,30,39744,0,MODE_EMA, PRICE_LOW,i+1)+50*Point && Low[i]>Low[i+1]
     && !(Low[i+2]< iMA(symbol,30,39744,0,MODE_EMA, PRICE_LOW,i+2)+20*Point && Low[i+2]> iMA(symbol,30,39744,0,MODE_EMA, PRICE_LOW,i+2)-30*Point
     && Close[i+2]> iMA(symbol,30,39744,0,MODE_EMA, PRICE_LOW,i+2)+50*Point && Low[i+1]>Low[i+2])){
               ObjectCreate("Faken"+i,OBJ_TEXT, 0, Time[i+1], Low[i+1]+10*Point);
                 ObjectSetText("Faken"+i, "F", 33, "Arial Black", clrBlack);
                 ObjectCreate("Fakez"+i,OBJ_TEXT, 0, Time[i+1], Low[i+1]+10*Point);
                 ObjectSetText("Fakez"+i, " F", 33, "Arial Black", clrMagenta);
                 fodir[i]=1;}                      
                 
////30m Lema      
  if (High[i+2]>High[i+1] && Low[i+1]< iMA(symbol,30,828,0,MODE_EMA, PRICE_LOW,i+1)+20*Point && Low[i+1]> iMA(symbol,30,828,0,MODE_EMA, PRICE_LOW,i+1)-30*Point
     && Close[i+1]> iMA(symbol,30,828,0,MODE_EMA, PRICE_LOW,i+1)+10*Point && High[i]>High[i+1]
     && !(Low[i+2]< iMA(symbol,30,828,0,MODE_EMA, PRICE_LOW,i+2)+20*Point && Low[i+2]> iMA(symbol,30,828,0,MODE_EMA, PRICE_LOW,i+2)-30*Point
     && Close[i+2]> iMA(symbol,30,828,0,MODE_EMA, PRICE_LOW,i+2)+10*Point && Low[i+1]>Low[i+2])){
               ObjectCreate("Faken"+i,OBJ_TEXT, 0, Time[i+1], Low[i+1]+10*Point);
                 ObjectSetText("Faken"+i, "F", 33, "Arial Black", clrBlack);
                 ObjectCreate("Fakez"+i,OBJ_TEXT, 0, Time[i+1], Low[i+1]+10*Point);
                 ObjectSetText("Fakez"+i, " F", 33, "Arial Black", clrYellow);
                 fodir[i]=1;}               


////Green River     
  if (High[i+2]>High[i+1] && Low[i+1]< iMA(symbol,30,414,0,MODE_EMA, PRICE_LOW,i+1)-30*Point && Low[i+1]> iMA(symbol,30,414,0,MODE_EMA, PRICE_LOW,i+1)-90*Point
     && Close[i+1]> iMA(symbol,30,414,0,MODE_EMA, PRICE_LOW,i+1)+10*Point && Low[i]>Low[i+1]
     && !(Low[i+2]< iMA(symbol,30,414,0,MODE_EMA, PRICE_LOW,i+2)-30*Point && Low[i+2]> iMA(symbol,30,414,0,MODE_EMA, PRICE_LOW,i+2)-90*Point
     && Close[i+2]> iMA(symbol,30,414,0,MODE_EMA, PRICE_LOW,i+2)+50*Point && Low[i+1]>Low[i+2])){
               ObjectCreate("Faken"+i,OBJ_TEXT, 0, Time[i+2], Low[i+2]+10*Point);
                 ObjectSetText("Faken"+i, "F", 33, "Arial Black", clrBlack);
                 ObjectCreate("Fakez"+i,OBJ_TEXT, 0, Time[i+2], Low[i+2]+10*Point);
                 ObjectSetText("Fakez"+i, " F", 33, "Arial Black", clrYellow);
                 fodir[i]=1;} 
                 

////Lower Guard Rail
  if (Low[i+2]>Low[i+1] && Low[i+1]< iMA(symbol,30,414,0,MODE_EMA, PRICE_LOW,i+1)-FMax*10*Point && Low[i+1]> iMA(symbol,30,414,0,MODE_EMA, PRICE_LOW,i+1)-FMax*10*Point-60*Point
     && Close[i+1]> iMA(symbol,30,414,0,MODE_EMA, PRICE_LOW,i+1)-FMax*10*Point && Low[i]>Low[i+1]
  //   && Low[i+2]<iMA(symbol,30,414,0,MODE_EMA, PRICE_LOW,i+1)-FMax*10*Point
     && !(Low[i+3]>Low[i+2] && Low[i+2]< iMA(symbol,30,414,0,MODE_EMA, PRICE_LOW,i+2)-FMax*10*Point && Low[i+2]> iMA(symbol,30,414,0,MODE_EMA, PRICE_LOW,i+2)-FMax*10*Point-60*Point
     && Close[i+2]> iMA(symbol,30,414,0,MODE_EMA, PRICE_LOW,i+2)-FMax*10*Point && Low[i+1]>Low[i+2])
    // && (Open[i+2]>iMA(symbol,30,414,0,MODE_EMA, PRICE_LOW,i+2)-FMax*10*Point  || Open[i+1]>iMA(symbol,30,414,0,MODE_EMA, PRICE_LOW,i+2)-FMax*10*Point)
     ){
                 ObjectCreate("Faken"+i,OBJ_TEXT, 0, Time[i+1], Low[i+1]+10*Point);
                 ObjectSetText("Faken"+i, "F", 33, "Arial Black", clrBlack);
                 ObjectCreate("Fakez"+i,OBJ_TEXT, 0, Time[i+1], Low[i+1]+10*Point);
                 ObjectSetText("Fakez"+i, " F", 33, "Arial Black", clrYellow);
                 fodir[i]=1;} 
                        
                 
   }                        
                 


}

deletetxt1("LEMA");


if (Period()==30){

///downside fake-out boxes








if (MathAbs(Open[0]-iMA(symbol,30,414,0,MODE_EMA, PRICE_LOW,0)-FMax*10*Point)<800*Point && Open[4]>iMA(symbol,30,414,0,MODE_EMA, PRICE_LOW,0)-FMax*10*Point)
 ObjectCreate("LEMAGRL", OBJ_RECTANGLE, 0,  Time[15], iMA(symbol,30,414,0,MODE_EMA, PRICE_LOW,0)-FMax*10*Point-60*Point, Time[25], iMA(symbol,30,414,0,MODE_EMA, PRICE_LOW,0)-FMax*10*Point-120*Point);
  ObjectSetInteger(0,"LEMAGRL",OBJPROP_COLOR,clrCyan);
  ObjectSet("LEMAGRL",OBJPROP_BACK,0);
  ObjectSet("LEMAGRL",OBJPROP_WIDTH,5);

if (MathAbs(Open[0]-iMA(symbol,30,1556,0,MODE_EMA, PRICE_LOW,0))<800*Point && Open[4]>iMA(symbol,30,1556,0,MODE_EMA, PRICE_LOW,0))
 ObjectCreate("LEMA1556L", OBJ_RECTANGLE, 0,  Time[15], iMA(symbol,30,1556,0,MODE_EMA, PRICE_LOW,0)-10*Point, Time[25], iMA(symbol,30,1556,0,MODE_EMA, PRICE_LOW,0)-60*Point);
  ObjectSetInteger(0,"LEMA1556L",OBJPROP_COLOR,clrCyan);
  ObjectSet("LEMA1556L",OBJPROP_BACK,0);
  ObjectSet("LEMA1556L",OBJPROP_WIDTH,5);


if (MathAbs(Open[0]-iMA(symbol,30,414,0,MODE_EMA, PRICE_LOW,0))<800*Point && Open[4]>iMA(symbol,30,414,0,MODE_EMA, PRICE_LOW,0))
 ObjectCreate("LEMA414L", OBJ_RECTANGLE, 0,  Time[15], iMA(symbol,30,414,0,MODE_EMA, PRICE_LOW,0)-10*Point, Time[25], iMA(symbol,30,414,0,MODE_EMA, PRICE_LOW,0)-60*Point);
  ObjectSetInteger(0,"LEMA414L",OBJPROP_COLOR,clrCyan);
  ObjectSet("LEMA414L",OBJPROP_BACK,0);
  ObjectSet("LEMA414L",OBJPROP_WIDTH,5);


if (MathAbs(Open[0]-iMA(symbol,30,828,0,MODE_EMA, PRICE_LOW,0))<800*Point && Open[4]>iMA(symbol,30,828,0,MODE_EMA, PRICE_LOW,0))
 ObjectCreate("LEMA828L", OBJ_RECTANGLE, 0,  Time[15], iMA(symbol,30,828,0,MODE_EMA, PRICE_LOW,0)-10*Point, Time[25], iMA(symbol,30,828,0,MODE_EMA, PRICE_LOW,0)-60*Point);
  ObjectSetInteger(0,"LEMA828L",OBJPROP_COLOR,clrCyan);
  ObjectSet("LEMA828L",OBJPROP_BACK,0);
  ObjectSet("LEMA828L",OBJPROP_WIDTH,5);


if (MathAbs(Open[0]-iMA(symbol,30,135,0,MODE_EMA, PRICE_LOW,0))<800*Point && Open[4]>iMA(symbol,30,135,0,MODE_EMA, PRICE_LOW,0))
 ObjectCreate("LEMA135L", OBJ_RECTANGLE, 0,  Time[15], iMA(symbol,30,135,0,MODE_EMA, PRICE_LOW,0)-10*Point, Time[25], iMA(symbol,30,135,0,MODE_EMA, PRICE_LOW,0)-60*Point);
  ObjectSetInteger(0,"LEMA135L",OBJPROP_COLOR,clrCyan);
  ObjectSet("LEMA135L",OBJPROP_BACK,0);
  ObjectSet("LEMA135L",OBJPROP_WIDTH,5);



///upside fake-out boxes

if (MathAbs(Open[0]-iMA(symbol,30,414,0,MODE_EMA, PRICE_HIGH,0)+FMax*10*Point)<800*Point && Open[3]<iMA(symbol,30,414,0,MODE_EMA, PRICE_HIGH,0)+FMax*10*Point)
 ObjectCreate("LEMAGRU", OBJ_RECTANGLE, 0,  Time[15], iMA(symbol,30,414,0,MODE_EMA, PRICE_HIGH,0)+FMax*10*Point+60*Point, Time[25], iMA(symbol,30,414,0,MODE_EMA, PRICE_HIGH,0)+FMax*10*Point+120*Point);
  ObjectSetInteger(0,"LEMAGRU",OBJPROP_COLOR,clrOrangeRed);
  ObjectSet("LEMAGRU",OBJPROP_BACK,0);
  ObjectSet("LEMAGRU",OBJPROP_WIDTH,5);
  

if (MathAbs(Open[0]-iMA(symbol,30,1556,0,MODE_EMA, PRICE_HIGH,0))<800*Point && Open[3]<iMA(symbol,30,1556,0,MODE_EMA, PRICE_HIGH,0))
 ObjectCreate("LEMA1556U", OBJ_RECTANGLE, 0,  Time[15], iMA(symbol,30,1556,0,MODE_EMA, PRICE_HIGH,0)+60*Point, Time[25], iMA(symbol,30,1556,0,MODE_EMA, PRICE_HIGH,0)+10*Point);
  ObjectSetInteger(0,"LEMA1556U",OBJPROP_COLOR,clrOrangeRed);
  ObjectSet("LEMA1556U",OBJPROP_BACK,0);
  ObjectSet("LEMA1556U",OBJPROP_WIDTH,5);  


if (MathAbs(Open[0]-iMA(symbol,30,414,0,MODE_EMA, PRICE_HIGH,0))<800*Point && Open[3]<iMA(symbol,30,414,0,MODE_EMA, PRICE_HIGH,0))
 ObjectCreate("LEMA414U", OBJ_RECTANGLE, 0,  Time[15], iMA(symbol,30,414,0,MODE_EMA, PRICE_HIGH,0)+60*Point, Time[25], iMA(symbol,30,414,0,MODE_EMA, PRICE_HIGH,0)+10*Point);
  ObjectSetInteger(0,"LEMA414U",OBJPROP_COLOR,clrOrangeRed);
  ObjectSet("LEMA414U",OBJPROP_BACK,0);
  ObjectSet("LEMA414U",OBJPROP_WIDTH,5);


if (MathAbs(Open[0]-iMA(symbol,30,414,0,MODE_EMA, PRICE_HIGH,0))<800*Point && Open[3]<iMA(symbol,30,414,0,MODE_EMA, PRICE_HIGH,0))
 ObjectCreate("LEMA414U", OBJ_RECTANGLE, 0,  Time[15], iMA(symbol,30,414,0,MODE_EMA, PRICE_HIGH,0)+60*Point, Time[25], iMA(symbol,30,414,0,MODE_EMA, PRICE_HIGH,0)+10*Point);
  ObjectSetInteger(0,"LEMA414U",OBJPROP_COLOR,clrOrangeRed);
  ObjectSet("LEMA414U",OBJPROP_BACK,0);
  ObjectSet("LEMA414U",OBJPROP_WIDTH,5);


if (MathAbs(Open[0]-iMA(symbol,30,828,0,MODE_EMA, PRICE_HIGH,0))<800*Point && Open[3]<iMA(symbol,30,828,0,MODE_EMA, PRICE_HIGH,0))
 ObjectCreate("LEMA828U", OBJ_RECTANGLE, 0,  Time[15], iMA(symbol,30,828,0,MODE_EMA, PRICE_HIGH,0)+60*Point, Time[25], iMA(symbol,30,828,0,MODE_EMA, PRICE_HIGH,0)+10*Point);
  ObjectSetInteger(0,"LEMA828U",OBJPROP_COLOR,clrOrangeRed);
  ObjectSet("LEMA828U",OBJPROP_BACK,0);
  ObjectSet("LEMA828U",OBJPROP_WIDTH,5);


if (MathAbs(Open[0]-iMA(symbol,30,135,0,MODE_EMA, PRICE_HIGH,0))<800*Point && Open[3]<iMA(symbol,30,135,0,MODE_EMA, PRICE_HIGH,0))
 ObjectCreate("LEMA135U", OBJ_RECTANGLE, 0,  Time[15], iMA(symbol,30,135,0,MODE_EMA, PRICE_HIGH,0)+60*Point, Time[25], iMA(symbol,30,135,0,MODE_EMA, PRICE_HIGH,0)+10*Point);
  ObjectSetInteger(0,"LEMA135U",OBJPROP_COLOR,clrOrangeRed);
  ObjectSet("LEMA135U",OBJPROP_BACK,0);
  ObjectSet("LEMA135U",OBJPROP_WIDTH,5);





}




if (plot_fluctuation_brackets){
deletetxt1("Fluct"); 
deletetxt1("Der"); 
deletetxt1("Abigail");
deletetxt1("NOBR");

n=1;  
   while (n<Bars){
      if ( RSI2[n]<44 &&  RSI2[n]< RSI2[n-1] &&  RSI2[n]< RSI2[n+1]) break;
      n++;
   }


if (n<Bars  && Period()<=240) { ObjectDelete(0,"Fluct");
     if (n<7) ObjectCreate(0,"Fluct",OBJ_TREND,0,Time[n],Low[n],Time[1],Low[n]+FSize*10*Point,0,0);
     else ObjectCreate(0,"Fluct",OBJ_TREND,0,Time[n],Low[n],Time[n-7],Low[n]+FSize*10*Point,0,0);
    ObjectSetInteger(0,"Fluct",OBJPROP_RAY_RIGHT,false);
         ObjectSet("Fluct",OBJPROP_COLOR,clrWhite);
         ObjectSet("Fluct",OBJPROP_WIDTH,1); 
       
       
                 if (n<7) ObjectCreate("Abigail"+n, OBJ_RECTANGLE, 0,  Time[8], (Low[n]+FSize*10*Point), Time[0], Low[n]+FSize*10*Point+FSize/5*10*Point);
                  else ObjectCreate("Abigail"+n, OBJ_RECTANGLE, 0,  Time[n], (Low[n]+FSize*10*Point), Time[0], Low[n]+FSize*10*Point+FSize/5*10*Point);
  ObjectSetInteger(0,"Abigail"+n,OBJPROP_COLOR,clrOrange);
  ObjectSet("Abigail"+n,OBJPROP_BACK,0);
  ObjectSet("Abigail"+n,OBJPROP_WIDTH,5);
       
       
                        if (n<7) ObjectCreate("Abigail"+o, OBJ_RECTANGLE, 0,  Time[8], (Low[n]+FSize*10*Point), Time[0], Low[n]+FSize*10*Point+FSize/5*10*Point);
                  else ObjectCreate("Abigail"+o, OBJ_RECTANGLE, 0,  Time[n], (Low[n]+FSize*10*Point), Time[0], Low[n]+FSize*10*Point+FSize/5*10*Point);
  ObjectSetInteger(0,"Abigail"+o,OBJPROP_COLOR,clrMagenta);
  ObjectSet("Abigail"+o,OBJPROP_BACK,1);
  ObjectSet("Abigail"+o,OBJPROP_WIDTH,5);
  
  
//  ObjectCreate("Abigail"+o+o, OBJ_RECTANGLE, 0,  Time[32], (Low[n]+FSize*10*Point), Time[4], Low[n]+FSize*10*Point+FSize/5*10*Point);
//  ObjectSetInteger(0,"Abigail"+o+o,OBJPROP_COLOR,clrOrange);
//  ObjectSet("Abigail"+o+o,OBJPROP_BACK,0);
//  ObjectSet("Abigail"+o+o,OBJPROP_WIDTH,5);
  
  
//       ObjectCreate("NOBR", OBJ_TEXT, 0, Time[22], (Low[n]+FSize*10*Point)+30*Point); 
//               ObjectSetText("NOBR", "NO BREAK / EXTENSION", 28, "Arial Black", clrOrange);
  
}


o=1;  
   while (o<Bars){
      if (RSI2[o]>56 && RSI2[o]>RSI2[o-1] && RSI2[o]>RSI2[o+1]) break;
      o++;
   }


if (o<Bars  && Period()<=240) { ObjectDelete(0,"Der");
   if (o<7) ObjectCreate(0,"Der",OBJ_TREND,0,Time[o],High[o],Time[1],High[o]-FSize*10*Point,0,0);
    else  ObjectCreate(0,"Der",OBJ_TREND,0,Time[o],High[o],Time[o-7],High[o]-FSize*10*Point,0,0);
    ObjectSetInteger(0,"Der",OBJPROP_RAY_RIGHT,false);
         ObjectSet("Der",OBJPROP_COLOR,clrWhite);
         ObjectSet("Der",OBJPROP_WIDTH,1); 
         
         
         if (o<7)  ObjectCreate("Abigail"+o, OBJ_RECTANGLE, 0,  Time[8], (High[o]-FSize*10*Point), Time[0], High[o]-FSize*10*Point-FSize/5*10*Point);
         else ObjectCreate("Abigail"+o, OBJ_RECTANGLE, 0,  Time[o], (High[o]-FSize*10*Point), Time[0], High[o]-FSize*10*Point-FSize/5*10*Point);
  ObjectSetInteger(0,"Abigail"+o,OBJPROP_COLOR,clrOrange);
  ObjectSet("Abigail"+o,OBJPROP_BACK,0);
  ObjectSet("Abigail"+o,OBJPROP_WIDTH,5);
  
  
           if (o<7)  ObjectCreate("Abigail"+o+n, OBJ_RECTANGLE, 0,  Time[8], (High[o]-FSize*10*Point), Time[0], High[o]-FSize*10*Point-FSize/5*10*Point);
         else ObjectCreate("Abigail"+o+n, OBJ_RECTANGLE, 0,  Time[o], (High[o]-FSize*10*Point), Time[0], High[o]-FSize*10*Point-FSize/5*10*Point);
  ObjectSetInteger(0,"Abigail"+o+n,OBJPROP_COLOR,clrLime);
  ObjectSet("Abigail"+o+n,OBJPROP_BACK,1);
  ObjectSet("Abigail"+o+n,OBJPROP_WIDTH,5);
  
//  ObjectCreate("Abigail"+o+n+o, OBJ_RECTANGLE, 0,  Time[32], (High[o]-FSize*10*Point), Time[4], High[o]-FSize*10*Point-FSize/5*10*Point);
//  ObjectSetInteger(0,"Abigail"+o+n+o,OBJPROP_COLOR,clrOrange);
 // ObjectSet("Abigail"+o+n+o,OBJPROP_BACK,0);
 // ObjectSet("Abigail"+o+n+o,OBJPROP_WIDTH,5);
  
  
//   ObjectCreate("NOBR2", OBJ_TEXT, 0, Time[22], (High[o]-FSize*10*Point)); 
//               ObjectSetText("NOBR2", "NO BREAK / EXTENSION", 28, "Arial Black", clrOrange);
  
}  
  }

deletetxt1("Pol");

if (plot_polarities){

ObjectCreate( "Pol1", OBJ_TREND, 0, Time[1], NormalizeDouble(iMA(symbol,30,414,0,MODE_EMA, PRICE_LOW,0)-FMax*10*Point-90*Point,4), Time[0], NormalizeDouble(iMA(symbol,30,414,0,MODE_EMA, PRICE_LOW,0)-FMax*10*Point-90*Point,4));
               ObjectSet("Pol1", OBJPROP_COLOR, clrBlack);
               ObjectSet("Pol1", OBJPROP_STYLE, 2 );
               ObjectSet("Pol1", OBJPROP_WIDTH, 3 );
               ObjectSet("Pol1",OBJPROP_RAY_RIGHT,true);
               ObjectSet("Pol1", OBJPROP_BACK, 1 );
               
               
ObjectCreate( "Pol2", OBJ_TREND, 0, Time[1], NormalizeDouble(iMA(symbol,30,414,0,MODE_EMA, PRICE_LOW,0)-FMax*10*Point+90*Point,4), Time[0], NormalizeDouble(iMA(symbol,30,414,0,MODE_EMA, PRICE_LOW,0)-FMax*10*Point+90*Point,4));
               ObjectSet("Pol2", OBJPROP_COLOR, clrBlack);
               ObjectSet("Pol2", OBJPROP_STYLE, 2 );
               ObjectSet("Pol2", OBJPROP_WIDTH, 3 );
               ObjectSet("Pol2",OBJPROP_RAY_RIGHT,true);
               ObjectSet("Pol2", OBJPROP_BACK, 1 );               
        
ObjectCreate( "Pol3", OBJ_TREND, 0, Time[1], NormalizeDouble(iMA(symbol,30,414,0,MODE_EMA, PRICE_HIGH,0)+FMax*10*Point-90*Point,4), Time[0], NormalizeDouble(iMA(symbol,30,414,0,MODE_EMA, PRICE_HIGH,0)+FMax*10*Point-90*Point,4));
               ObjectSet("Pol3", OBJPROP_COLOR, clrBlack);
               ObjectSet("Pol3", OBJPROP_STYLE, 2 );
               ObjectSet("Pol3", OBJPROP_WIDTH, 3 );
               ObjectSet("Pol3",OBJPROP_RAY_RIGHT,true);
               ObjectSet("Pol3", OBJPROP_BACK, 1 );        

ObjectCreate( "Pol4", OBJ_TREND, 0, Time[1], NormalizeDouble(iMA(symbol,30,414,0,MODE_EMA, PRICE_HIGH,0)+FMax*10*Point+90*Point,4), Time[0], NormalizeDouble(iMA(symbol,30,414,0,MODE_EMA, PRICE_HIGH,0)+FMax*10*Point+90*Point,4));
               ObjectSet("Pol4", OBJPROP_COLOR, clrBlack);
               ObjectSet("Pol4", OBJPROP_STYLE, 2 );
               ObjectSet("Pol4", OBJPROP_WIDTH, 3 );
               ObjectSet("Pol4",OBJPROP_RAY_RIGHT,true);
               ObjectSet("Pol4", OBJPROP_BACK, 1 );     


      ObjectCreate("Pol00", OBJ_TEXT, 0, Time[0], NormalizeDouble(iMA(symbol,30,414,0,MODE_EMA, PRICE_LOW,0)-FMax*10*Point-90*Point-.0000,4)); 
               ObjectSetText("Pol00", "      + "+addon, 20, "Arial Black", clrBlack);
               
               
                ObjectCreate("Pol01", OBJ_TEXT, 0, Time[0], NormalizeDouble(iMA(symbol,30,414,0,MODE_EMA, PRICE_LOW,0)-FMax*10*Point+.0004,4)); 
               ObjectSetText("Pol01", "      0 0", 20, "Arial Black", clrBlack);
               

 ObjectCreate("Pol02", OBJ_TEXT, 0, Time[0], NormalizeDouble(iMA(symbol,30,414,0,MODE_EMA, PRICE_LOW,0)-FMax*10*Point+90*Point+.0008,4)); 
               ObjectSetText("Pol02", "      0 "+addon, 20, "Arial Black", clrBlack);


ObjectCreate("Pol03", OBJ_TEXT, 0, Time[0], NormalizeDouble(iMA(symbol,30,414,0,MODE_EMA, PRICE_HIGH,0)+FMax*10*Point-90*Point-.0000,4)); 
               ObjectSetText("Pol03", "      0 "+addon, 20, "Arial Black", clrBlack);
               
               
                ObjectCreate("Pol04", OBJ_TEXT, 0, Time[0], NormalizeDouble(iMA(symbol,30,414,0,MODE_EMA, PRICE_HIGH,0)+FMax*10*Point+.0004,4)); 
               ObjectSetText("Pol04", "      0 0", 20, "Arial Black", clrBlack);
               

 ObjectCreate("Pol05", OBJ_TEXT, 0, Time[0], NormalizeDouble(iMA(symbol,30,414,0,MODE_EMA, PRICE_HIGH,0)+FMax*10*Point+90*Point+.0008,4)); 
               ObjectSetText("Pol05", "      - "+addon, 20, "Arial Black", clrBlack);



}
   
//----
   return(0);
  }
//+------------------------------------------------------------------+

bool LowComparison(int currentpos, int length)
{
  bool condition = False; 
   for(int k=currentpos; k<currentpos+length; k++)
      if (iLow(Symbol(),0,k)<iMA(Symbol(),30, 135,0,MODE_EMA, PRICE_LOW,k)-.0004) {condition=True; break;}
   return (condition);
}

bool HighComparison(int currentpos, int length)
{
  bool condition = False; 
   for(int k=currentpos; k<currentpos+length; k++)
      if (iHigh(Symbol(),0,k)>iMA(Symbol(),30,135,0,MODE_EMA, PRICE_HIGH,k)+.0004) {condition=True; break;}
   return (condition);
}


double ChoppinessIndex(int period, int bar)
  {
    double Low0 = 0, High0 = 0, Close1 = 0;
    double TrueRangeLow = 0, TrueRangeHigh = 0, TrueRangeSum = 0, Input = 0;
    double PeriodTrueRangeLow = 999999999, PeriodTrueRangeHigh = 0, PeriodTrueRange = 0;

    for(int k=bar; k<bar+period; k++)
    {
      Low0   = iLow(NULL,0,k);
      High0  = iHigh(NULL,0,k);
      Close1 = iClose(NULL,0,k+1);

      if (Low0<Close1)  TrueRangeLow  = Low0;  else TrueRangeLow  = Close1;
      if (High0>Close1) TrueRangeHigh = High0; else TrueRangeHigh = Close1;
      
      if (TrueRangeLow <PeriodTrueRangeLow)  PeriodTrueRangeLow  = TrueRangeLow;  // find true low of period
      if (TrueRangeHigh>PeriodTrueRangeHigh) PeriodTrueRangeHigh = TrueRangeHigh; // find true high of period

      TrueRangeSum += TrueRangeHigh;
      TrueRangeSum -= TrueRangeLow;
    }

    PeriodTrueRange = PeriodTrueRangeHigh - PeriodTrueRangeLow;
    if (PeriodTrueRange==0) PeriodTrueRange = MathPow(10, -12); // avoid possibility of division by zero
    Input = TrueRangeSum / PeriodTrueRange;
    return ((logN(Input, 10, MathPow(10, -12)) / logN(period, 10, MathPow(10, -12))) * 100);
  }
  

double logN(double x, double base, double epsilon)
  {
    double integer = 0.0;
    if ((x < 1) || (base < 1)) return(0);

    while (x < 1)
    {
      integer -= 1;
      x *= base;
    }
  
    while (x >= base)
    {
      integer += 1;
      x /= base;
    }
  
    double partial = 0.5;
    x *= x;
    double decimal = 0.0;

    while (partial > epsilon)
    {
      if (x >= base)
      {
        decimal += partial;
        x = x / base;
      }
      partial *= 0.5;
      x *= x;
    }
    
    return (integer + decimal);
  } 


double StdDev(int shift, int samples)
  {
  double x0=0, x1=0, x2=0;
  for (int m=0; m<samples; m++)
    {
    x0 = ExtMapBuffer[m+shift];
    x1 += x0;
    x2 += MathPow(x0,2);
    }
  return(MathSqrt((x2-(x1*x1/samples))/(samples-1))); // minimum samples is 2, enforced in the init section
}
//+------------------------------------------------------------------+

   void deletetxt1(string text){
   for(int iObj=ObjectsTotal()-1; iObj >= 0; iObj--){
      string   on = ObjectName(iObj);
      if(StringFind(on, text) == 0)  ObjectDelete(on);
}  }

It started out as a mean reversion, by the far end of the bear zone 1…
…and that was a wave 1 UP…

Getting In The Groove

Getting in the groove – in my opinion – requires a lot.

You would need 2 brokers 2 hours of server time apart, to be able to have different grouping on 4h candles. A signal may show up with one broker, and not with the other.

You would need to start plotting the things that are most important, and these things can be found on the Daily, the 4H and the 30 minute charts.

Energy bands can certainly help you with gauging the possibilities.

4H/ 2H dojis’ fake outs can give you targets for example for retracements (see Cornsilk lines and the two boxes with the two fake-out numbers).

Stochastics with the right settings can help you find low risk new entries, i.e. sell the fresh 4h overbought in the daily embedded oversold (magenta stripes between the oscillator lines).

Monitoring for measuring legs and divergent legs provides you with an accurate picture of current reads. You should not be making any changes while a measuring leg is printing, exit & reverse upon a divergent leg, and only when the leg was printed entirely to prevent from false triggers.

Naming certain conditions such as I named some RSI2 sequences DDI and SD can help you remembering that a thrust is still due (with the only exception is upon having reached the end of the line – see the energy moat).

A sign of strength followed by a thrust is a peak, and you do not want to be buying until you saw 2 measuring legs printed in the opposite direction.

Invent a box with “bona fide reversal” label and put in 4h divergences with not both legs being in the overbought/oversold, and 4x 30-minute RSI2 divergences in it for starters.

Ring around the doji

//2H DOJI Lines by Macdulio
#property copyright "Copyright © 2019, Macdulio" 
#property link      "https://forexfore.blog" 
#property description "V1.0"
#property description "2H Doji Lines - "
#property description "plotting # maxlines (max 15) "
#property description "from the last 2-H dojis"
#property description "plus 2 boxes and two numbers"
#property description "around the very last two."
#include <stdlib.mqh>
#property indicator_chart_window
#property indicator_buffers 30
#property indicator_color1 Cornsilk
extern int maxlines = 8; 
extern int displaylength = 36;     
extern int       MinLengthOfUpTail=1; //candle with upper tail equal or more than this will show up
extern int       MinLengthOfLoTail=1; //candle with lower tail equal or more than this will show up
extern double    MaxLengthOfBody=30; //candle with body less or equal with this will show up
     
double pt=0.00001;
double lines[];
double mid[];

double line1[];
double line2[];
double line3[];
double line4[];
double line5[];
double line6[];
double line7[];
double line8[];
double line9[];
double line10[];
double line11[];
double line12[];
double line13[];
double line14[];
double line15[];

double vbru[];

string TimeFrame;
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexBuffer(0,line1);
   SetIndexBuffer(1,line2);
   SetIndexBuffer(2,line3);
   SetIndexBuffer(3,line4);
   SetIndexBuffer(4,line5);  
   SetIndexBuffer(5,line6);
   SetIndexBuffer(6,line7);
   SetIndexBuffer(7,line8);
   SetIndexBuffer(8,line9);
   SetIndexBuffer(9,line10);
   SetIndexBuffer(10,line11);  
   SetIndexBuffer(11,line12);   
   SetIndexBuffer(12,line13);
   SetIndexBuffer(13,line14);
   SetIndexBuffer(14,line15);  
                
   SetIndexStyle(0,DRAW_LINE,EMPTY,5,indicator_color1);
   SetIndexStyle(1,DRAW_LINE,EMPTY,5,indicator_color1);
   SetIndexStyle(2,DRAW_LINE,EMPTY,5,indicator_color1);     
   SetIndexStyle(3,DRAW_LINE,EMPTY,5,indicator_color1);
   SetIndexStyle(4,DRAW_LINE,EMPTY,5,indicator_color1);
   SetIndexStyle(5,DRAW_LINE,EMPTY,5,indicator_color1);  
   SetIndexStyle(6,DRAW_LINE,EMPTY,5,indicator_color1);
   SetIndexStyle(7,DRAW_LINE,EMPTY,5,indicator_color1);
   SetIndexStyle(8,DRAW_LINE,EMPTY,5,indicator_color1);     
   SetIndexStyle(9,DRAW_LINE,EMPTY,5,indicator_color1);
   SetIndexStyle(10,DRAW_LINE,EMPTY,5,indicator_color1);
   SetIndexStyle(11,DRAW_LINE,EMPTY,5,indicator_color1);
   SetIndexStyle(12,DRAW_LINE,EMPTY,5,indicator_color1);     
   SetIndexStyle(13,DRAW_LINE,EMPTY,5,indicator_color1);
   SetIndexStyle(14,DRAW_LINE,EMPTY,5,indicator_color1);

   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   string symbol = Symbol();
   int      i,pos,c_b=IndicatorCounted();;
  ArrayResize(lines, maxlines);
 
  ArrayInitialize(lines, 0);

  ArrayResize(line1, 100);
  ArrayInitialize(line1, 0);  
  ArrayResize(line2, 100);
  ArrayInitialize(line2, 0);  
  ArrayResize(line3, 100);
  ArrayInitialize(line3, 0);    
  ArrayResize(line4, 100);
  ArrayInitialize(line4, 0);  
  ArrayResize(line5, 100);
  ArrayInitialize(line5, 0);  
  ArrayResize(line6, 100);
  ArrayInitialize(line6, 0);  
  ArrayResize(line7, 100);
  ArrayInitialize(line7, 0);    
  ArrayResize(line8, 100);
  ArrayInitialize(line8, 0);    
  ArrayResize(line9, 100);
  ArrayInitialize(line9, 0);    
  ArrayResize(line10, 100);
  ArrayInitialize(line10, 0);  
  ArrayResize(line11, 100);
  ArrayInitialize(line11, 0);    
  ArrayResize(line12, 100);
  ArrayInitialize(line12, 0);    
  ArrayResize(line13, 100);
  ArrayInitialize(line13, 0);      
  ArrayResize(line14, 100);
  ArrayInitialize(line14, 0);  
  ArrayResize(line15, 100);
  ArrayInitialize(line15, 0);  

   
    ArrayResize(vbru, Bars);
   ArrayInitialize(vbru, 0); 
 
    ArrayResize(mid, Bars);
   ArrayInitialize(mid, 0);     
 


   pos=0;
  
 for (i=500; i>=0; i--) 
    {
    
    if (i>0 && i/2==MathRound(i/2)){
    
       if (iOpen(NULL,60,i)>iClose(NULL,60,i) &&  iHigh(NULL,60,i+1)-iClose(NULL,60,i+1)>=MinLengthOfUpTail*pt && iHigh(NULL,60,i)-iClose(NULL,60,i)>=MinLengthOfUpTail*pt && iClose(NULL,60,i+1)-iLow(NULL,60,i+1)>=MinLengthOfLoTail*pt && iClose(NULL,60,i)-iLow(NULL,60,i)>=MinLengthOfLoTail*pt && MathAbs(iOpen(NULL,60,iLowest(NULL,60,MODE_OPEN,2,i))-iClose(NULL,60,iHighest(NULL,60,MODE_CLOSE,2,i)))<=MaxLengthOfBody*pt  && vbru[i+1]==0) vbru[i]=MathAbs(iClose(NULL,60,i)+iOpen(NULL,60,i))/2;
       
        if (iOpen(NULL,60,i)<iClose(NULL,60,i) &&  iHigh(NULL,60,i+1)-iClose(NULL,60,i+1)>=MinLengthOfUpTail*pt && iHigh(NULL,60,i)-iClose(NULL,60,i)>=MinLengthOfUpTail*pt && iClose(NULL,60,i+1)-iLow(NULL,60,i+1)>=MinLengthOfLoTail*pt && iClose(NULL,60,i)-iLow(NULL,60,i)>=MinLengthOfLoTail*pt && MathAbs(iOpen(NULL,60,iLowest(NULL,60,MODE_CLOSE,2,i))-iClose(NULL,60,iHighest(NULL,60,MODE_OPEN,2,i)))<=MaxLengthOfBody*pt  && vbru[i+1]==0) vbru[i]=MathAbs(iClose(NULL,60,i)+iOpen(NULL,60,i))/2;
       
   }
     }
         


  for (i=1; i<=250; i++)
   {
        if (vbru[i]>0){  mid[pos]= vbru[i]; pos=pos+1;}
   }
    
 
deletetxt1("Happy");

i=0;
   while(i<maxlines && pos>0)        
            {
               if (i==pos) break;
               if (mid[i]!=EMPTY_VALUE) lines[i]=mid[i];
               i++;
            }

   for (i=0; i<=displaylength-1; i++) {
      if (lines[0]>0) line1[i]=lines[0];
      if (lines[1]>0) line2[i]=lines[1];
      if (lines[2]>0) line3[i]=lines[2];
      if (lines[3]>0) line4[i]=lines[3];
      if (lines[4]>0) line5[i]=lines[4];
      if (lines[5]>0) line6[i]=lines[5];
      if (lines[6]>0) line7[i]=lines[6];
      if (lines[7]>0) line8[i]=lines[7];                
      if (lines[8]>0) line9[i]=lines[8];
      if (lines[9]>0) line10[i]=lines[9]; 
      if (lines[10]>0) line11[i]=lines[10];
      if (lines[11]>0) line12[i]=lines[11];
      if (lines[12]>0) line13[i]=lines[12];
      if (lines[13]>0) line14[i]=lines[13];
      if (lines[14]>0) line15[i]=lines[14];
            
      
     if (i==6) {ObjectCreate("Happygail"+i, OBJ_RECTANGLE, 0,  Time[6], line1[i]+160*Point, Time[2], line1[i]-160*Point);
  ObjectSetInteger(0,"Happygail"+i,OBJPROP_COLOR,clrPurple);
  ObjectSet("Happygail"+i,OBJPROP_BACK,0);
  ObjectSet("Happygail"+i,OBJPROP_WIDTH,5);
  
  ObjectCreate("Happybail"+i, OBJ_RECTANGLE, 0,  Time[5], line2[i]+160*Point, Time[1], line2[i]-160*Point);
  ObjectSetInteger(0,"Happybail"+i,OBJPROP_COLOR,clrRed);
  ObjectSet("Happybail"+i,OBJPROP_BACK,0);
  ObjectSet("Happybail"+i,OBJPROP_WIDTH,5);
  
   
  if (line2[i]>line1[i]){ 
         ObjectCreate("Happydays"+iHigh(symbol,240,i), OBJ_TEXT, 0, Time[0], line2[i]+99*Point); 
         ObjectSetText("Happydays"+iHigh(symbol,240,i), DoubleToStr(NormalizeDouble(line2[i]+80*Point,4),4), 16, "Arial Black", Black);
         
         ObjectCreate("Happydays"+iLow(symbol,240,i), OBJ_TEXT, 0, Time[0], line1[i]-78*Point); 
         ObjectSetText("Happydays"+iLow(symbol,240,i), DoubleToStr(NormalizeDouble(line1[i]-80*Point,4),4), 16, "Arial Black", Black);
         }
  else { 
         ObjectCreate("Happydays"+iHigh(symbol,240,i), OBJ_TEXT, 0, Time[0], line1[i]+99*Point); 
         ObjectSetText("Happydays"+iHigh(symbol,240,i), DoubleToStr(NormalizeDouble(line1[i]+80*Point,4),4), 16, "Arial Black", Black);
         
         ObjectCreate("Happydays"+iLow(symbol,240,i), OBJ_TEXT, 0, Time[0], line2[i]-78*Point); 
         ObjectSetText("Happydays"+iLow(symbol,240,i), DoubleToStr(NormalizeDouble(line2[i]-80*Point,4),4), 16, "Arial Black", Black);
         }       
   
  }
   
}

  return(0);
}

   void deletetxt1(string text){
   for(int iObj=ObjectsTotal()-1; iObj >= 0; iObj--){
      string   on = ObjectName(iObj);
      if(StringFind(on, text) == 0)  ObjectDelete(on);
}  }

The Energy Bands

The concept of the energy bands is to attribute predicting power to the current consolidation level by showing how far the price could get if it was to keep on moving in a direction – before hitting an “exhaustion”.

Since somebody had to think of this, I did.

An exhaustion would prompt a consolidation: price would have to start moving sideways, backwards or something in between.

For the last time I would mention that price cannot simply always do what it wants.

Imagine the value of these bands when you are playing options strategies, such as an iron condor. You must know where to put on your spread if you don’t want it to become a liability.

 cval[i] = (.0200/55)*adj*(ChoppinessIndex(ChoppinessPeriod,i+3)+ChoppinessIndex(ChoppinessPeriod,i+4)+ChoppinessIndex(ChoppinessPeriod,i+5))/3;

The consolidation value is derived from the mean of the 3rd, 4th and 5th, 14-sample consolidation values. The adjustment is 70%.

This value is added or subtracted from the average of the 8th, 7th and 5th high/low with an individual multiplier.

 c2[i] = (iLow(NULL,0,i+8)+iLow(NULL,0,i+7)+iLow(NULL,0,i+5))/3-cval[i]*1.28
+(VOLA-50)/10000;
double VOLA = (sqrt(252) * (log(iClose(NULL,0,0) / iClose(NULL,0,1)/5*1000)))+10;

The bands are asymmetric. How did I end up with 1.27 and 1.62 multiplier on the downside and 0.9 and 1.15 on the upside and with a 4th value thrown in for good measure, is a mystery.

What matters is that these bands are dynamic, and can land you the right idea of distance possibilities.

For instance, when the high was made, did you or did you not have the maximum likely travel distance at your hand, at that very moment?