Forex
Google
New signals service!

Go Back   Forex Trading > Programming > Metatrader Programming


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
  #381 (permalink)  
Old 06-09-2008, 05:24 AM
MANSTIR's Avatar
Member
 
Join Date: Nov 2007
Posts: 93
MANSTIR is on a distinguished road
closed order

i want to closed order for ea on each day, if i'got my achieve profit..

how can i do that?

do i put;

========
bool ProfitAchieve = true;
int ProfitAchieve = 40;

========

if ProfitAchieve = true;
{
if ProfitAchieve >= 40;
{
ClosedOrder;
{
else
{


are my code were correct? i need help...please

Last edited by MANSTIR; 06-09-2008 at 05:28 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #382 (permalink)  
Old 06-09-2008, 07:40 AM
Senior Member
 
Join Date: Feb 2007
Posts: 849
FerruFx is on a distinguished road
I didn't tested but something like this may be what you need.

Quote:
bool ProfitAchieve = true;
int Profit_Achieve = 40;

int start()
{
if(ProfitAchieve && Profit() >= Profit_Achieve) CloseOrder();
}

int Profit()
{
double pips=0;
int trade;
int trades=OrdersTotal();
for(trade=0;trade<trades;trade++) {

OrderSelect(trade,SELECT_BY_POS,MODE_TRADES);

if(OrderSymbol()==Symbol() && OrderMagicNumber() == MagicNumber) {

if(OrderType() == OP_BUY) pips+= (Bid-OrderOpenPrice())/point;
if(OrderType() == OP_SELL) pips+= (OrderOpenPrice()-Ask)/point; }

} //---- for
return(pips);
}

void CloseOrder()
{
int trades = OrdersTotal();
bool order;
for(int trade=0; trade < trades; trade++) {

OrderSelect(trade,SELECT_BY_POS,MODE_TRADES);

if(OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber) continue;

if(OrderType() == OP_BUY) order = OrderClose(OrderTicket(),OrderLots(),Bid,2,Blue);
else if(OrderType() == OP_SELL) order = OrderClose(OrderTicket(),OrderLots(),Ask,2,Pink);

} //---- for

if(!order) CloseOrder();
}
__________________
THE HEART of FOREX & THE PROBABILITY METER - Trade with 100% confidence and ... Stress Less!!!
Coding services: Experts Advisors, indicators, alerts, etc ... more info by PM
NEW: video presentation of the Probability Meter ... 24hrs action on the website
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #383 (permalink)  
Old 06-10-2008, 09:12 AM
MANSTIR's Avatar
Member
 
Join Date: Nov 2007
Posts: 93
MANSTIR is on a distinguished road
Quote:
Originally Posted by FerruFx View Post
I didn't tested but something like this may be what you need.


thanks mr.ferrufx,

i will try it...

add;

bool ProfitAchieve = true;
int Profit_Achieve = 40;
int MagicNumber = 123456;

int start()
{
if(ProfitAchieve && Profit() >= Profit_Achieve) CloseOrder();
}

int Profit()
{
double pips=0;
int trade;
int trades=OrdersTotal();
for(trade=0;trade<trades;trade++) {

OrderSelect(trade,SELECT_BY_POS,MODE_TRADES);

if(OrderSymbol()==Symbol() && OrderMagicNumber() == MagicNumber) {

if(OrderType() == OP_BUY) pips+= (Bid-OrderOpenPrice())/Point;
if(OrderType() == OP_SELL) pips+= (OrderOpenPrice()-Ask)/Point; }

} //---- for
return(pips);
}

void CloseOrder()
{
int trades = OrdersTotal();
bool order;
for(int trade=0; trade < trades; trade++) {

OrderSelect(trade,SELECT_BY_POS,MODE_TRADES);

if(OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber) continue;

if(OrderType() == OP_BUY) order = OrderClose(OrderTicket(),OrderLots(),Bid,2,Blue);
else if(OrderType() == OP_SELL) order = OrderClose(OrderTicket(),OrderLots(),Ask,2,Pink);

} //---- for

if(!order) CloseOrder();
}

Last edited by MANSTIR; 06-10-2008 at 09:19 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #384 (permalink)  
Old 06-10-2008, 03:19 PM
Junior Member
 
Join Date: Apr 2008
Posts: 2
diffused is on a distinguished road
chart shift coords

Hi,

How does one dynamically find out the coords for the chart shift area?

I'm wanting to put labels in there and have them repaint when charts are resized.

Currently i only know how to put in the physical coords.


Cheers
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #385 (permalink)  
Old 06-15-2008, 09:08 AM
Member
 
Join Date: Dec 2006
Posts: 62
soul is on a distinguished road
Error Handling question

What Error message would I get if my EA place an BUYLIMIT order @ 1.4000
when the market is 1.3950?

Can solve the error by setting the Slippage to 50 or more?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #386 (permalink)  
Old 06-16-2008, 04:20 PM
Member
 
Join Date: Mar 2008
Posts: 44
mauro269 is on a distinguished road
I want to shorter the price

Hi Guys,
finally I've configured my email account on MT4, and I've done an indicator that says me the order opened. But I have still a problem....when I receive the price at which I bought or sold I receive this long value:

Price: 1.96830000

Is there a way to shorter it to 1.9683?I've used in the code the BID price.
Thanks.
Regards,

Mauro
__________________
I'm studing to become an MQL Programmer!
The best strategy to use ForexKiller. Try it: http://forex-killerallday.blogspot.com/
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #387 (permalink)  
Old 06-16-2008, 04:30 PM
IN10TION's Avatar
Senior Member
 
Join Date: Mar 2007
Posts: 510
Blog Entries: 1
IN10TION is on a distinguished road
string YourNewPrice = DoubleToStr(Bid,Digits);

Quote:
Originally Posted by mauro269 View Post
Hi Guys,
finally I've configured my email account on MT4, and I've done an indicator that says me the order opened. But I have still a problem....when I receive the price at which I bought or sold I receive this long value:

Price: 1.96830000

Is there a way to shorter it to 1.9683?I've used in the code the BID price.
Thanks.
Regards,

Mauro
__________________
..updated 4.Oct.08.. IN10TION newsReader v09.84 Lite - the best news reader on your chart
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #388 (permalink)  
Old 06-16-2008, 04:43 PM
Member
 
Join Date: Mar 2008
Posts: 44
mauro269 is on a distinguished road
Hi my friend, thanks for your reply.
I put it after:

int start()
{


Is it correct?

However I have a problem because at the string

Code:
"StopLoss: " + (YourNewPrice - SL*Point) + "pips \n\n"
It says that there's a problem at the "-" sign between YourNewPrice and SL:

'-' - both operands are to be numeric


Thanks for your help!
__________________
I'm studing to become an MQL Programmer!
The best strategy to use ForexKiller. Try it: http://forex-killerallday.blogspot.com/
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #389 (permalink)  
Old 06-16-2008, 04:55 PM
IN10TION's Avatar
Senior Member
 
Join Date: Mar 2007
Posts: 510
Blog Entries: 1
IN10TION is on a distinguished road
for the calculation you use Bid again.
a "double" has always those trailing zero's

...DoubleToStr(Bid - (SL*Point),Digits)...


Quote:
Originally Posted by mauro269 View Post
Hi my friend, thanks for your reply.
I put it after:

int start()
{


Is it correct?

However I have a problem because at the string

Code:
"StopLoss: " + (YourNewPrice - SL*Point) + "pips \n\n"
It says that there's a problem at the "-" sign between YourNewPrice and SL:

'-' - both operands are to be numeric


Thanks for your help!
__________________
..updated 4.Oct.08.. IN10TION newsReader v09.84 Lite - the best news reader on your chart
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #390 (permalink)  
Old 06-16-2008, 05:17 PM
Member
 
Join Date: Mar 2008
Posts: 44
mauro269 is on a distinguished road
Quote:
Originally Posted by IN10TION View Post
for the calculation you use Bid again.
a "double" has always those trailing zero's

...DoubleToStr(Bid - (SL*Point),Digits)...

Thanks a lot, Now it works perfect!!!
Regards
__________________
I'm studing to become an MQL Programmer!
The best strategy to use ForexKiller. Try it: http://forex-killerallday.blogspot.com/
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Tags
close, eas, profit, reach

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Learning Cycles For New Traders Dan7974 General Discussion 350 01-18-2008 06:04 PM
Learning to code for autotrading GoatT Metatrader Programming 8 01-10-2007 08:55 PM
Self learning expert mrtools Expert Advisors - Metatrader 4 32 10-22-2006 05:29 PM


All times are GMT. The time now is 02:09 PM.



Search Engine Friendly URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.