Divide by zero in the EA stops your EA permanently. See https://docs.mql4.com/runtime/errors
Dear stringo,
How do I manipulate the "divide by 0" in my case? I do not really understand your suggestion. In case I'm mistaken, what I want to do is to intentionally terminate my EA after it has sent the order sucessfully, not to figure out why my EA has terminated.
Your feedback is much appreciated.
best regards
for example
int stop=10; ... if(OrdersTotal()>0) stop/=0; // EA will be stopped automatically after zero divide ...
Thanks stringo for your advice. I have also come up with this idea. I would appreciate your comments on its logic:
init()
{
int check==0;
return();
}
start()
{
if(check==1)
{
return();
}
if(condition is true)
{
Ordersend(...);
check==1;
return();
}
return();
}
Thanks
mastermedea
after sending the first order, will stop working permanently
was your statement. stringo has given you what asked for...
stringo has suggested a failsafe way to completely and permanently stop EA which also requires hardly any coding.
not matter what you do to inhibit EA trading - using flags does not in essence permanently stop EA - it will still be called every data tick associated with chart EA attached to.
Also, your code will not work at all - as shown, is incorrect mql4. It will never compile...
Have you studied the mql4 book?
Your code says not... please take time to read mql4 book because you will then understand...
some keywords for you: scope, local, global, declaration, static
This is very important book and will show you many informations.
enjoy trip
;)
btw, please - when posting any code, to click the SRC button and insert code into this form. Why? because not easy for readers to 'see' code structure to enable them to offer you good help.
Hi ukt,
You are right about everything. That coding doesn't compile ha ha... I was aware of the logic I came up with (i.e have it recalled at every tick without sending orders) but the (guessing) coding was horrible. Well, have moved the "int check;" to after "start()", it compiled but not sure it will work. Anyway, forget it...
Coding is never my strength, nor is my capability of studying into coding books. In fact, I always have headache looking at coding. That's why I choose to manually search for setups and decide whether or not to enter (given that I'm unemployed and have plenty of time on the computer). After a setup prints, I would use very basic scripts or EA's to send orders or close them just to save me some half hour away drinking coffe rather than waiting for the correct tick to come. Funny enough, after making headaching efforts to investigate the documentation and other EA samples, I have successsfully (God bless me) created basic EA and scripts that perfectly do the job they're created for.
So my way is to ask for bit by bit of information until a decent and working EA/script is completed. That approach might not be welcome on this forum where most of you guys are king on the field. I know that, and I'm deeply thankful to all those who have patiently answered my stupid quetions, among them stringo, you and phy... thanks again!
regards
"Well, have moved the "int check;" to after "start()", it compiled but not sure it will work. "
**do some site search on keywords: scope, static, global, local
then **Have think and you will 'get it' - no probs!
"Anyway, forget it..."
no... please not say! I make more OoooPs coding than would like ;)
Remember, as a child - falling was what one did most often, yes?
A child grows and naturally learns, yes? Why so? cause keep trying 'over and over'
Well... so to does one when programming! imho, the trick is to be open to anything, to try anything - over and over... until 'get it' That is my "hammer and chisel" approach. I not 'get it' very often BUT the 'over and over' procedure kicks in every time [just as does for child] - no other way for me, but does work [most times ;]
And... never think you are right and that the computer/programming language/program environment is of course WRONG
That is last port of call when the sh*t hits the fan and it always will too - is nature of life, yes? But you, just like that child whom eventually does what many would consider impossible ie, WALK and RUN too! so you naturally learn more about programming/mql4 simply because you keep trying :o)
Is all about the need/desire in doing anything, yes?"Funny enough, after making headaching efforts to investigate the documentation and other EA samples"
CONGRATULATIONS!
See my meaning? you kept trying to walk and guess what? U DID!
soon be trying to run too!
ha... look out Carl Lewis!
"That approach might not be welcome on this forum where most of you guys are king on the field."
Well... is true that sometimes [speaking for myself] is amazing to me the nature/type of some questions. I have to kick myself and remember that is big bad world with many cultures and ways of thinking and... backgrounds which may/mayNot enable/disable individual in process of messin with MetaQuotes ;o)
I personally devote energies to my answers which [always in hindsight] might be better spent 'looking after number one!' - human nature, yes? Yet... age for me has put mellow [most times ;] aspect on life and anyway, is better for physical self to just take a chill pill when feel harmful mindset intruding... LOL
So okaaaaay, I like offering help - but done 'my way' and if nobody respond... well, sometimes in direct proportion to my efforts - so too are my mental 'issues' afterwards - grin!
But - I think good to turn from self sometimes and [at least] attempt to 'be there' for others - I also use the SWSWSW aid to help in times when 'bad vibes' hit me: SomeWillSomeWontSoWhat!!!
Then... have good ;o)) and just damn well get on with the living thingy ;)
Oh yessss - not just others that get helped - is me too! Why? as said, I not 'get it' hardly ever, but see interesting post and I read/think and as usual not 'get it' - lol. Now... the fun hots up! cause I gotta do the research and test code gunk - just like poster [should/if know how of course] do. Same most times for me - BUT I get privilege of learning too!
So how cool is that then! :o))
kings???
If only dude! as already said, I bet that many travel similar paths to me in that they just keep hacking away and eventually 'get it' - I often wish I 'got it' more often, but I do not and that's that, yes?
Of course some are VIP clever and is [usually] plain to see that they are one of the very clued in dudes! - I wish them well and may they profit with large doses of FX income!
How they got to be clever is not issue - they [to me] exhibit plainly by their posts that they are such types...
For all I know, they are massive hammer 'n chisel types which gain knowledge the hard way - I dunno ;)
okaaay - not meant/mean as 'scope into my inner tangled brain mush stuff... but as already said - my way
Enjoy time on forum and keep chill pill always nearby
<(-_-)>
..
yes, stringo, rosh and phy [plenty more too :] - are vip resources, take note of what they say - may not be clear to reader at times...lol, but they say what they say because they know else they not say!
for example
I came across this when I searched terminating an ea after its job is done.
After nearly a year, your post is still proving useful.
Many thanks.
Cheers
Hi,
I've got a problem with EA start. An EA is triggered by a new tick. Everytime a new tick comes in, EA will work for 1 loop.
How can I make an EA does not respond to a new tick IF it's previous loop has not finished yet?
In a fast rapid price movement, tick comes very fast. My EA couldn't keep up with this fast tick. The new tick(s) keep making new "start" command while the older loop(s) are not finished yet. The process is keep piling up, I can see in the perfomance of my CPU. And the EA doesn't work correctly this way. It lags alot and shows wrong result.
How can I make an EA loop start by both new tick AND after it has finished it's last loop?
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi seniors,
I have created an EA that sends orders for me automatically. It works well, the condition is when close > value and OrdersTotal()==0, then send a limit order. My concern however is that the EA may continue to send another order when the first order has triggered stop loss or take profit. So I want to find some way that this EA, after sending the first order, will stop working permanently.
Anybody helps me with what function or logic should I use? I had a look at OrdersExpire but that does not help in my case.
Many thanks in advance
Best regards