Please, show the whole fragment of logs from Experts tab.
hey, thank you for replying, I solved the problem, it's logical problem....
thank you so much for responding so quickly.
cheers,
risardi
![Don't Paste Code](https://c.mql5.com/mql4/forum/2010/04/don_tfpasteocode.gif)
Objects aren't necessarily created yet when init() runs. Shouldn't the code be in start()
Also you should test if the objects actually exist.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
Hi everyone,
I'm a newbie in MQL programming however, I found a quirky thing about the following code:
extern string Resistance_Line_Name = "resist";
extern string Support_Line_Name = "support";
extern double Risk_Reward_Ratio = 1;
extern double Take_Profit_In_Pips = 30;
extern double No_Of_Lots = 0.1;
double sLineValue = 0.0;
double resistLineValue = 0.0;
double middleLineValue = 0.0;
int ticketNum = 0;
double currentClose;
//used to stop start() to repeat the execution if price is coming back.
int executionFlag = 0;
//inform if order is being placed
int orderFlag = 0;
//--------------------------------------------------------------------
int init() // Spec. funct. init()
{
Print ("Function init() triggered at start");// Alert
sLineValue = ObjectGetValueByShift(Support_Line_Name,1);
sLineValue = NormalizeDouble(sLineValue,Digits);
Print("Support Line Value is at ", DoubleToStr(sLineValue,Digits));
resistLineValue = ObjectGetValueByShift(Resistance_Line_Name,1);
resistLineValue = NormalizeDouble(resistLineValue,Digits);
Print("Resistance Line Value is ", DoubleToStr(resistLineValue,Digits));
middleLineValue = sLineValue + ((resistLineValue + sLineValue)/2.00000); // <------- <-------
Print("Middle Line Value is ", DoubleToStr(middleLineValue,Digits));
return; // Exit init()
}
When running it, I always find that it can only add resistLineValue to sLineValue but it did not divide the two number by 2. Secondly, I tried NormalizeDouble on both variables, the result were the same, it cannot add the two number and divide the result by two. The print command logged "Middle Line Value is " as resistLineValue+sLineValue. I have tried add more zeros, without zeros, change variable name, use normalizedouble, all didn't make a difference.
Would anyone with far longer experience tell me what is wrong with the code, please.