Forex
Google

Go Back   Forex Trading > Metatrader Training > Metatrader 4 mql 4 - Development course > Questions
Forex Forum Register FAQ Members List Calendar Search Today's Posts Mark Forums Read


Register in Forex TSD!
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time).
Click here to register and get more information

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-28-2005, 11:36 AM
cardio cardio is offline
Senior Member
 
Join Date: Sep 2005
Location: St Louis, MO, USA
Posts: 176
cardio is an unknown quantity at this point
Post Basic questions ...

Hi

I want to do the following in code

'Don't trade for 30 minutes since my last trade'
So if my indicators indicate that I should add to my current trade again then I place trade in the same direction only if 30minutes have past

I am doing the following - this code does work yet - it is just in design phase - I don't know how to add 30 minutes to my last order

This is for an EA only working on the current pair

int start()
{
int cnt, ticket, total, stop1;
static datetime lasttime

total=OrdersTotal();
for(cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

//Determine the time of the last OrderClose
if (OrderCloseTime > lasttime + 30)
{
lasttime = orderclosetime
}//if (OrderCloseTime)
}

Now I want to say
if (Curtime() > lasttime + 30 minutes)
{
Contiue trading
}

pls help
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 09-30-2005, 05:05 AM
mbkennel mbkennel is offline
Junior Member
 
Join Date: Sep 2005
Posts: 5
mbkennel is on a distinguished road
I think that looks fine, but in the check for the OrderCloseTime,
I don't see why you need the extra 30 minutes.

If the newest OrderCloseTime is more recent than the previous one, then it should be lasttime.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 09-30-2005, 09:27 AM
newdigital newdigital is online now
Administrator
 
Join Date: Sep 2005
Posts: 15,432
newdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud of
Post

if (Curtime() > lasttime + 30*60)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 10-31-2005, 07:20 PM
yaniv_av yaniv_av is offline
Member
 
Join Date: Oct 2005
Posts: 34
yaniv_av is on a distinguished road
Basic question ...

Hi,
I'm new with MetaTrader and have a basic question:

I want to limit the open positions in my expert-advisor to only 1 position at a time - but I want that limitation per symbol, so if I'll run another expert-advisor on another symbol, It will open a new position on that symbol.
In another words, I want to be able to open 1 positions for all the symbols, but not more than 1 position for a symbol (And I'm talking about many expert-advisor on many symbols...)
How can I do It ?

I saw the "totaltrades" function, but from the documentation I understood that this function applys to the account and not for the current symbol,
so "if totaltrades=1 then exit;" will cause to 1 position at a time for all the symbols...

10X !
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 11-01-2005, 12:23 PM
Alex.Piech.FinGeR's Avatar
Alex.Piech.FinGeR Alex.Piech.FinGeR is offline
Senior Member
 
Join Date: Oct 2005
Location: Germany
Posts: 305
Alex.Piech.FinGeR has much to be proud ofAlex.Piech.FinGeR has much to be proud ofAlex.Piech.FinGeR has much to be proud ofAlex.Piech.FinGeR has much to be proud ofAlex.Piech.FinGeR has much to be proud ofAlex.Piech.FinGeR has much to be proud ofAlex.Piech.FinGeR has much to be proud ofAlex.Piech.FinGeR has much to be proud of
1 positions for all the symbols

Code:
int total=OrdersTotal();
  if(total<1)

{

.
.
.

}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 11-01-2005, 12:43 PM
newdigital newdigital is online now
Administrator
 
Join Date: Sep 2005
Posts: 15,432
newdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud of
But one position for one symbol or for one chart opened?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 11-02-2005, 11:29 PM
yaniv_av yaniv_av is offline
Member
 
Join Date: Oct 2005
Posts: 34
yaniv_av is on a distinguished road
well, one per chart is the best ...

But if it can't be done, then 1 per symbol is also good...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 11-03-2005, 12:52 PM
Alex.Piech.FinGeR's Avatar
Alex.Piech.FinGeR Alex.Piech.FinGeR is offline
Senior Member
 
Join Date: Oct 2005
Location: Germany
Posts: 305
Alex.Piech.FinGeR has much to be proud ofAlex.Piech.FinGeR has much to be proud ofAlex.Piech.FinGeR has much to be proud ofAlex.Piech.FinGeR has much to be proud ofAlex.Piech.FinGeR has much to be proud ofAlex.Piech.FinGeR has much to be proud ofAlex.Piech.FinGeR has much to be proud ofAlex.Piech.FinGeR has much to be proud of
1 per symbol

Code:
...

 for (int i=0; i<OrdersTotal(); i++) {
	if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
	  if (OrderSymbol()==Symbol()  ) 

return(0);


....
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 11-04-2005, 11:58 AM
yaniv_av yaniv_av is offline
Member
 
Join Date: Oct 2005
Posts: 34
yaniv_av is on a distinguished road
Great!

10X alot !
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 11-05-2005, 03:30 PM
yaniv_av yaniv_av is offline
Member
 
Join Date: Oct 2005
Posts: 34
yaniv_av is on a distinguished road
And I'll bother u again ... (:

Can I do It also per chart ?
Because I have differents systems for differents time intervals charts ...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


Similar Threads
Thread Thread Starter Forum Replies Last Post
Basic Indicator Question waaustin Metatrader Programming 8 04-02-2008 02:54 PM
MT4 (Basic) Questions stepwise Metatrader 4 2 05-21-2007 04:03 PM
Need Help Understanding Basic MQL logic Emerald King Expert Advisors - Metatrader 4 7 02-27-2007 09:59 AM
Very basic coding help needed camisa Questions 1 05-08-2006 05:36 PM


All times are GMT. The time now is 08:22 AM.