I can give idea as help.
First you need empty array of ints[] and boolean signalSemCloseAllTrades not in function, then when you get the result
if(someCheckCodeTheCatch>20) signalSemCloseAllTrades = true;shrink the array of ints[lastEndnumber++] and add all the tickets for closing, than flag signalSemCloseAllTrades is true as far as all the trades are not closed, and when done, all of them
ArrayResize( ints , 0); signalSemCloseAllTrades = false;I will not drink coffee util you do it.
Open demo account IBFX
and see the code of the scripts inside the platform then you will find as well
Close all orders by symbol just change that it does at certain profit or loss
Open demo account IBFX
and see the code of the scripts inside the platform then you will find as well
Close all orders by symbol just change that it does at certain profit or loss
I downloaded the IBFX MT4 but the expert can not be opened with MetaEditor and you can not change,
thanks
I can give idea as help.
First you need empty array of ints[] and boolean signalSemCloseAllTrades not in function, then when you get the result
shrink the array of ints[lastEndnumber++] and add all the tickets for closing, than flag signalSemCloseAllTrades is true as far as all the trades are not closed, and when done, all of themI will not drink coffee util you do it.
I need an expert to be placed on a window and close that window positions
Thanks
//+------------------------------------------------------------------------------+ //| NEW close all trades.mq4 | //+------------------------------------------------------------------------------+ #property copyright "T. de Vries" #property link "" extern int Slippage = 3; extern double MaxLoss = 420.0; extern double MinProfit = 40.0; extern bool CloseAllSymbol = true; extern int Magic1 = 1234; // Globals int TradesSlippage; double Poin,profitnow; bool CloseOrdersNow=false; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ //calculating total profit double MyProfitsTotal(int Magic1) //(int Magic1) { double profit=0; for (int cnt = OrdersTotal()-1 ; cnt >= 0 ; cnt--) { OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES); if (OrderMagicNumber() == Magic1 && OrderSymbol()==Symbol() && !CloseAllSymbol) { profit+= OrderProfit() + OrderCommission() + OrderSwap(); } //if only Magic1 if (OrderSymbol()==Symbol() && CloseAllSymbol) { profit+= OrderProfit() + OrderCommission() + OrderSwap(); }// all ChartSymbol() } //for return(profit); } int init() { if (Digits == 4 || Digits == 2) { TradesSlippage = Slippage; Poin = Point; } if (Digits == 5 || Digits == 3) { TradesSlippage = Slippage*10; Poin = Point*10; } return(0); } int deinit(){return(0);} void ScreenMsg() { string profitstr = DoubleToStr(profitnow,2); string ls_80 = "\n" + "\n" + "\n"; string ls_64 = "---------------------------\n"; string ls_88 = " Account Number: " + AccountNumber() + "\n" + " Server Time: " + TimeToStr(TimeCurrent(), TIME_SECONDS) + "\n" + " TradingResult = " + profitstr + "\n"; Comment(ls_80 + ls_64 + ls_88); } int start() { profitnow = MyProfitsTotal(Magic1); if((CloseOrdersNow) && (profitnow == 0)){CloseOrdersNow = false;} if(profitnow > MinProfit ||profitnow < (-1*MaxLoss)){CloseOrdersNow = true;} ScreenMsg(); if (CloseOrdersNow) { for (int cnt = OrdersTotal()-1 ; cnt >= 0 ; cnt--) { OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES); if (OrderMagicNumber() == Magic1 && OrderSymbol()==Symbol() && OrderType()<2 && !CloseAllSymbol) { OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),TradesSlippage,Blue); } //if only Magic1 if (OrderSymbol()==Symbol() && OrderType()<2 && CloseAllSymbol) { OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),TradesSlippage,Blue); } //only ChartSymbol() } //for } return(0); } // the end
This is all if you learn yourself a little basics then you could made this in a moment
And about IBFX that is to read with thev metaeditor look to this ....
//+-------------------------------------------------------------------------+ //| IBFX - Quick CloseAll.mq4 | //| Copyright © 2010, InterbankFX LLC | //| http://www.ibfx.com | //+------------------------------------------------------------------+ #property copyright "Copyright © 2010, Interbank FX LLC" #property link "http://www.ibfx.com" #include <IBFX - Quick Scripts.mqh>
Perhaps I might be so bold as to critique certain parts of this code ...
int init() { if (Digits == 4 || Digits == 2) { TradesSlippage = Slippage; Poin = Point; } if (Digits == 5 || Digits == 3) { TradesSlippage = Slippage*10; Poin = Point*10; } return(0); }
In this block if Digits is expected (or might possibly) be something other than 2, 3, 4 or 5 we end up with uninitialized variables TradeSlippage and Poin. Now admittedly MQL4 will rescue the errant programmer by setting them to 0 (unlike other C compilers) but it is poor practice to leave this condition. Why not just write it as ...
int init() { if (Digits == 4 || Digits == 2) { TradesSlippage = Slippage; Poin = Point; } else { TradesSlippage = Slippage*10; Poin = Point*10; } return(0); }
or explicitly trap the unaccounted for situations?
int init() { if (Digits == 4 || Digits == 2) { TradesSlippage = Slippage; Poin = Point; } else if (Digits == 5 || Digits == 3) { TradesSlippage = Slippage*10; Poin = Point*10; } else { abort = true; Print("WTF? Dodgy digits " + Digits); } return(0); }
In this section ...
//calculating total profit double MyProfitsTotal(int Magic1) //(int Magic1) { double profit=0; for (int cnt = OrdersTotal()-1 ; cnt >= 0 ; cnt--) { OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES); if (OrderMagicNumber() == Magic1 && OrderSymbol()==Symbol() && !CloseAllSymbol) { profit+= OrderProfit() + OrderCommission() + OrderSwap(); } //if only Magic1 if (OrderSymbol()==Symbol() && CloseAllSymbol) { profit+= OrderProfit() + OrderCommission() + OrderSwap(); }// all ChartSymbol() } //for return(profit); }
The code is a bit cumbersome and logically redundant. It also requires the programmer to supply a magic number when it is not always needed. It also doesn't check the success of the OrderSelect.
My revised (but untested) version ...
//calculating total profit double MyProfitsTotal2(int Magic1=0){ //(int Magic1) double profit=0; for( int cnt = OrdersTotal()-1 ; cnt >= 0 ; cnt-- ){ if( OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES) && OrderSymbol()==Symbol() ){ if( OrderMagicNumber()==Magic1 || CloseAllSymbol ) profit+= OrderProfit() + OrderCommission() + OrderSwap(); } } return(profit); }
In this section ...
The code is a bit cumbersome and logically redundant. It also requires the programmer to supply a magic number when it is not always needed. It also doesn't check the success of the OrderSelect.
My revised (but untested) version ...
It was that i made a little change to one of the first programs i wrote for myself where i had to close all trades for one symbol (EURUSD) one magicnumber
And this was for me more placed as an example The method from WHRoeder for making EA's work as well for point or pip notation I am now using in the programs i make if Flax 1964 still search for a program that can close all trades same symbol at certain profit then he has one... so the code might a bit cumbersome and logically redundant it was for me not important enough to make a perfect program because someone search for it
So yes dabbler you are right with your changes and also i like your coding style... very good
It was that i made a little change to one of the first programs i wrote for myself where i had to close all trades for one symbol (EURUSD) one magicnumber
And this was for me more placed as an example The method from WHRoeder for making EA's work as well for point or pip notation I am now using in the programs i make if Flax 1964 still search for a program that can close all trades same symbol at certain profit then he has one... so the code might a bit cumbersome and logically redundant it was for me not important enough to make a perfect program because someone search for it
So yes dabbler you are right with your changes and also i like your coding style... very good
grazie a tutti, il magic number va bene mi permette di far funzionare più expert su una singola valuta, da lunedì sono in prova su un conto demo ...
Grazie
Thanks to all, the magic number goes well I will let you run more expert on a single currency, since Monday are being tested on a demo account ...
thanks
Voi siete bravi programmatori, io non conosco il C ed utilizzo "MOLANIS" spero di avere buone idee che non riesco ad implementare ...
Esempio
E' possibile calcolare il numero delle operazioni ?
io vorrei trovare se targhet profit >( numero operazioni * singolo profitto (2$)) close this trade ...
Grazie tante
You are a good programmer, I do not know C and use "MOLANIS" I hope you have good ideas that I can not implement ...
example
And 'possible to calculate the number of operations?
I would find if targhet profit> (number operations * Single profit ($ 2)) close this trade ...
thanks a lot

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Can you help?
Does anyone have an EXPERT that can close the positions at a given profit ($ 20) of a single currency on a portfolio of more than one currency?
thanks
Potete aiutarmi?
Qualcuno ha un EXPERT che può chiudere le posizioni ad un dato profitto (20$) di una singola valuta su un portafoglio di più valute?
Grazie