Questions from Beginners MQL4 MT4 MetaTrader 4 - page 40

 
Игорь:

I put it on a blank chart everything is displayed and counts as it should

I close and start the terminal Screenshot 1

I have changed the TF and everything appears again and works until the next restart

i just want to avoid ticking the TF because i still have paid indices that take 1-2 min to re-calculate

i have tried it with one window and without it.

the problem is on start up

I think there's something wrong with the text mark setting

 
Игорь:

Problem on startup

I guess there's something wrong with setting the text label.

One thing I don't understand is why you have all the variables initialised in your code?

like this

double s = ....

This should all be there before init(), but without expressions

double e,p,r,s,t;


and the code only contains expressions

void init()

{

s=...

}

void start()

{

r=...

t=...

}

Play around a bit, rebuild the code correctly.

And everything will work, I hope.

 
Renat Akhtyamov:

One thing I don't understand - why are all your variables initialised in your code?

like this

double s = ....

This should all be there before init(), but without expressions

double e,p,r,s,t;


I have only expressions in the code.

void init()

{

s=...

}

void start()

{

r=...

t=...

}

Play around a bit, rebuild the code correctly.

And everything will work, I hope.

I'm self-taught and I didn't write this code, but I stole it from his site

But he will not answer your questions and fixes bugs for a fee.

the code works, i have been using it for a long time and i have written many useful informers on it

but all have the same problem after restarting

I have been fighting with it for a long time but I will try your latest version

I'll let you know!

 
Игорь:

I am self-taught and I did not write this code, professional programmer KIMIV IGORI from his site

but he will not answer your questions and fixes bugs for a fee only.

the code works, i have been using it for a long time and i have written many useful informers on it

but all have the same problem after restarting

I have been fighting with it for a long time but I will try your latest version

I will report back!

I do not understand why, but on restarting it swears at this place

DoubleToStr(s/AccountBalance()*100.0, 2)

error 2016.12.20 21:31:43.360 test USDCHF,H4: zero divide in 'test.mq4' (93,26) - Division by zero.


 
Sergey Gritsay:

Not sure why yet, but on reloading it swears at this location

DoubleToStr(s/AccountBalance()*100.0, 2)

error 2016.12.20 21:31:43.360 test USDCHF,H4: zero divide in 'test.mq4' (93,26) - Division by zero.


Put a pause in inite or make some kind of check for balance == 0, Expert Advisor loads faster than the terminal connects to the server and the balance is unknown at the moment of start, i.e. zero.
 

Hello all)

I'm new to mql4 and I'm coming up with everything myself... I am new to mql4 so please don't be too hard on me.)

I want to automate my trading strategy and am using it to write an Expert Advisor.

There is a need in the section "Comment" so that the information on the chart was displayed with a table layout. Let's say I need three columns and about 10 rows.
PLEASE!!! how do I do it ...

 
Sergey Gritsay:

Not sure why yet, but on reloading it swears at this location

DoubleToStr(s/AccountBalance()*100.0, 2)

error 2016.12.20 21:31:43.360 test USDCHF,H4: zero divide in 'test.mq4' (93,26) - Division by zero.


Because the chart has loaded, but has not connected to the server, the result is division by zero.

We need to check if: if(AccountBalance()== 0) { return(0); }

Replace line:

// +"пипс "+DoubleToStr(s/AccountBalance()*100, 2)+"%", ecText, 130, 5, eiCorner);

+"пипс "+DoubleToStr(s/(AccountBalance()==0?1:AccountBalance())*100, 2)+"%", ecText, 130, 5, eiCorner);
 
Игорь:

I am self-taught and I did not write this code, professional programmer KIMIV IGORI from his site

but he will not answer your questions and fixes bugs for a fee only.

the code works, i have been using it for a long time and i have written many useful informers on it

but all have the same problem after restarting

I have been fighting with it for a long time but I will try your latest version

I will let you know!

I have eliminated an error in your code and made the information display a bit nicer.
Files:
test.mq4  56 kb
 
Sergey Gritsay:
Igor eliminated an error in your code and made the display of information a little more pleasant.

Thank you, kind man, I'll be stuck with the code for a week!

Your picture is great!

I'll use it!

I'd like to use mine, it's all clear and working!

No offense to you, I will use yours too - but I don't have so much time yet!

Maybe someone will use mine!

 
Vitaly Muzichenko:

Because the graph has loaded but no connection to the server has occurred, the result is division by zero.

We need to put a check if: if(AccountBalance()== 0) { return(0); }

Replace the line:

// +"пипс "+DoubleToStr(s/AccountBalance()*100, 2)+"%", ecText, 130, 5, eiCorner);

+"пипс "+DoubleToStr(s/(AccountBalance()==0?1:AccountBalance())*100, 2)+"%", ecText, 130, 5, eiCorner);

I didn't get any errors I looked !

A HUGE THANK YOU everything worked at last !!!!

I'm very happy to finally get all my work done !!!

Thanks again !!!!!!!!!!!!!!!!!!!

Reason: