MQL4 Learning - page 42

 

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(TimeCurrent()))

// 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); }

}

}

 

Environment Variables?

Hi,

any way to set environment variables from MT4?

 

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

 
miko:
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.

 

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 crossis 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:

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.

 
 

You may use

Current

For example:

double Buy1_1 = iMA(NULL, 0, 55, 0, MODE_EMA, PRICE_CLOSE, Current + 1);

double Buy1_2 = iMA(NULL, 0, 200, 0, MODE_EMA, PRICE_CLOSE, Current + 1);

double Buy2_1 = iMA(NULL, 0, 55, 0, MODE_EMA, PRICE_CLOSE, Current + 0);

double Buy2_2 = iMA(NULL, 0, 200, 0, MODE_EMA, PRICE_CLOSE, Current + 0);

double Buy3_1 = iSAR(NULL, 0, 0.005, 0.05, Current + 1);

double Buy3_2 = iSAR(NULL, 0, 0.005, 0.05, Current + 0);

double Buy4_1 = iMACD(NULL, 0, 12, 26, 9, PRICE_CLOSE, MODE_SIGNAL, Current + 1);

double Buy4_2 = iMACD(NULL, 0, 12, 26, 9, PRICE_CLOSE, MODE_SIGNAL, Current + 0);[/CODE]

and so on ..

And in the EA's settings:

[CODE]extern int Current = 0;
 

Limit & Stop levels

Hi,

Is there indicator that can show my Stop Loss and Take Profit of my Broker when news come ? Indi that can show me changes of Stop Loss and Take Profit ?

Pucio

 

I moved your post to here as did not understand the question sorry.

Forex news MT4 indicators are on this section https://www.mql5.com/en/forum

 

Thanks!

much appreciated......

Reason: