[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
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
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.
Alex, you here for me? I'm new to mql4. I'm trying to figure out this code.
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
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.