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
  #391 (permalink)  
Old 06-16-2008, 11:47 PM
Member
 
Join Date: Aug 2006
Posts: 97
bwilhite is on a distinguished road
Yes, that should solve the problem, although I would think that if you're that far behind the market you probably don't want to be opening that trade anyway (just my .0002).

The error will be invalid price, which I think is #138 if I recall correctly.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #392 (permalink)  
Old 06-19-2008, 05:46 AM
Junior Member
 
Join Date: Mar 2008
Posts: 3
Ragtrader is on a distinguished road
calling consecutive losses?

I can't figure out how to call the current count of consecutive losses (or wins) that exited through SL (or TP) on a system that maintains many open/pending orders.

Is there a function for this? (like the variable on the default MACD EA) or will I have to keep an array with the closetime of each order and recalculate it each time?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #393 (permalink)  
Old 06-19-2008, 06:14 AM
Senior Member
 
Join Date: Nov 2006
Posts: 215
luxinterior is on a distinguished road
Can you not just check the order history. If the closing price is the same as SL then it was a loss. If it's the same as the TP then it's a win.

Did I miss something?

Lux
__________________
Build An Expert Advisor. FREE E-course As Seen On TV
ForexArea.com
Users of Gap Trader from 'Forex-Assistant' MUST Read This
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #394 (permalink)  
Old 06-19-2008, 11:21 AM
Junior Member
 
Join Date: Mar 2008
Posts: 3
Ragtrader is on a distinguished road
My apologies, maybe i don't understand the order history calls...

I guess that means you could search the order history by time closed to find the most recent order closed, check if it was TP/SL, and search again?

I was just hoping there was a function that the MACD EA used instead of searching 200k orders (by the end of a 5 year backtest) for the most recent closed orders.

Is there a way to find the most recently closed orders perhaps?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #395 (permalink)  
Old 06-19-2008, 12:11 PM
Senior Member
 
Join Date: Nov 2006
Posts: 215
luxinterior is on a distinguished road
Sure. Use TimeDayOfYear(TimeCurrent()) then keep subtracting 1 till you hit an order.

Lux
__________________
Build An Expert Advisor. FREE E-course As Seen On TV
ForexArea.com
Users of Gap Trader from 'Forex-Assistant' MUST Read This
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #396 (permalink)  
Old 06-19-2008, 03:48 PM
Junior Member
 
Join Date: Mar 2008
Posts: 3
Ragtrader is on a distinguished road
ok - i tried the following - are there any functions to simplify this? it seems not that elegant


int winTotal ()
{
int totalWins = 0;

// retrieving info from trade history
int i, hstTotal=OrdersHistoryTotal();
int newestClose= -1;
datetime newestCloseTime;
int winners[20];
for(i=0;i<hstTotal;i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==True ) // order has no error
{
if (OrderCloseTime() > 0)
{
if (TimeDayOfYear(OrderCloseTime())==TimeDayOfYear(Ti meCurrent()))
// is the order from today?

{
if (newestClose>-1) // is there a newer order initialized
{
if (OrderCloseTime() >= newestCloseTime) // is this order newer?
{
int j;
int found = 0;
for (j=0; j<totalWins; j++)
{
if (OrderTicket()==winners[j]) { found++; }//not already chosen
if (found == 0)
{
newestClose = i;
newestCloseTime = OrderCloseTime();
}
}
}
else if (newestClose == -1)
{ newestClose = i; newestCloseTime = OrderCloseTime(); }
}
}
}

}
// most recent order closed - counts up to 10
OrderSelect(newestClose,SELECT_BY_POS,MODE_HISTORY );
if (OrderProfit() > 0)
{
totalWins++;
winners[totalWins]=OrderTicket();
if (totalWins>9) { return(totalWins); }
}
else { return(totalWins); }
}
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #397 (permalink)  
Old 06-19-2008, 05:12 PM
ycomp's Avatar
Member
 
Join Date: Jan 2006
Posts: 93
ycomp is on a distinguished road
Environment Variables?

Hi,

any way to set environment variables from MT4?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #398 (permalink)  
Old 06-20-2008, 10:54 AM
Junior Member
 
Join Date: Oct 2006
Posts: 18
miko is on a distinguished road
multi position script

Hi everyone,
I am looking to close all positions at the same time on MT4. Did not search properly yet but if someone could give me a hint, it 's more than welcome.
Kind Regards
Miko
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #399 (permalink)  
Old 06-20-2008, 11:20 AM
Administrator
 
