[ARCHIVE]Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Can't go anywhere without you - 5. - page 308

 
How do I run the newly edited script without restarting mt4?
 
I'm trying, but it's not working. I'm getting a lot of errors in the code((.
 
Will you share something? )
 

Might be useful. This works fine!

In the meta-editor, press F5 to compile.

Important: The meta editor must be run from the same folder as the terminal.

 

Alex, you here for me? I'm new to mql4. I'm trying to figure out this code.



#property indicator_chart_window
#property indicator_buffers 2
extern int TimeFrame=0;//If=0, then the current one
extern int Distanse=0;//distance of the line from the fractal in points
extern string FrApNam="Ap";//name of the line corresponding to the fractal upwards.
extern string FrDnNam="Dn";//name of the line according to the fractal downwards.
extern color ClAp=Blue;//color line corresponds to Fractal upwards.
extern color ClDn=Red;//colour of line according to Fractal Down.
extern bool comment=true;//permission to comment
//-----------------------------------------------------------------------------+
double FrPrise,znach1,znach2;
double FrApPrise=0,FrDnPrise=0;
double ind_buffer1[];
double ind_buffer2[];
//+----------------------------------------------------------------------------+
void init()
{if(TimeFrame==0){TimeFrame=Period();}
SetIndexBuffer(0,ind_buffer1);//Buffer

SetIndexBuffer(1,ind_buffer2);
return;}
void deinit(){

return;}


//+----------------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
int limit;
double tmp;
int i, j,k;
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
//-----------------------------------------------------------------------------+
LineAp();
LineDn();
double FAP=NormalizeDouble((FrApPrise-Distanse*Point),5);//Normalize
double FDP=NormalizeDouble((FrDnPrise+Distanse*Point),5);
int diap=MathRound((FrApPrise-FrDnPrise)/Point);
ind_buffer1[0]=FAP;
ind_buffer2[1]=FDP;
Comment("TimeFrame="+TimeFrame+
"\nApPrise =",FAP,
"\nDnPrise =",FDP,
"nFractal Channel ="
,diap+"Point");



return(0);
}
//-----------------------------------------------------------------------------+
// searches for a horizontal line by name, redraws if price changes |
//-----------------------------------------------------------------------------+
void LineDn(){
FrPrise=NormalizeDouble(FindNearFractal(0,TimeFrame,MODE_LOWER),MarketInfo(Symbol(),MODE_DIGITS));
FrPrise=NormalizeDouble(FrPrise-Distance*Point,MarketInfo(Symbol(),MODE_DIGITS));
//Comment(FrPrise);
if(ObjectFind(FrDnNam)==0){
if(ObjectGet(FrDnNam,OBJPROP_PRICE1)==FrPrise){return;}}
FrDnPrise=FrPrise;
ObjectDelete(FrDnNam);
SetHLine(ClDn,FrDnNam,FrDnPrise,0,1);
WindowRedraw();
return;}
//-----------------------------------------------------------------------------+
// searches for a horizontal line by name, redraws if price has changed |
//-----------------------------------------------------------------------------+
void LineAp(){
FrPrise=NormalizeDouble(FindNearFractal(0,TimeFrame,MODE_UPPER),MarketInfo(Symbol(),MODE_DIGITS));
FrPrise=NormalizeDouble(FrPrise+Distanse*Point,MarketInfo(Symbol(),MODE_DIGITS));
if(ObjectFind(FrApNam)==0){
if(ObjectGet(FrApNam,OBJPROP_PRICE1)==FrPrise){return;}}
FrApPrise=FrPrise;
ObjectDelete(FrApNam);
SetHLine(ClAp,FrApNam,FrApPrise,0,1);
WindowRedraw();
return;}
//-----------------------------------------------------------------------------+
//| Description : Search for the nearest fractal. Returns a price level. |
//+----------------------------------------------------------------------------+
//| Parameters: |
//| sy - instrument name ("" or NULL - current symbol) |
//| tf - timeframe ( 0 - current TF) |
//| mode - fractal type (MODE_LOWER|MODE_UPPER) |
//+----------------------------------------------------------------------------+
double FindNearFractal(string sy="0", int tf=0, int mode=MODE_LOWER) {
if (sy=="" || sy=="0") sy=Symbol();
double f=0;
int d=MarketInfo(sy, MODE_DIGITS), s;
if (d==0) if (StringFind(sy, "JPY"<0) d=4; else d=2;

for (s=2; s<100; s++) {
f=iFractals(sy, tf, mode, s);
if (f!=0) return(NormalizeDouble(f, d))
}
Print("FindNearFractal(): Fractal not found");
return(0);
}

//+----------------------------------------------------------------------------+
//| Description : Set object OBJ_HLINE horizontal line |
//+----------------------------------------------------------------------------+
//| Parameters: |
//| cl - line colour |
//| nm - name ("" - opening time of the current bar) |
//| p1 - price level (0 - Bid) |
//| st - line style (0 - simple line) |
//| wd - line width (0 - default) |
//+----------------------------------------------------------------------------+
void SetHLine(color cl, string nm="", double p1=0, int st=0, int wd=1) {
if (nm=="") nm=DoubleToStr(Time[0], 0);
if (p1<=0) p1=Bid;
if (ObjectFind(nm)<0) ObjectCreate(nm, OBJ_HLINE, 0, 0,0;)
ObjectSet(nm, OBJPROP_PRICE1, p1);
ObjectSet(nm, OBJPROP_COLOR , cl);
ObjectSet(nm, OBJPROP_STYLE , st);
ObjectSet(nm, OBJPROP_WIDTH , wd);
}

It is necessary to write an Expert Advisor for this indicator which would pass the upper and the lower price on М1 and М5 timeframes.

 
palomnik:

Alex, you here for me? I'm new to mql4. I'm trying to figure out this code.

#property indicator_chart_window
#property indicator_buffers 2 
extern int TimeFrame=0;//Если=0, то текуший
extern int Distanse=0;//Дистанция линии от фрактала в пунктах
extern string FrApNam="Ap";//Имя линии соотв.Фракталу вверх
extern string FrDnNam="Dn";//Имя линии соотв.Фракталу вниз
extern color ClAp=Blue;//Цвет линии соотв.Фракталу вверх
extern color ClDn=Red;//Цвет линии соотв.Фракталу вниз
extern bool comment=true;//Разрещение на комментарий
//-----------------------------------------------------------------------------+
double FrPrise,znach1,znach2;
double FrApPrise=0,FrDnPrise=0;
double ind_buffer1[];
double ind_buffer2[];
//+----------------------------------------------------------------------------+
void init()
{if(TimeFrame==0){TimeFrame=Period();}
SetIndexBuffer(0,ind_buffer1);//КОРОБКА

SetIndexBuffer(1,ind_buffer2);
return;}
void deinit(){

return;}


//+----------------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
int limit;
double tmp;
int i, j,k;
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
//-----------------------------------------------------------------------------+
LineAp();
LineDn();
double FAP=NormalizeDouble((FrApPrise-Distanse*Point),5);//ЗНАЧЕНИЕ
double FDP=NormalizeDouble((FrDnPrise+Distanse*Point),5);
int diap=MathRound((FrApPrise-FrDnPrise)/Point);
ind_buffer1[0]=FAP;
ind_buffer2[1]=FDP;
Comment("TimeFrame="+TimeFrame+
"\nApPrise =",FAP,
"\nDnPrise =",FDP,
"\nFractal Channel ="
,diap+"Point");



return(0);
}
//-----------------------------------------------------------------------------+
// Ищет горизонтальную линию по имени перерисовывает если изменилась цена | 
//-----------------------------------------------------------------------------+
void LineDn(){
FrPrise=NormalizeDouble(FindNearFractal(0,TimeFrame,MODE_LOWER),MarketInfo(Symbol(),MODE_DIGITS));
FrPrise=NormalizeDouble(FrPrise-Distanse*Point,MarketInfo(Symbol(),MODE_DIGITS));
//Comment(FrPrise);
if(ObjectFind(FrDnNam)==0){
if(ObjectGet(FrDnNam,OBJPROP_PRICE1)==FrPrise){return;}}
FrDnPrise=FrPrise; 
ObjectDelete(FrDnNam);
SetHLine(ClDn,FrDnNam,FrDnPrise,0,1);
WindowRedraw();
return;} 
//-----------------------------------------------------------------------------+
// Ищет горизонтальную линию по имени перерисовывает если изменилась цена | 
//-----------------------------------------------------------------------------+
void LineAp(){
FrPrise=NormalizeDouble(FindNearFractal(0,TimeFrame,MODE_UPPER),MarketInfo(Symbol(),MODE_DIGITS));
FrPrise=NormalizeDouble(FrPrise+Distanse*Point,MarketInfo(Symbol(),MODE_DIGITS));
if(ObjectFind(FrApNam)==0){
if(ObjectGet(FrApNam,OBJPROP_PRICE1)==FrPrise){return;}}
FrApPrise=FrPrise; 
ObjectDelete(FrApNam); 
SetHLine(ClAp,FrApNam,FrApPrise,0,1);
WindowRedraw();
return;}
//-----------------------------------------------------------------------------+ 
//| Описание : Поиск ближайшего фрактала. Возвращает ценовой уровень. |
//+----------------------------------------------------------------------------+
//| Параметры: |
//| sy - наименование инструмента ("" или NULL - текущий символ) |
//| tf - таймфрейм ( 0 - текущий ТФ) |
//| mode - тип фрактала (MODE_LOWER|MODE_UPPER) |
//+----------------------------------------------------------------------------+
double FindNearFractal(string sy="0", int tf=0, int mode=MODE_LOWER) {
if (sy=="" || sy=="0") sy=Symbol();
double f=0;
int d=MarketInfo(sy, MODE_DIGITS), s;
if (d==0) if (StringFind(sy, "JPY")<0) d=4; else d=2;

for (s=2; s<100; s++) {
f=iFractals(sy, tf, mode, s);
if (f!=0) return(NormalizeDouble(f, d));
}
Print("FindNearFractal(): Фрактал не найден");
return(0);
}

//+----------------------------------------------------------------------------+
//| Описание : Установка объекта OBJ_HLINE горизонтальная линия |
//+----------------------------------------------------------------------------+
//| Параметры: |
//| cl - цвет линии |
//| nm - наименование ("" - время открытия текущего бара) |
//| p1 - ценовой уровень (0 - Bid) |
//| st - стиль линии (0 - простая линия) |
//| wd - ширина линии (0 - по умолчанию) |
//+----------------------------------------------------------------------------+
void SetHLine(color cl, string nm="", double p1=0, int st=0, int wd=1) {
if (nm=="") nm=DoubleToStr(Time[0], 0);
if (p1<=0) p1=Bid;
if (ObjectFind(nm)<0) ObjectCreate(nm, OBJ_HLINE, 0, 0,0);
ObjectSet(nm, OBJPROP_PRICE1, p1);
ObjectSet(nm, OBJPROP_COLOR , cl);
ObjectSet(nm, OBJPROP_STYLE , st);
ObjectSet(nm, OBJPROP_WIDTH , wd);
}



Надо к данному индикатору написать советник.Передающий верхнюю и нижнюю цены.по М1 и М5 таймфреймам. 

Don't know what src is for? Delete your scribble!
 
How do I implement this function in my EA? When TP or SL is triggered on any Bay order, all Bay orders should be closed.
 
David it is not one function it is a small Expert Advisor, in a nutshell it is comparing how many orders were and how many orders are closed in the sample, I will help in details as soon as I deal with data transfer from indicator to Expert Advisor, I have already given above ToR
 
I have never heard of it, I just don't understand it. I actually described the problem, but I got some kind of silence ((. https://forum.mql4.com/ru/52892/page308 palomnik 23.04.2013 09:56
 
palomnik:
Mister, is anyone understand how to pass values from an indicator to an EA? I need help, I don't understand it myself, just one moment and then it's over. https://forum.mql4.com/ru/52892/page308 palomnik 23.04.2013 09:56
There are a lot of different ways to do this:

1. Through a global variable.

2. Via file.

3. Via iCustom().

4. Through the global graphic variables.

5. Mapping. You can transfer data from one terminal to another terminal. Or in one terminal to transfer data from one window to another window without limitation of global variables of MT4.