'Close all'/'Open' tools - page 51

 

error 130 with script

I get a error 130 when this scripted is loaded, I believe the error is stop to close, but I have set the stops to different extremes 200 pips +

and it still returns error 130

extern string Pair_0 = "USDCAD";

extern double Pair_0_Lots = 0.04;

extern int Pair_0_TP = 100;

extern int Pair_0_SL = 62;

extern int Pair_0_OrdType = 0;

/*

0 Buying position (default for else then 0 and 1).

1 Selling position.

*/

extern string Pair_1 = "USDJPY";

extern double Pair_1_Lots = 0.06;

extern int Pair_1_TP = 60;

extern int Pair_1_SL = 38;

extern int Pair_1_OrdType = 0;

/*

0 Buying position (default for else then 0 and 1).

1 Selling position.

*/

extern string OrdType = "0=Buying position. 1=Selling position.";

extern int Slippage = 5;

extern int MagicNumbers = 234;

bool KillEmAll=false;

//+------------------------------------------------------------------+

//| expert initialization function |

//+------------------------------------------------------------------+

int init()

{

//----

//----

return(0);

}

//+------------------------------------------------------------------+

//| expert deinitialization function |

//+------------------------------------------------------------------+

int deinit()

{

//----

//----

return(0);

}

//+------------------------------------------------------------------+

//| expert start function |

//+------------------------------------------------------------------+

int start()

{

//----

if(KillEmAll==true) {

Comment("\n\nJust 2 Become 1 DONE!");

return(0);

}

int kabbi=OrdersTotal(),sittong=0,dhuwe=0,karcis;

double argena=0,TP=0,SL=0;

for(int a=0;a<kabbi;a++) {

if(OrderSelect(a,SELECT_BY_POS,MODE_TRADES)) {

if(OrderMagicNumber()!=MagicNumbers) continue;

if(OrderSymbol()==Pair_0) sittong++;

else if(OrderSymbol()==Pair_1) dhuwe++;

}

}

if(sittong==0) {

if(Pair_0_OrdType>2) Pair_0_OrdType=0;

if(Pair_0_OrdType==OP_BUY) {

argena=MarketInfo(Pair_0,MODE_ASK);

if(Pair_0_SL==0) SL=0; else SL=argena-Pair_0_SL*MarketInfo(Pair_0,MODE_POINT);

if(Pair_0_TP==0) TP=0; else TP=argena+Pair_0_TP*MarketInfo(Pair_0,MODE_POINT);

} else {

argena=MarketInfo(Pair_0,MODE_BID);

if(Pair_0_SL==0) SL=0; else SL=argena+Pair_0_SL*MarketInfo(Pair_0,MODE_POINT);

if(Pair_0_TP==0) TP=0; else TP=argena-Pair_0_TP*MarketInfo(Pair_0,MODE_POINT);

}

karcis=OrderSend(Pair_0,Pair_0_OrdType,Pair_0_Lots,argena,Slippage,SL,TP,"Viking234.Com",MagicNumbers,0,Yellow);

if(karcis<0) {

Print("Something wrong with this order on "+Pair_0+" error#"+GetLastError());

return(0);

}

}

if(dhuwe==0) {

if(Pair_1_OrdType>1) Pair_1_OrdType=0;

if(Pair_1_OrdType==OP_BUY) {

argena=MarketInfo(Pair_1,MODE_ASK);

if(Pair_1_SL==0) SL=0; else SL=argena-Pair_1_SL*MarketInfo(Pair_1,MODE_POINT);

if(Pair_1_TP==0) TP=0; else TP=argena+Pair_1_TP*MarketInfo(Pair_1,MODE_POINT);

} else {

argena=MarketInfo(Pair_1,MODE_BID);

if(Pair_1_SL==0) SL=0; else SL=argena+Pair_1_SL*MarketInfo(Pair_1,MODE_POINT);

if(Pair_1_TP==0) TP=0; else TP=argena-Pair_1_TP*MarketInfo(Pair_1,MODE_POINT);

}

karcis=OrderSend(Pair_1,Pair_1_OrdType,Pair_1_Lots,argena,Slippage,SL,TP,"Viking234.Com",MagicNumbers,0,Yellow);

if(karcis<0) {

Print("Something wrong with this order on "+Pair_1+" error#"+GetLastError());

return(0);

}

}

if(sittong>0&&dhuwe>0) KillEmAll=true;

//----

return(0);

}

//+------------------------------------------------------------------+

Files:
 

EA: Request - Closing Multiple Spreads when Profit target Hit.

