Does anyone have past 5 days high low afl......

#1
Does anyone have the afl to plot the past 5 days HIGH and LOW range so that it can be used to trade as breakout levels........If someone has it plz post it .......Thanks
 

icytrader

Active Member
#2
Do you mean you want to plot the high and low values for the last 5 days or the high - low range for the past 5 days? Let me know and I'll help you out.
 
#3
Do you mean you want to plot the high and low values for the last 5 days or the high - low range for the past 5 days? Let me know and I'll help you out.
Thanks for comming out for help.......i need previous 5 days high/low range plotted on the chart sothat i would be easy to take entry when price crosses these high/low lines on the chart.......thanks in advance
 

headstrong007

----- Full-Time ----- Day-Trader
#4
Below is "5 day Range Breakout" code for MT4...very useful.. what u wanted... today itself was the great example of it. :D

If u want it for amibroker any ami programmer can convert it easily for u..

Code:
//+------------------------------------------------------------------+
//|                                          5day Range Breakout.mq4 |                                        
//+------------------------------------------------------------------+

//---- input parameters
extern int       DAYS=5;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   double daily_high[20];
   double daily_low[20];
   double yesterday_close;
   double phigh,plow;
   int i=1;
//---- TODO: add your code here
   ArrayResize(daily_high,DAYS);
   ArrayResize(daily_low,DAYS);
   ArrayInitialize(daily_high,0);
   ArrayInitialize(daily_low,0);
   ArrayCopySeries(daily_low, MODE_LOW, Symbol(), PERIOD_D1);
   ArrayCopySeries(daily_high, MODE_HIGH, Symbol(), PERIOD_D1);
/* initialise */
   plow=daily_low[1];
   phigh=daily_high[1];
//----
   for(i=1;i<DAYS;i++)
     {
      if(plow>daily_low[i])
        {
         plow =daily_low[i];
        }
     }
   for(i=1;i<DAYS;i++)
     {
      if(phigh<daily_high[i])
        {
         phigh =daily_high[i];
        }
     }
   Comment("\n5dayH ",phigh,"\n5dayL ",plow);
   //----
   ObjectDelete("5dayHigh");
   ObjectDelete("5dayLow");
   ObjectCreate("5dayHigh", OBJ_HLINE,0, CurTime(),phigh);
   ObjectSet("5dayHigh",OBJPROP_COLOR,SpringGreen);
   ObjectSet("5dayHigh",OBJPROP_STYLE,STYLE_SOLID);
   ObjectCreate("5dayLow", OBJ_HLINE,0, CurTime(),plow);
   ObjectSet("5dayLow",OBJPROP_COLOR,Red);
   ObjectSet("5dayLow",OBJPROP_STYLE,STYLE_SOLID);
   //----
   ObjectsRedraw();
   return(0);
  }
//+------------------------------------------------------------------
 

monkeybusiness

Well-Known Member
#6
Does anyone have the afl to plot the past 5 days HIGH and LOW range so that it can be used to trade as breakout levels........If someone has it plz post it .......Thanks
Code:
_SECTION_BEGIN("N_Day_HiLo");

// Set chart display parameters
// Chart background is Black,
// Date Axis displayed,
// Long titles wrapped to next line

SetChartOptions(0, chartShowDates | chartWrapTitle);
SetChartBkColor(colorBlack);

// Locate Highest HIGH and Lowest LOW in last N days

N = Param("Days to go back(Excl today)", 10, 2, 200, 1);
PriceStyle = ParamStyle("Chart Type", styleCandle, maskPrice);
LineStyle = ParamStyle("Line Style");

NDayHi = H[BarCount - 1 - N];
NDayLo = L[BarCount - 1 - N];
XH = XL = BarCount - 1 - N;

for(i = BarCount - 1 - N; i < BarCount - 1; i++)
{
if(H[i] > NDayHi)
{
NDayHi = H[i];
XH = i;
}
if(L[i] < NDayLo)
{
NDayLo = L[i];
XL = i;
}
}


// Define the Lines to be drawn

HLine = LineArray(BarCount - 1 - N, NDayHi, BarCount - 2, NDayHi);
LLine = LineArray(BarCount - 1 - N, NDayLo, BarCount - 2, NDayLo);

// Plot chart

_N(Title = StrFormat("{{NAME}} ({{INTERVAL}}) {{DATE}} {{OHLCX}} Vol=%1.0f\n{{VALUES}}", V));

Plot(C, "", colorGrey50, PriceStyle);
Plot(Hline, WriteVal(N, 1.0) + " Day Hi", colorWhite, LineStyle);
Plot(LLine, WriteVal(N, 1.0) + " Day Lo", colorWhite, LineStyle);

_SECTION_END();
 
#7
Hi Guys,

For the same Previous day High-Low... I have written attached codes in AmiBroker but it shows Syntax Error. What am I doing wrong. Its my first code.
 

Attachments