| New signals service! | |
|
|||||||
| 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 |
|
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
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. |
|
|||
|
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? |
|
|||
|
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 |
|
|||
|
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? |
|
|||
|
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 |
|
|||
|
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); } } } |
|
|||
|
Quote:
Some EAs and scripts were posted (by authors) in elite section only so sorry for that. |
|
|||
|
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:
|
![]() |
| 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 | |
|
|
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 |