need help reqoute problem

Jul 28, 2011 at 10:49
1,186流覽
8 Replies
pearlo
forex_trader_8864
會員從Mar 18, 2010開始   127帖子
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開始   127帖子
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開始   1341帖子
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開始   127帖子
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開始   127帖子
Jul 28, 2011 at 13:04
hi steve

will the above code solve the re-quote issue?
walker36
forex_trader_36599
會員從May 13, 2011開始   1341帖子
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開始   1341帖子
Jul 28, 2011 at 13:07
ıf you have anyother ıssues drop me messege
pearlo
forex_trader_8864
會員從Mar 18, 2010開始   127帖子
Jul 28, 2011 at 13:14
thank you very much steve. 😄
walker36
forex_trader_36599
會員從May 13, 2011開始   1341帖子
Jul 28, 2011 at 13:15
you well come😉
登錄 / 註冊 to comment
You must be connected to Myfxbook in order to leave a comment
*商業用途和垃圾郵件將不被容忍,並可能導致帳戶終止。
提示:發佈圖片/YouTube網址會自動嵌入到您的帖子中!
提示:鍵入@符號,自動完成參與此討論的用戶名。