Forex
Google

Go Back   Forex Trading > Programming > Metatrader Programming
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
  #781 (permalink)  
Old 03-25-2008, 08:27 PM
Beno's Avatar
Beno Beno is offline
Senior Member
 
Join Date: Aug 2006
Location: London
Posts: 246
Beno is on a distinguished road
ralph.ronnquist

Gidday

thanks for the code i have used it but it only counts for the one pair and not the total of all pairs .

I have been experimenting with various scenarios but still not working

i have an ea that opens 3 positions that i run on 5 pairs I can see the pip count for each pair but not the collective.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #782 (permalink)  
Old 03-25-2008, 10:27 PM
ShahJB's Avatar
ShahJB ShahJB is offline
Junior Member
 
Join Date: May 2007
Posts: 12
ShahJB is on a distinguished road
Quote:
Originally Posted by Beno View Post
ralph.ronnquist

Gidday

thanks for the code i have used it but it only counts for the one pair and not the total of all pairs .

I have been experimenting with various scenarios but still not working

i have an ea that opens 3 positions that i run on 5 pairs I can see the pip count for each pair but not the collective.
well, if u r familiar with global variables, u can use them to store the pips info on each pair referenced by each symbols. Create another global variable which references the total pips value and call this particular global variable, get it updated as the pips increase, store it. Global variables can be accessed by each ea since it is stored in MT4's memory.

I can help to code it for u if want.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #783 (permalink)  
Old 03-25-2008, 10:39 PM
Beno's Avatar
Beno Beno is offline
Senior Member
 
Join Date: Aug 2006
Location: London
Posts: 246
Beno is on a distinguished road
Gidday ShahJB

I have seen global variables in code before but have had zero experience with them so yes i would like to accept your help to code this as its driving me nuts
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #784 (permalink)  
Old 03-25-2008, 11:04 PM
ShahJB's Avatar
ShahJB ShahJB is offline
Junior Member
 
Join Date: May 2007
Posts: 12
ShahJB is on a distinguished road
Quote:
Originally Posted by Beno View Post
Gidday ShahJB

I have seen global variables in code before but have had zero experience with them so yes i would like to accept your help to code this as its driving me nuts
i just coded the following promptly. Why don't u add this code first. Give it a try n pm me if it fails. I need to catch some sleep.

string val_old_string = "val_old" + Symbol();

int val_old = GlobalVariableGet(val_old_string);

if(val != val_old)
{
int pips_increment_decrement;
int current_total_pips;

string counter = "Pips Counter";
double pips_counter = GlobalVariableGet(counter);

if (val>val_old)
{
pips_increment_decrement = val - val_old;
current_total_pips = pips_increment_decrement + pips_counter;
GlobalVariableSet(counter, current_total_pips);
GlobalVariableSet(val_old_string, val);
}
else
{
pips_increment_decrement = val_old - val;
current_total_pips = pips_counter - pips_increment_decrement;
GlobalVariableSet(counter, current_total_pips);
GlobalVariableSet(val_old_string, val);
}
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #785 (permalink)  
Old 03-28-2008, 02:55 PM
rlach3 rlach3 is offline
Junior Member
 
Join Date: Jan 2008
Posts: 1
rlach3 is on a distinguished road
Exclamation Why isnt' this working???

Hello,
I am a complete newbie to programming. Thanks to the posts and learning resources on this site I built up courage to attempt building few EAs, one of which will use Lguerre as one of the triggers (I used this website to help me out ; Expert Advisor Builder for MetaTrader 4 ). The problem with my EA is that it won't open buy orders when triggers are hit. I have built a couple of EAs using the aforementioned site and they execute orders for long & short positions just fine (The EAs used RSI's). Please take a look at the attached EA, 3-28, and let me know what I'm doing incorrectly.... am I using the wrong format for the levels to be hit before a trade is executed? Does the Laguerre need additional parameters?

I have spent an embarrassing amount of time on this and I'm on the verge of giving up.... any help is GREATLY appreciated!!!!!


I seem to have found the answer... why do I need to multiply the Laguerre in my EA, though?????
Attached Files
File Type: mq4 3-31.mq4 (9.8 KB, 7 views)

Last edited by rlach3 : 03-31-2008 at 03:50 PM. Reason: Update
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #786 (permalink)  
Old 03-31-2008, 09:45 PM
dtomassino dtomassino is offline
Junior Member
 
