Hello All
Im new to MQL4 and programming :) i just started to learn,
i need to know how can i write an expert to
1) find the biggest body of last 20 candle
2) calculate the size of body
i really appreciate if you help me to learn :)
Use a loop to go through the last 20 candles . . . save the MathAbs() difference between the Open and Close, then compare the next difference for the next candle to the last one saved, if it is larger save it instead, repeat for all the candles.
Hey buddy
its little bit complicated for me as a starter :) i really appreciate your support ... let me try if i can handle it :d i should start from one place its the best time
P.S do you know any good book that explain all functions ? with sample?
Hey Guys could you please put your comments?//+------------------------------------------------------------------+ //| test.mq4 | //| Copyright 2014, MetaQuotes Software Corp. | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ #property copyright "Copyright 2014, MetaQuotes Software Corp." #property link "http://www.metaquotes.net" extern int nOfCandle =25; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { double O = Open [1]; double C= Close[1]; if(C<O) { double badaneh = (O-C)/Point; Comment (badaneh); } if(C>O) { double badaneh2 = (C-O)/Point; Comment (badaneh2); } if (nOfCandle>Bars) { Alert("تعداد کندل اشتباه است"); return(-1); } int n =0; int MaxN=0; double MaxBody=0; while(n<nOfCandle) { double Body=(Open[n]-Close[n])/Point; int dy=MathAbs Body; if (dy>MaxBody) { MaxBody=dy; MaxN=n; } n++; } Comment("\n","\n",MaxBody,"\n",MaxN);
i think i have problem with below section
int dy=MathAbs Body;
if (dy>MaxBody)
can you please let me know how can i handle this part? i
Hello Guys,
Could you please help me why i face the below error?
'(' - function definition unexpected
//+------------------------------------------------------------------+ //| test.mq4 | //| Copyright 2014, MetaQuotes Software Corp. | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ #property copyright "Copyright 2014, MetaQuotes Software Corp." #property link "http://www.metaquotes.net" extern int q=1; extern int nOfCandle =25; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { double O = Open [q]; double C= Close[q]; if(C<O) { double badaneh = (O-C)/Point; } if(C>O) { double badaneh2 = (C-O)/Point; } if (nOfCandle>Bars) { Alert("تعداد کندل اشتباه است"); return(-1); } int n =0; int MaxN=0; double MaxBody=0; while(n<nOfCandle) { double Body=(Open[n]-Close[n])/Point; double dy=MathAbs (Body); if (dy>MaxBody) { MaxBody=dy; MaxN=n; } n++; } { double darsad = (badaneh/MaxBody)*100; double darsad2 = (badaneh2/MaxBody)*100; double Totaldarsad=(darsad+darsad2); } if (Totaldarsad>=60) { string B="بزرگ"; } if (Totaldarsad>=40,Totaldarsad<60) { string M="متوسط"; } if (Totaldarsad=<40) { string S="کوچک"; } Comment("\n اندازه بدنه کندل مورد ارزيابي ",badaneh,"\n :اندازه بدنه کندل مورد ارزيابي ",badaneh2,"\n","\n","\n :اندازي بدنه کندل مبنا",MaxBody,"\n :شماره بزرگترين کندل محيط",MaxN,"\n :نسبت بدنه کندل مورد ارزيابي به بدنه مبنا",Totaldarsad); //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- Comment(""); //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { //---- //---- return(0); } //+------------------------------------------------------------------+
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello All
Im new to MQL4 and programming :) i just started to learn,
i need to know how can i write an expert to
1) find the biggest body of last 20 candle
2) calculate the size of body
i really appreciate if you help me to learn :)
Thanks
Mostafa