Hello, I am in need of an EA that will track numerous positions as subgroups and then close them when a total profit target for each sub-group of trades is hit. I would like to assign order numbers to a subgroup, a profit target to a subgroup, and then close all positions in that sub-group when the profit as a subgroup is reached. (My strategy: I trade spreads of two currency pairs and also scale into the spreads, putting on further positions if the net price goes against me. -averaging down. But I am only concerned with the overall profit target for the spread cluster. However, there are more than one pair that will be traded in the same account at one time so the various pairs need to be segregated from each other when calculating the overall P/L for the spreads.

In reality: I put on numerous positions of the AUD/USD against the USD/CHF on 1/4/11 and will also put on a GBP/USD against the EUR/USD on 1/8/11 and need to track the P/L for these two concepts independently. -thanks !

 

Close trades at specified time

Hi there

Is there any script for closing orders at specified time? (local or broker time)

 

Hi,anyone have script close all order sell only or close all order buy only ? thx for share...

 

Does any one got a buy/sell script like this?

No STOP LOSS NO Target Profit...Totally Manual...

buy script example..

.01

.02 - should be opened after it goes down 5 pips

.04 - after it goes down 8 pips

.06 - after it goes down 10 pips

.08 - after it goes down 15 pips

.10 - after it goes down 20 pips

.12 - after it goes down 30 pips

etc etc..

Files:
2222222.jpg  108 kb
 

EA to Place Pending Orders

Hi,

Does anybody know of an EA that can help me in placing buy and sell pending orders on these currency pairs EUR/USD, USD/JPY, and EUR/GBP. I need to input the entry price for buy and sell for each currency pair and T/P and S/L preferably in pips. I have one that places these trades on EUR/USD, USD/CHF, and GBP/USD.

Parameters should look something like this:

EUR/USD BUY Price

EUR/USD SELL Price

EUR/USD S/L

EUR/USD T/P

USD/JPY BUY Price

USD/JPY SELL Price

USD/JPY S/L

USD/JPY T/P

EUR/GBP BUY Price

EUR/GBP SELL Price

EUR/GBP S/L

EUR/GBP T/P

Any help will be geatly appreciated.

 

Hi sandropace,

Those scripts should be on this thread.

Look at this post https://www.mql5.com/en/forum/173000/page25 (explanation), this post https://www.mql5.com/en/forum/173000/page25 (explanation too) and this page https://www.mql5.com/en/forum/173000 (to download).

Besides, some more similar tools:

https://www.mql5.com/en/forum/180162

and

https://www.mql5.com/en/forum/general

 

Hi newdigital,

Thanks for your reply.

I have not tried the scripts yet but I think that I can use them.

The problem is that I have to make one for each currency pair and one for buy and one for sell. Is there a way how can I integrate them together so that I run it once and open all the trades, ie a buy stop and a sell stop for EUR/USD, USD/JPY, and EUR/GBP.

Is there an EA that can do this job?

Regards,

Sandro

 

What you described - are the scrips.

Because EAs are doing everything automatically (even they can decide when to place the trades ... ).

When I traded many charts and few systems simultaniously so I had same problem with you: I had to open some trades quickly with stop loss and take profit: some of them as pending, some of them for market price ... and so on.

So, I used those scripts:

https://www.mql5.com/en/forum/173000/page24

What I did is the following:

- I placed those scripts in scripts folder, compile.

- Open MetaEditor, and edit those scrips with the settings.

For exampler:

I want to automate:

Sell for EURUSD with my take profit and my stop loss

Buy for EURUSD

and buy stop for USDCHF.

So, I open 1 script in MetaEditor (for buy), change take profit and stop loss according to my desirte, change Lots to my desire, magic to 1 (Magic = 1).

After that - in MetaEditor - go to menu - File and "Save as". and save this script is AllBuyOrders_5d_ eurusd.

How to use?

In Metatrader - open chart for EURUSD and attach this script and the trade will be opened.

The trade with have magic number = 1 (Magic = 1).

Same with other pairs or type of the trades, for example - you will have

AllBuyOrders_5d_ usdchf_buystop

and so on.

In manual trading - all you need to do is just select the correct script by the name of the script, and attach it to the correct pair/chart.

That's all.

---------

The only I do not know about how those scripts will work for ECN/STP brokers (IBFX, FXCM and so on) because I used them on Alpari.

 

If 5 digit so use those scripts:

https://www.mql5.com/en/forum/173000/page24

You need to know: your broker/account is ecn/stp or not (because i think - those scripts should be modified for ecn/stp brokers/accounts). So, read this post how to know it quicky without asking anyone:

https://www.mql5.com/en/forum/179984/page8

Explanation about how to use those scripts:

https://www.mql5.com/en/forum/173000/page25

and

https://www.mql5.com/en/forum/173000/page25

I am looking to place pending orders to enter the market at a given price.

Market price is the price right now. It is not for pending order.

It is for normal order. Pending order should be different from market price.

For example - buy stop order is something as

"if the price will go up from curreent market price on ... 4 digit pips so - open buy in this time".

So, you need this one for pending order:

Distance = 0; // Distance from current price in pips for pending orders

There is Price parameter in the settings/input but I do not know about it anything as never used it.

You can try on demo and see.

Reason: