molanis.com/forum - Tools for MetaTrader : The place to ask about the best expert advisor builder, expert advisor downloads, and expert advisor programming

AFTER YOU REGISTER SEND US AN EMAIL TO ACTIVATE YOUR ACCOUNT - Before posting:-1- Please read the user guide -2- Try the examples -3- Search in the forum
It is currently Sat Apr 27, 2024 3:14 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Delay next trade by x amount of time
PostPosted: Fri Oct 24, 2014 2:48 am 
Offline

Joined: Thu Aug 23, 2012 2:00 pm
Posts: 49
Hi Guys

Can anyone help me with the code for a MQL block that will delay the opening of the next trade by X amount of time...

My EA gets stuck in an Open/Close loop at very specific times based on a custom indi of mine and I just can't work it out so I'm thinking that if I delay the opening of the next trade by 30 or 60 mins then this will solve the issue...

Thanx


Top
 Profile  
 
 Post subject: Re: Delay next trade by x amount of time
PostPosted: Fri Oct 24, 2014 11:17 am 
Offline

Joined: Tue Dec 22, 2009 12:22 am
Posts: 1761
The mql and mql+ icons were created with specific purposes for people that know mql but like to use molanis for fast development
The mql icon is to create trading conditions (like indicator> indicator, etc)
The mql+ icon is to manage contained mql code. By contained it means that cannot do what you want unless you write all code that evaluates your trading condition and trade. We put it out there for people that want to have access to molanis functions like number of open positions, open,close trades, or add any custom code that does stuff. But it cannot modify what happens in a TA icon or a Buy icon.


Top
 Profile  
 
 Post subject: Re: Delay next trade by x amount of time
PostPosted: Fri Oct 24, 2014 2:29 pm 
Offline

Joined: Thu Aug 23, 2012 2:00 pm
Posts: 49
Thanx...

But surely I can put a MQL box between my AND and BUY/SELL that will induce MQL4 code that will stop my EA from opening another trade after a certain amount of time....

I'd love to be able to code as well as you guys do but I'm a bit lost here....

Point me in the right direction and I'll try to wing it....

Thsnx...


Top
 Profile  
 
 Post subject: Re: Delay next trade by x amount of time
PostPosted: Fri Oct 24, 2014 2:40 pm 
Offline

Joined: Thu Aug 23, 2012 2:00 pm
Posts: 49
Sorry... I've just just read your response again and I appreciate what you are saying... I'm trying to get familiar with the MQL blocks....

BUT:

1. I have cut and pasted code (sorry) I have re-typed code into the MQL blocks and it keeps being rejected...
2. WHY can I not copy and past code into the blocks... I don't get that... because if I'm wrong with the code I have to re=type it all in again...

I'm not trying to be funny... I love what you guys have done... but I'm getting stumped with advancing my programming... this is new territory that I have been avoiding for a year now...

And, it's all about not being able to cut and paste code into the MQL box.... Why can't I do that...? It really F#@$ up my time and motivation to experiment more with the MQL blocks....

Please let me know if I'm not getting something here....

Thanx

MikeT


Top
 Profile  
 
 Post subject: Re: Delay next trade by x amount of time
PostPosted: Fri Oct 24, 2014 2:51 pm 
Offline

Joined: Thu Aug 23, 2012 2:00 pm
Posts: 49
[quote We put it out there for people that want to have access to molanis functions like number of open positions, open,close trades, or add any custom code that does stuff. ][/quote]

Don't you understand that that is exactly what I am trying to do...

Jesus...

Anyways...


Top
 Profile  
 
 Post subject: Re: Delay next trade by x amount of time
PostPosted: Sun Oct 26, 2014 7:57 pm 
Offline

Joined: Tue Dec 22, 2009 12:22 am
Posts: 1761
Quote:
But surely I can put a MQL box between my AND and BUY/SELL that will induce MQL4 code that will stop my EA from opening another trade

Yes you can but it has to follow the condition format as in
if (condition) then , or in mql if (insert condition) {
So you create the insert condition part and the code generator will use it in
if (insert condition) { ... it adds if ( and ) {
Thus you cannot just paste any mql code because most likely it is not in condition format
For any code you need to use the mql+ icon and write the trading condition and the execution if (condition) { Buy... }


Top
 Profile  
 
 Post subject: Re: Delay next trade by x amount of time
PostPosted: Mon Oct 27, 2014 12:04 am 
Offline

Joined: Thu Aug 23, 2012 2:00 pm
Posts: 49
Thanx guys....

I've started to become familiar with how the MQL+ boxes work and realized that I had to hard code it.... for those of you who are interested, paste the following code just before

Quote:
if (TradeOrAlert) {


//Set Next Trade Delay
int WaitTime = 20; // 20 Min.
static int TimeSent;
if (TimeCurrent() >= TimeSent + (WaitTime * 60))
{

....and then paste the other part of the functions code just before

Quote:
// Check Trailing Stops


TimeSent = TimeCurrent();
}
else
return(0);

Note: You can obviously change the delay time to whatever delay you would like to use...

It seems to be working....

Later


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by Molanis © 2009