Join Date: Mar 2008
Posts: 3
dtomassino is on a distinguished road
I ran into a problem closing positions. Help please

I ran into a problem that I dont know how to solve. My program has a few open orders and closes them all together but sometimes I think that some of the orders are not filled therefore it keeps waiting till they are filled and that locks up my program. What have you guys found to be the best way to close all open orders? Thank you kindly for your help.

here is the code:



int OrdersTotalLong()
{
int order_total = 0;

for (int i = 0; i < OrdersTotal(); i++)
{
OrderSelect(i,SELECT_BY_POS, MODE_TRADES);
if (OrderType() == OP_BUY)
order_total++;
}
return(order_total);
}
int MaxLongOrder()
{
int order = 0;
double lotsbuyed = 0;

for (int i = 0; i < OrdersTotal(); i++)
{
OrderSelect(i,SELECT_BY_POS, MODE_TRADES);
if ((OrderType() == OP_BUY) && (OrderLots() > lotsbuyed))
{
lotsbuyed = OrderLots();
order = i;
}
}
return(order);
}


int CloseLong()
{
while (OrdersTotalLong() > 0) //until there's no Orders open (close all)
{
if (OrderSelect(MaxLongOrder(), SELECT_BY_POS, MODE_TRADES) == false) continue;

OrderClose(OrderTicket(),OrderLots(), Bid, 3, Green);
}


}
return(0);
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #787 (permalink)  
Old 04-01-2008, 12:33 AM
Linuxser's Avatar
Linuxser Linuxser is offline
Moderator
 
Join Date: May 2006
Location: Helliconia (Autumn)
Posts: 2,162
Linuxser has disabled reputation
Quote:
Originally Posted by dtomassino View Post
I ran into a problem that I dont know how to solve. My program has a few open orders and closes them all together but sometimes I think that some of the orders are not filled therefore it keeps waiting till they are filled and that locks up my program. What have you guys found to be the best way to close all open orders? Thank you kindly for your help.

here is the code:
Iīve moved your post here, hope you find some help.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #788 (permalink)  
Old 04-01-2008, 04:42 AM
jturns23 jturns23 is offline
Senior Member
 
Join Date: Sep 2007
Posts: 136
jturns23 is on a distinguished road
Hiding Stoploss

Could anyone tell how how to hide stoplosses and trailing stops in an EA? (I don't like the idea of brokers seeing my stoplosses or trailing stops, it's like a target for them). Thanks.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #789 (permalink)  
Old 04-01-2008, 07:09 AM
hiachiever hiachiever is offline
Member
 
Join Date: Jan 2006
Posts: 48
hiachiever is on a distinguished road
Quote:
Originally Posted by jturns23 View Post
Could anyone tell how how to hide stoplosses and trailing stops in an EA? (I don't like the idea of brokers seeing my stoplosses or trailing stops, it's like a target for them). Thanks.
Simple in your code you define a stopvalue and a target value.
Then after you place a trade obtain the price that you entered the trade at, and then with each new each tick check to see if either your stop or your target has been hit.

If has been hit then have the EA execute the OrderClose function.

Personally, I still have a stop that the broker can see though it is set a long way from the price action 50-100 pips. In this way if the terminal goes down for some reason, you are at least protected against any sudden moves.

Cheers,
Hiachiever
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #790 (permalink)  
Old 04-01-2008, 10:10 AM
omelette omelette is offline
Senior Member
 
Join Date: Jan 2006
Posts: 985
omelette is on a distinguished road
Quote:
Originally Posted by jturns23 View Post
Could anyone tell how how to hide stoplosses and trailing stops in an EA? (I don't like the idea of brokers seeing my stoplosses or trailing stops, it's like a target for them). Thanks.
What you are seeking to implement are most often called 'soft-stops', where you dynamically track P&L, closing order(s) when the required target(s) are reached - as opposed to placing 'hards-stops', which the broker can see and spike...

A hard-stop of some degree is essential imo (for the 'just-in-case' scenario..) but even this won't save you if you have a completely unscrupulous broker - such as Fxopen: -

Brokers Scam
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
How to code this? iscuba11 Metatrader 4 mql 4 - Development course 1 08-03-2007 04:22 PM


All times are GMT. The time now is 12:15 AM.