Join Date: Sep 2005
Posts: 16,818
Blog Entries: 145
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
Quote:
Originally Posted by miko View Post
Hi everyone,
I am looking to close all positions at the same time on MT4. Did not search properly yet but if someone could give me a hint, it 's more than welcome.
Kind Regards
Miko
Please find on the post below the links to EAs and scripts.
Some EAs and scripts were posted (by authors) in elite section only so sorry for that.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #400 (permalink)  
Old 06-20-2008, 11:21 AM
Administrator
 
Join Date: Sep 2005
Posts: 16,818
Blog Entries: 145
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
hint

Trailing stop EAs/scripts.
- There are many trailing stop EAs: if you open the order and don't want to pricess the order manually - so those EA may do everything for you.
- tools for trailing stop: the thread with many links incl the tool to modify the orders by mouse.
- 'Close all'/'Open' scripts: the thread with many scripts/EAs.
- script to modify the order by mouse on the chart is here.
- StepStopExpert_v1.1: EA to trail the orders.
- EMATrailing Stop EA: trailing stop based on an EMA. Original thread is here.
- Trail Strength_Trend Stop: trailing stop EA based on VoltyChannel or trend envelopes is here.
- Trailing stop EA with instruction in pdf file about how to use it is here.
- BreakEvenExpert EAs: original thread with EAs/tools to move stop to break even .

EA which is managing the other EAs/orders (closing on loss, profit, equity, magic numbers and so on):
1. CloseAll-PL EA is here.
2. CloseTrades_After_Account_Profit_Reached Ea is here.
3. MultiPositionExpert. Please read this thread before using this EA: this EA is managing the other EAs' trading concerning magic number, profit, loss, equity and so on.
- Fixed version of MultiPositionExpert 1.12 version is here.
- New 1.13 version is here.
- Updated 1.14 version is here (BTW, I am using 1.12 version with real money sometimes and it works fine).
- Updated 1.15 version is here: pending orders delete and alert options:
CloseMode: 0 - Close All orders(open and pending),1-close only open orders
AlertMode: Alert mode: 0-off,1-on
4. The Colonels Chariot EA is here.


- 'Close all' scripts and CloseOnTime EA are here.
- EquityMangager V2: original thread. The other version is here.
- EquityWatch: EA to watch and manage the equity during other EA's trading.
- ShowLeverage script is here.
- MaxMargin2. This EA prints comments in the upper left corner of the chart: account balance, account equity, current margin, max margin, time and date of the last tick. Next version working with AccountEquityAnalyzer is on this post; script to delete all all Global Variables is on this post and important explanation about it is on this post.
- AccountEquityAnalyzer indicator is on ths post.
- scripts for opening of manual orders with Magic Numbers are here.
- tools to monitor spread and swap are here.
- Status Monitor: indicator to monitor leverage, swap, spead and more.
- SpreadToCheck EA (spread checker): expert will record current time and current spread in *.csv file.
- spread monitor indicator is here.
- EA to delete pendind orders on specify pairs only: original thread.
- EA to delete all pendind orders: original thread.
- EA to close the orders on specify pairs only: original thread.
- EA to close open trades based on equity or account floating loss reaches: public thread.
- HotKey for buy/sell orders: the thread is here.
- EA for buy/sell at specific price: original thread.
- EA to close a trade when 2 MAs cross is here.
- EAs or Scripts to open pending orders are here.
- Close All Trades When Once Profit Taken EA is on this page.
- script able to read a statement is on this thread.
- Systems Dashboard: indicator to monitor open trades on many EAs in one metatrader.

Swiss Army EA (Automatic order management) with pdf instruction is here:
Quote:
How to use it:
Apply it to a chart. By default, it is set to manage all orders that are currently in the terminal. This can be changed by changing the "ManageBy" options. It will perform trailing stops, breakevens, or closing of orders (as specified by user) for whatever orders it is allowed to manage (also specified by user). The EA will print to the screen what it is allowed to do, so that should help you along in figuring out what it is doing.
Buy/sell EA: the thread about buy/sell tools.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Tags
automated close order, close, eas, forex, learn mql4, learn mql4 video, mql4 learning, OrderCloseBy, profit, reach, secure profit function, T101_v1.11_orest_IBFXm.mq4, learning mql4

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 07:04 PM
Learning to code for autotrading GoatT Metatrader Programming 8 01-10-2007 09:55 PM
Self learning expert mrtools Expert Advisors - Metatrader 4 32 10-22-2006 06:29 PM


All times are GMT. The time now is 12:29 PM.



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