Hello, please use the function for the code. I have the impression that your code is not complete. Does it use the base flag found in the code section? Or have you tried to change it?
//+------------------------------------------------------------------+ //| GG-TimeBox.mq4 | //| Copyright ? 2009, GGekko | //| http://www.fx-ggekko.com | //+------------------------------------------------------------------+ #property copyright "Copyright ? 2009, GGekko modified by kaliloup" #property link "http://www.fx-ggekko.com" #property version "1.00" #property strict #property indicator_chart_window #property indicator_buffers 4 #property indicator_color1 DodgerBlue #property indicator_color2 Red #property indicator_width1 2 #property indicator_width2 2 #property indicator_style1 STYLE_DOT #property indicator_style2 STYLE_DOT extern string __Copyright__ = "www.fx-ggekko.com"; extern string HelpForCustomTF = "D1:1440 - H4:240 - H1:60 - ... - M5:5"; extern int CustomTF = PERIOD_D1; extern int UnitToProcess = 20; extern int DojiDiff = 2; extern color UpColor = C'218,250,218'; extern color DownColor = C'250,211,211'; extern color DojiColor = C'255,245,195'; double ExtMapBuffer1[]; double ExtMapBuffer2[]; double ExtMapBuffer3[]; double ExtMapBuffer4[]; datetime starttime[],endtime[]; double lowprice[],highprice[]; int bars_in_one_rectangle; color BarsColor[]; int ChartPeriod; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- // Drawing settings SetIndexStyle(0,DRAW_ARROW); SetIndexArrow(0, 233); SetIndexStyle(1,DRAW_ARROW); SetIndexArrow(1, 234); IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)); // Buffers SetIndexBuffer(0,ExtMapBuffer1); SetIndexBuffer(1,ExtMapBuffer2); ChartPeriod=Period(); //D1 if(CustomTF==PERIOD_D1) { switch(ChartPeriod) { case PERIOD_M1 : bars_in_one_rectangle=1440-1; break; case PERIOD_M5 : bars_in_one_rectangle=288-1; break; case PERIOD_M15: bars_in_one_rectangle=96-1; break; case PERIOD_M30: bars_in_one_rectangle=48-1; break; case PERIOD_H1 : bars_in_one_rectangle=24-1; break; case PERIOD_H4 : bars_in_one_rectangle=6-1; break; default : ChartPeriod=240; } } //H4 else if(CustomTF==PERIOD_H4) { switch(ChartPeriod) { case PERIOD_M1 : bars_in_one_rectangle=240-1; break; case PERIOD_M5 : bars_in_one_rectangle=48-1; break; case PERIOD_M15: bars_in_one_rectangle=16-1; break; case PERIOD_M30: bars_in_one_rectangle=8-1; break; case PERIOD_H1 : bars_in_one_rectangle=4-1; break; default : ChartPeriod=60; } } //H1 else if(CustomTF==PERIOD_H1) { switch(ChartPeriod) { case PERIOD_M1 : bars_in_one_rectangle=60-1; break; case PERIOD_M5 : bars_in_one_rectangle=12-1; break; case PERIOD_M15: bars_in_one_rectangle=4-1; break; case PERIOD_M30: bars_in_one_rectangle=2-1; break; default : ChartPeriod=30; } } //M30 else if(CustomTF==PERIOD_M30) { switch(ChartPeriod) { case PERIOD_M1 : bars_in_one_rectangle=30-1; break; case PERIOD_M5 : bars_in_one_rectangle=6-1; break; case PERIOD_M15: bars_in_one_rectangle=2-1; break; default : ChartPeriod=15; } } //M15 else if(CustomTF==PERIOD_M15) { switch(ChartPeriod) { case PERIOD_M1 : bars_in_one_rectangle=15-1; break; case PERIOD_M5 : bars_in_one_rectangle=3-1; break; default : ChartPeriod=5; } } //M5 else if (CustomTF==PERIOD_M5) { switch(ChartPeriod) { case PERIOD_M1 : bars_in_one_rectangle=5-1; break; default : ChartPeriod=1; } } ArrayResize(starttime, UnitToProcess); ArrayResize(endtime, UnitToProcess); ArrayResize(lowprice, UnitToProcess); ArrayResize(highprice, UnitToProcess); ArrayResize(BarsColor, UnitToProcess); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- for(int w=0; w<UnitToProcess; w++) { ObjectDelete("CustomTF"+w); } Comment(""); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int w; for(w=0; w<UnitToProcess; w++) { ObjectDelete("CustomTF"+w); } for(w=0; w<UnitToProcess; w++) { starttime[w]=iTime(NULL,CustomTF,w); endtime[w]=starttime[w]+bars_in_one_rectangle*Period()*60; lowprice[w]=iLow(NULL,CustomTF,w); highprice[w]=iHigh(NULL,CustomTF,w); if(iOpen(NULL,CustomTF,w)<iClose(NULL,CustomTF,w)-(DojiDiff*Point)) BarsColor[w]=UpColor; else if(iOpen(NULL,CustomTF,w)>iClose(NULL,CustomTF,w)+(DojiDiff*Point)) BarsColor[w]=DownColor; else BarsColor[w]=DojiColor; } if(Bid<=lowprice[0]){ExtMapBuffer1[0]=Bid-(Ask-Bid);} if(Bid>=highprice[0]){ExtMapBuffer2[0]=Bid+(Ask-Bid);} for(w=0; w<UnitToProcess; w++) { ObjectCreate("CustomTF"+w,OBJ_RECTANGLE,0,starttime[w],lowprice[w],endtime[w],highprice[w]); ObjectSet("CustomTF"+w,OBJPROP_COLOR,BarsColor[w]); } //---- //---- return(0); } //+------------------------------------------------------------------+
I changed the base code, I haven't put sound alert yet. Let me know if this is the help you were looking for.
Hello there
thank you for the update, it works,well!
hello sir can i get your email ?
Merci de poster en français sur ce forum.
Vous avez raison, pardon c'est de ma faute.
Vous manquez des opportunités de trading :
- Applications de trading gratuites
- Plus de 8 000 signaux à copier
- Actualités économiques pour explorer les marchés financiers
Inscription
Se connecter
Vous acceptez la politique du site Web et les conditions d'utilisation
Si vous n'avez pas de compte, veuillez vous inscrire
Hello there!!
can anbody help us please? i needs to edit this code indicator by adding signal alert + arrow signal
everytime the upper wick of candlestick touch the upside of the box ((it shows sell signal)), and when the lower wick of candlestick touch the downside of the box ((it shows buy signal))
//| GG-TimeBox.mq4 |
//| Copyright © 2009, GGekko |
//| http://www.fx-ggekko.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, GGekko"
#property link "http://www.fx-ggekko.com"
#property indicator_chart_window
extern string Copyright = "www.fx-ggekko.com";
extern string HelpForCustomTF = "D1:1440 - H4:240 - H1:60 - ... - M5:5";
extern int CustomTF = PERIOD_D1;
extern int UnitToProcess = 20;
extern int DojiDiff = 2;
extern color UpColor = C'218,250,218';
extern color DownColor = C'250,211,211';
extern color DojiColor = C'255,245,195';
datetime starttime[],endtime[];
double lowprice[],highprice[];
int bars_in_one_rectangle;
color BarsColor[];
int ChartPeriod;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
ChartPeriod=Period();
//D1
if(CustomTF==PERIOD_D1)
{
switch(ChartPeriod)
{
case PERIOD_M1 : bars_in_one_rectangle=1440-1; break;
case PERIOD_M5 : bars_in_one_rectangle=288-1; break;
case PERIOD_M15: bars_in_one_rectangle=96-1; break;
case PERIOD_M30: bars_in_one_rectangle=48-1; break;
case PERIOD_H1 : bars_in_one_rectangle=24-1; break;
case PERIOD_H4 : bars_in_one_rectangle=6-1; break;
default : ChartPeriod=240;
}
}
//H4
else if(CustomTF==PERIOD_H4)
{
switch(ChartPeriod)
{
case PERIOD_M1 : bars_in_one_rectangle=240-1; break;
case PERIOD_M5 : bars_in_one_rectangle=48-1; break;
case PERIOD_M15: bars_in_one_rectangle=16-1; break;
case PERIOD_M30: bars_in_one_rectangle=8-1; break;
case PERIOD_H1 : bars_in_one_rectangle=4-1; break;
default : ChartPeriod=60;
}
}
//H1
else if(CustomTF==PERIOD_H1)
{
switch(ChartPeriod)
{
case PERIOD_M1 : bars_in_one_rectangle=60-1; break;
case PERIOD_M5 : bars_in_one_rectangle=12-1; break;
case PERIOD_M15: bars_in_one_rectangle=4-1; break;
case PERIOD_M30: bars_in_one_rectangle=2-1; break;
default : ChartPeriod=30;
}
}
//M30
else if(CustomTF==PERIOD_M30)
{
switch(ChartPeriod)
{
case PERIOD_M1 : bars_in_one_rectangle=30-1; break;
case PERIOD_M5 : bars_in_one_rectangle=6-1; break;
case PERIOD_M15: bars_in_one_rectangle=2-1; break;
default : ChartPeriod=15;
}
}
//M15
else if(CustomTF==PERIOD_M15)
{
switch(ChartPeriod)
{
case PERIOD_M1 : bars_in_one_rectangle=15-1; break;
case PERIOD_M5 : bars_in_one_rectangle=3-1; break;
default : ChartPeriod=5;
}
}
//M5
else if (CustomTF==PERIOD_M5)
{
switch(ChartPeriod)
{
case PERIOD_M1 : bars_in_one_rectangle=5-1; break;
default : ChartPeriod=1;
}
}
ArrayResize(starttime, UnitToProcess);
ArrayResize(endtime, UnitToProcess);
ArrayResize(lowprice, UnitToProcess);
ArrayResize(highprice, UnitToProcess);
ArrayResize(BarsColor, UnitToProcess);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
for(int w=0; w<UnitToProcess; w++)
{
ObjectDelete("CustomTF"+w);
}
Comment("");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
for(int w=0; w<UnitToProcess; w++)
{
ObjectDelete("CustomTF"+w);
}
for(w=0; w<UnitToProcess; w++)
{
starttime[w]=iTime(NULL,CustomTF,w*bars_in_one_rectangle);
endtime[w]=iTime(NULL,CustomTF,w*bars_in_one_rectangle+bars_in_one_rectangle-1);
lowprice[w]=iLowest(NULL,CustomTF,MODE_LOW,bars_in_one_rectangle,w*bars_in_one_rectangle,bars_in_one_rectangle);
highprice[w]=iHighest(NULL,CustomTF,MODE_HIGH,bars_in_one_rectangle,w*bars_in_one_rectangle,bars_in_one_rectangle);
BarsColor[w]=DojiColor;
if(MathAbs(highprice[w]-lowprice[w]) < (DojiDiff*Point))
{
BarsColor[w]=DojiColor;
}
else if (highprice[w] < highprice[w+1])
{
BarsColor[w]=DownColor;
}
else if (lowprice[w] > lowprice[w+1])
{
BarsColor[w]=UpColor;
}
else
{
BarsColor[w]=DojiColor;
}
double BoxUp=highprice[w]+(highprice[w]-lowprice[w])/2;
double BoxDn=lowprice[w]-(highprice[w]-lowprice[w])/2;
double BoxHeight=MathAbs(highprice[w]-lowprice[w]);
ObjectCreate("CustomTF"+w,OBJ_RECTANGLE,0,starttime[w],BoxUp,endtime[w],BoxDn);
ObjectSet("CustomTF"+w,OBJPROP_COLOR,BarsColor[w]);
ObjectSet("CustomTF"+w,OBJPROP_BACK,true);
ObjectSet("CustomTF"+w,OBJPROP_STYLE,STYLE_SOLID);
ObjectSet("CustomTF"+w,OBJPROP_WIDTH,1);
ObjectSet("CustomTF"+w,OBJPROP_FILL,true);
ObjectSet("CustomTF"+w,OBJPROP_TIME1,starttime[w]);
ObjectSet("CustomTF"+w,OBJPROP_PRICE1,BoxUp);
/// CODE IS GOOD AT__THIS POINT ///
// Set the object properties
ObjectSet("MyRectangle", OBJPROP_TIME1, Time[i]);
ObjectSet("MyRectangle", OBJPROP_PRICE1, Low[i]);
ObjectSet("MyRectangle", OBJPROP_TIME2, Time[i+1]);
ObjectSet("MyRectangle", OBJPROP_PRICE2, High[i+1]);
// Set the object style
ObjectSet("MyRectangle", OBJPROP_COLOR, clrRed);
ObjectSet("MyRectangle", OBJPROP_STYLE, STYLE_DASH);
ObjectSet("MyRectangle", OBJPROP_BACK, true);
// Set the object description
ObjectSetText("MyRectangle", "My Rectangle", 10, "Arial", clrWhite);
//--- check if the current bar is a bullish outside bar
if(Close[1] < Open[1] && Close[0] > High[1] && Open[0] < Low[1] && Close[0] > Open[0])
{
//--- draw a green arrow above the high of the current bar
double arrowPrice = High[0] + (ATR(14) * 0.5);
ObjectCreate("BullishArrow", OBJ_ARROW, 0, Time[0], arrowPrice);
ObjectSet("BullishArrow", OBJPROP_ARROWCODE, 159);
ObjectSet("BullishArrow", OBJPROP_COLOR, Green);
ObjectSet("BullishArrow", OBJPROP_WIDTH, 3);
ObjectSet("BullishArrow", OBJPROP_STYLE, STYLE_SOLID);
ObjectSet("BullishArrow", OBJPROP_BACK, false);
ObjectSet("BullishArrow", OBJPROP_SELECTABLE, false);
ObjectSet("BullishArrow", OBJPROP_HIDDEN, false);
//--- print a message in the Experts tab
Print("Bullish Outside Bar detected at ", TimeToStr(Time[0], TIME_DATE|TIME_MINUTES));
}
//--- check if the current bar is a bearish outside bar
if(Close[1] > Open[1] && Close[0] < Low[1] && Open[0] > High[1] && Close[0] < Open[1])
{
//--- draw a red arrow below the low of the current bar
double arrowPrice = Low[0] - (ATR(14) * 0.5);
ObjectCreate("BearishArrow", OBJ_ARROW, 0, Time[0], arrowPrice);
ObjectSet("BearishArrow", OBJPROP_ARROWCODE, 159);
ObjectSet("BearishArrow", OBJPROP_COLOR, Red);
ObjectSet("BearishArrow", OBJPROP_WIDTH, 3);
ObjectSet("BearishArrow", OBJPROP_STYLE, STYLE_SOLID);
ObjectSet("BearishArrow", OBJPROP_BACK, false);
ObjectSet("BearishArrow", OBJPROP_SELECTABLE, false);
ObjectSet("BearishArrow", OBJPROP_HIDDEN, false);
//--- print a message in the Experts tab
Print("Bearish Outside Bar detected at ", TimeToStr(Time[0], TIME_DATE|TIME_MINUTES));
}
// H1 timeframe
double H1_Open = iOpen(_Symbol, PERIOD_H1, 1);
double H1_High = iHigh(_Symbol, PERIOD_H1, 1);
double H1_Low = iLow(_Symbol, PERIOD_H1, 1);
double H1_Close = iClose(_Symbol, PERIOD_H1, 1);
ObjectSet("H1_Open", OBJ_TEXT, 0, Time[1], H1_Open);
ObjectSet("H1_High", OBJ_TEXT, 0, Time[1], H1_High);
ObjectSet("H1_Low", OBJ_TEXT, 0, Time[1], H1_Low);
ObjectSet("H1_Close", OBJ_TEXT, 0, Time[1], H1_Close);
// H4 timeframe
double H4_Open = iOpen(_Symbol, PERIOD_H4, 1);
double H4_High = iHigh(_Symbol, PERIOD_H4, 1);
double H4_Low = iLow(_Symbol, PERIOD_H4, 1);
double H4_Close = iClose(_Symbol, PERIOD_H4, 1);
ObjectSet("H4_Open", OBJ_TEXT, 0, Time[1], H4_Open);
ObjectSet("H4_High", OBJ_TEXT, 0, Time[1], H4_High);
ObjectSet("H4_Low", OBJ_TEXT, 0, Time[1], H4_Low);
ObjectSet("H4_Close", OBJ_TEXT, 0, Time[1], H4_Close);
// D1 timeframe
double D1_Open = iOpen(_Symbol, PERIOD_D1, 1);
double D1_High = iHigh(_Symbol, PERIOD_D1, 1);
double D1_Low = iLow(_Symbol, PERIOD_D1, 1);
double D1_Close = iClose(_Symbol, PERIOD_D1, 1);
ObjectSet("D1_Open", OBJ_TEXT, 0, Time[1], D1_Open);
ObjectSet("D1_High", OBJ_TEXT, 0, Time[1], D1_High);
ObjectSet("D1_Low", OBJ_TEXT, 0, Time[1], D1_Low);
ObjectSet("D1_Close", OBJ_TEXT, 0, Time[1], D1_Close);