last order profit - page 2

 

what is  OTCurrentTick ???

 

what is   MaxOrders ???

Do you know that you won't close any trade as long OTCurrentTick is not equal to MaxOrders...  although  LastOrderProfit might be >= 0

 
deVries:

what is  OTCurrentTick ???

 

what is   MaxOrders ???

Do you know that you won't close any trade as long OTCurrentTick is not equal to MaxOrders...  although  LastOrderProfit might be >= 0

 


Hi again deVries,

In code below you can see what OTCurrentTick is:

int start()
 
   {//0 
                                         
    OTLastTick = OTCurrentTick;                      
    OTCurrentTick = OrdersTotal(); 
                     
    if(OTCurrentTick == 0 && OTLastTick > 0)
      {      
      BuyTrigger = Ask + OpenDistance * pips2dbl;
      SellTrigger = Bid - OpenDistance * pips2dbl;
      }                                  
    if(OTLastTick >= 2                                                
      && OTCurrentTick < OTLastTick
      && OTCurrentTick > 0)
      {
       CloseAllOnSL(); return;            
      }                                                                  
    if(OTCurrentTick > 0 && OTCurrentTick < MaxOrders)OpenOppositeOrder();
                                  
    if(OTCurrentTick == 0)
      {
       BuyAllowed = true;  
       SellAllowed = true; 

 

 In other parts of the code I have other function call to close all the orders that are less than the MaxOrders.

One of the reasons that I need to identify the profit of the last order that is open have to try to close the last order that equals the MaxOrders setting as soon it reaches profit 0, I mean as soon the profit of the order pays the commission. 

Luis 

 

Help Me  Warning, return value of 'OrderSelect' should be checked

"I want check OrderLot and Lot Buy/Sell"


void CheckLOT()

{
               OrderSelect(OrdersTotal()-1,SELECT_BY_POS,MODE_TRADES);
                  int Type=OrderType();
                  double Lot=OrderLots();
               if(OrdersTotal()>0)
                  { 
                     for(int i=0; i < OrdersTotal(); i++)
                        {
                     if(Type==OP_BUY) {Lot1 = Lot*i; }       
                     if(Type==OP_SELL){Lot2 = Lot*i; } 
                     }
                     
                     _Lots = Lot1+Lot2;
                     
                  }
               if(OrdersTotal()==0)
                  {
                      Lot1 = 0;
                      Lot2 = 0;
                     _Lots = 0;
                  } 
}                   

 

Please use the </> button to insert your above code.


 

Can you read?

https://www.mql5.com/en/forum/143829/page2#comment_7968243

EDIT I have removed the copy and pasted post that the poster again did not bother to post the code correctly. Keith.

 
  1. When you post code please use the CODE button (Alt-S)! (For large amounts of code, attach it.) Please edit both your posts.
              General rules and best pratices of the Forum. - General - MQL5 programming forum
              Messages Editor

  2.                OrderSelect(OrdersTotal()-1,SELECT_BY_POS,MODE_TRADES);
    Check your return codes for errors, report them and you would know why. Don't just silence the compiler, it is trying to help you.
              What are Function return values ? How do I use them ? - MQL4 and MetaTrader 4 - MQL4 programming forum
              Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
    Only those functions that return a value (e.g. iClose, MarketInfo, etc.) must you call ResetLastError before in order to check after.

  3. Using OrdersTotal directly and/or no Magic number filtering on your OrderSelect loop means your code is incompatible with every EA (including itself on other charts and manual trading.)
              Symbol Doesn't equal Ordersymbol when another currency is added to another seperate chart . - MQL4 and MetaTrader 4 - MQL4 programming forum
              MagicNumber: "Magic" Identifier of the Order - MQL4 Articles

 
18081961: In code below you can see what OTCurrentTick is:
    OTLastTick = OTCurrentTick;                      
    OTCurrentTick = OrdersTotal(); 
                     
    if(OTCurrentTick == 0 && OTLastTick > 0)
  1. Using OrdersTotal directly and/or no Magic number filtering on your OrderSelect loop means your code is incompatible with every EA (including itself on other charts and manual trading.)
              Symbol Doesn't equal Ordersymbol when another currency is added to another seperate chart . - MQL4 and MetaTrader 4 - MQL4 programming forum
              MagicNumber: "Magic" Identifier of the Order - MQL4 Articles
  2. It also has a race condition. Orders on other charts could close/open while this chart open/closes between ticks.
Reason: