Welcome to Forex-TSD!, one of the largest Forex forums worldwide, where you will be able to find the most complete and reliable Forex information imaginable.
From the list below, select the forum that you want to visit and register to post, as many times you want. It’s absolutely free. Click here for registering on Forex-TSD.
Exclusive Forum
The Exclusive Forum is the only paid section. Once you subscribe, you will get free access to real cutting-edge Trading Systems (automated and not), Indicators, Signals, Articles, etc., that will help and guide you, in ways that you could only imagine, with your Forex trading.
Elite Section
Get access to private discussions, specialized support, indicators and trading systems reported every week.
Advanced Elite Section
For professional traders, trading system developers and any other member who may need to use and/or convert, the most cutting-edge exclusive indicators and trading systems for MT4 and MT5.
Hello guys
I have my EA coded with RefreshRates as per following, but I still have requote and my EA stop sending new CloseOrder after 1 or 2 try. How to I write a code that will ask my EA to keep sending CloseOrder until it accepted by the broker server? Thanks
for (int i=0; i < RepeatN; i++)
{
RefreshRates();
bool res = CloseOrder(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID));
if (res) break;
}
Use a while loop.
Ex:
PHP Code:
int CA()//Close All
{
while(OrdersTotal()>0)
{
OrderSelect(0,SELECT_BY_POS);
if(OrderType()==OP_BUY) OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),999,Red);
if(OrderType()==OP_SELL) OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),999,Orange);
if(OrderType()==OP_BUYSTOP||OrderType()==OP_SELLSTOP||OrderType()==OP_BUYLIMIT||OrderType()==OP_SELLLIMIT) OrderDelete(OrderTicket());
}
return(0);
}
This will Close ALL orders when you call the function.
Place this code after the return(0) at the bottom of your EA, or in an include file. Then all you have to do is type:
PHP Code:
CA();
Type this anywhere in your EA you want ALL orders to close.
Can anyone help me with this problem? I am using the attached EA and want it to open up one sequence after another if it closes for a profit during a certain time frame. It currently only runs one sequence then quits trading until you restart it. I've tried setting the extern stoptradingaftersequence to false with no avail. I've also tried using "while" and "if,else" functions without success. Keep in mind I'm a noob so any actual "where and what" to put in the code would be very appreciated.
Can anyone help me with this problem? I am using the attached EA and want it to open up one sequence after another if it closes for a profit during a certain time frame. It currently only runs one sequence then quits trading until you restart it. I've tried setting the extern stoptradingaftersequence to false with no avail. I've also tried using "while" and "if,else" functions without success. Keep in mind I'm a noob so any actual "where and what" to put in the code would be very appreciated.
I'll give you some hints:
First you need to calculate the profit since the start of the sequence. You can use a boolean variable like StartSequence=true; . Then when profit is above a certain level or when you want it to stop a sequence and start another set StartSequence=false. You will also need an initialization loop when StartSequence=false, it should do some calculations you want and then start the sequence all over.
Hope it points you to the right direction.
__________________
Need a Professional Programmer? PM me
first, thanks for you all and especially the programers for your constant help on this forum !
second, i would like you please to take a look at my strategy, it is really simple and i don't think it will take too much lines of coding :
first we buy and sell 1lot of the same currency at the same time, with a profit target of 20pips for both positions, and a stop loss of 20 pips for both positions too, so if the buy lot hit tp the sell positin will be closed and vice versa.
after the buy position tp is hit and sell positioin hit sl, the system should open 3 lots for buy and 2 lots for sell at the same time, with also profit target of 20pips for all positions, and a stop loss of 20 pips for all positions too. if the 3lots of buy hit tp and 2lot sell hit sl then the system should open another set of 3lots buy and 2lots sell same conditins as previouse set, so we are now going with the trend.
but if the sl of the 3lots buy where hit then all positins should be closed and we start again by 1lot buy+1lot sell, then according to which positin hit tp first it open our 3lots with the trend, and 2lots against the trend...and so on.
thanks on advance for your help and i hope i made it clear for you...
very short program@can't find out where the mistaKe
i write a program, but can't find out what was wrong~ ~
it say:
'SELECT_BY_POS' - variable expected C:\Program Files\Straighthold Trader\experts\scripts\ point tick value defination.mq4 (17, 21)
could anyone tell me what the mistake is?
although u may say that the program don't need to quote "orderselect", but it should be OK even if i add it, what the mistake is?
//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+
i write a program, but can't find out what was wrong~ ~
it say:
'SELECT_BY_POS' - variable expected C:\Program Files\Straighthold Trader\experts\scripts\ point tick value defination.mq4 (17, 21)
could anyone tell me what the mistake is?
although u may say that the program don't need to quote "orderselect", but it should be OK even if i add it, what the mistake is?
//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+