need help reqoute problem

Jul 28, 2011 at 10:49
1,239 개의 뷰
8 Replies
pearlo
forex_trader_8864
Mar 18, 2010 부터 멤버   게시물111
Jul 28, 2011 at 10:49
int start()
{
PipTarget=(AccountBalance())*(TargetPercent/100);

if (AccountProfit()>= PipTarget)
{
for(i=OrdersTotal()-1;i>=0;i--)
{
OrderSelect(i, SELECT_BY_POS);
int type = OrderType();

bool result = false;

switch(type)
{
//Close opened long positions
case OP_BUY : result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 99, Red );
break;

//Close opened short positions
case OP_SELL : result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 99, Red );
break;

//Close pending orders
case OP_BUYLIMIT :
case OP_BUYSTOP :
case OP_SELLLIMIT :
case OP_SELLSTOP : result = OrderDelete( OrderTicket() );
}

if(result == false)
{
Alert("Order " , OrderTicket() , " failed to close. Error:" , GetLastError() );
Sleep(3000);
}
}

return(0);
pearlo
forex_trader_8864
Mar 18, 2010 부터 멤버   게시물111
Jul 28, 2011 at 10:52 (편집됨 Jul 28, 2011 at 10:54)
hi everyone. i need a little help here. what additional code or line should i add in case of requotes so that all trades would really close. thanks in advance.

ii hope someone would edit the code above so i wont get error 138 and have all trades close.
walker36
forex_trader_36599
May 13, 2011 부터 멤버   게시물1329
Jul 28, 2011 at 11:32


use "whıle" statement for loopıng ın close order wıth checkıng "ıf" "result" handle "false"

thıs wıll solve your ıssue
regards
pearlo
forex_trader_8864
Mar 18, 2010 부터 멤버   게시물111
Jul 28, 2011 at 13:03
if (AccountProfit()>= PipTarget)
{
for(i=OrdersTotal()-1;i>=0;i--)
{
OrderSelect(i, SELECT_BY_POS);
int type = OrderType();

bool result = false;

while (result == false)
{
switch(type)
{
//Close opened long positions
case OP_BUY : result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 99, Red );
break;

//Close opened short positions
case OP_SELL : result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 99, Red );
break;

//Close pending orders
case OP_BUYLIMIT :
case OP_BUYSTOP :
case OP_SELLLIMIT :
case OP_SELLSTOP : result = OrderDelete( OrderTicket() );
}
}


}

return(0);
pearlo
forex_trader_8864
Mar 18, 2010 부터 멤버   게시물111
Jul 28, 2011 at 13:04
hi steve

will the above code solve the re-quote issue?
walker36
forex_trader_36599
May 13, 2011 부터 멤버   게시물1329
Jul 28, 2011 at 13:05
that should work
ıt wıll loop untıl "result" ıs true
walker36
forex_trader_36599
May 13, 2011 부터 멤버   게시물1329
Jul 28, 2011 at 13:07
ıf you have anyother ıssues drop me messege
pearlo
forex_trader_8864
Mar 18, 2010 부터 멤버   게시물111
Jul 28, 2011 at 13:14
thank you very much steve. 😄
walker36
forex_trader_36599
May 13, 2011 부터 멤버   게시물1329
Jul 28, 2011 at 13:15
you well come😉
로그인 / 가입하기 to comment
You must be connected to Myfxbook in order to leave a comment
*상업적 사용 및 스팸은 허용되지 않으며 계정이 해지될 수 있습니다.
팁: 이미지/유튜브 URL을 게시하면 게시물에 자동으로 삽입됩니다!
팁: @기호를 입력하여 이 토론에 참여하는 사용자 이름을 자동으로 완성합니다.