#property copyright "Copyright © Book, 2007"
#property link "http://AutoGraf.dp.ua"
//--------------------------------------------------------------- 1 --
// Numeric values for M15
extern int Period_1= 200; // Period of MA 1
extern double cmo1 = -10.2; // Distance between MAs
extern double cmo2 = 10.2; // Distance between MAs
bool Work=true; // EA will work.
//--------------------------------------------------------------- 2 --
int start()
{
int
Ticket; // Order number
double
cmo; // Current MA_1 value
bool
Ans =false, // Server response after closing
Cls_B=false, // Criterion for closing Buy
Cls_S=false, // Criterion for closing Sell
Opn_B=false, // Criterion for opening Buy
Opn_S=false; // Criterion for opening Sell
//--------------------------------------------------------------- 3 --
// Preliminary processing
if(Bars cmo1 ) // If difference between
{
Alert("test1");
Opn_B=true; // Criterion for opening Buy
Cls_S=true; // Criterion for closing Sell
}
if (cmo > cmo2 ) // If difference between
{
Opn_S=true; // Criterion for opening Sell
Cls_B=true; // Criterion for closing Buy
}
//--------------------------------------------------------------- 9 --
return; // Exit start()
}
//--------------------------------------------------------------------
// tradingexpert.mq4
// The code should be used for educational purpose only.
//--------------------------------------------------------------------
- i need help in my EA it got an error i cant solve
- Useful features from KimIV
- Need assistance with Coding
nice work
oops edited it
//+------------------------------------------------------------------+ //| CMO_v1.mq4 | //| Copyright ? 2006, TrendLaboratory Ltd. | //| http://finance.groups.yahoo.com/group/TrendLaboratory | //| E-mail: igorad2004@list.ru | //+------------------------------------------------------------------+ #property copyright "Copyright ? 2006, TrendLaboratory Ltd." #property link "http://finance.groups.yahoo.com/group/TrendLaboratory" #property indicator_separate_window #property indicator_buffers 1 #property indicator_color1 LightBlue #property indicator_width1 2 #property indicator_level1 0 #property indicator_level2 50 #property indicator_level3 -50 #property indicator_maximum 100 #property indicator_minimum -100 //---- input parameters extern int Length = 14; // Period of evaluation extern int Price = 0; // Price mode : 0-Close,1-Open,2-High,3-Low,4-Median,5-Typical,6-Weighted //---- buffers double CMO[]; double Bulls[]; double Bears[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators IndicatorBuffers(3); SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,CMO); SetIndexBuffer(1,Bulls); SetIndexBuffer(2,Bears); //---- name for DataWindow and indicator subwindow label string short_name="CMO("+Length+","+Price+")"; IndicatorShortName(short_name); SetIndexLabel(0,"CMO"); //---- SetIndexDrawBegin(0,Length); return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int shift, limit, counted_bars=IndicatorCounted(); double Price1, Price2; //---- if ( counted_bars < 0 ) return(-1); if ( counted_bars ==0 ) limit=Bars-Length-1; if ( counted_bars < 1 ) for(int i=1;i<Length;i++) { Bulls[Bars-i]=0; Bears[Bars-i]=0; CMO[Bars-i]=0; } if(counted_bars>0) limit=Bars-counted_bars; limit--; for( shift=limit; shift>=0; shift--) { Price1 = iMA(NULL,0,1,0,0,Price,shift); Price2 = iMA(NULL,0,1,0,0,Price,shift+1); Bulls[shift] = 0.5*(MathAbs(Price1-Price2)+(Price1-Price2)); Bears[shift] = 0.5*(MathAbs(Price1-Price2)-(Price1-Price2)); double SumBulls = 0, SumBears=0; for (i=0;i<Length;i++) { SumBulls += Bulls[shift+i]; SumBears += Bears[shift+i]; } CMO[shift] = (SumBulls-SumBears)/(SumBulls+SumBears)*100; } /* for( shift=limit; shift>=0; shift--) { double AvgBulls=iMAOnArray(Bulls,0,Length,0,0,shift); double AvgBears=iMAOnArray(Bears,0,Length,0,0,shift); CMO[shift] = (AvgBulls-AvgBears)/(AvgBulls+AvgBears)*100; } */ //---- return(0); } //+------------------------------------------------------------------+
What is the area of help required?
?? yes?
- Besley:
I want to get the alarm to happen everytime chande momemtum crosses -10.2 and 10.2
cmo=iCustom(NULL,0,"Chande",Period_1,0); // 1 if (cmo > cmo1 ) // If difference between { Alert("test1");
This would sound continuously when it's above -10.2. You want something likecmo=iCustom(NULL,0,"Chande",Period_1,0); // 1 static double cmo.prev; if (cmo.prev > cmo1 && cmo <= cmo1){ // Was above -10.2 now below Alert("test1"); } else if (cmo.prev < cmo2 && cmo >= cmo2){ Alert("test1"); } cmo.prev = cmo;
- Am i doing it correctly?iCustom(string symbol, int timeframe, string name, ..., int mode, int shift) The ... are the parameters, mode is which buffer.
Look at the indicator you see://---- input parameters extern int Length = 14; // Period of evaluation extern int Price = 0; // Price mode : 0-Close,1-Open,2-High,3-Low,4-Median,5-Typical,6-Weighted
SetIndexBuffer(0,CMO); SetIndexBuffer(1,Bulls); SetIndexBuffer(2,Bears);
Therefor your call must be:#define CMO 0 #define Bulls 1 #define Bears 2 #define Mode CMO // Choose one #define Price MODE_CLOSE // Choose one cmo=iCustom(NULL,0,"Chande",Period_1, Price, Mode, 0);
//+------------------------------------------------------------------+ //| CMO_v1.mq4 |
If the name of the indicator file is CMO_v1.ex4 then the call must be:cmo=iCustom(NULL,0,"CMO_v1",Period_1, Price, Mode, 0);
Thanks very very much for your help.
I really appreciate it
However got a few more questions.
Is there any way to visualise where the alarm occurs on the chart, looking into the journal without the indicator chart appearing till its completed it kind of perplexing.
Also, how do i link my an alert into sending out an email via EA
Figured the mail with SendMail()
Okay i replaced
if (cmo.prev > cmo1 && cmo <= cmo1){ // Was above -10.2 now below Alert("test1"); }
if (cmo.prev > cmo1 && cmo <= cmo1){ // Was above -10.2 now below Alert("test1"); SendMail("test1","test1"); }
Somehow the alert shows on journal but not the email
email tested with test mail.
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