Little help please with a code.

To add comments, please log in or register
Mohamed Abdelwaged
242
Mohamed Abdelwaged  

I need some help guys..


now I have an opened Position "Opened Manually" 

I have that expert which count the number of open position and execute orders ..

I want the expert count his own position only but didn't work .. here is the code


void OnTick()
  {
//---
  int total=OrdersTotal();
  
   double OpenLongOrders=0,OpenShortOrders=0,PendLongs=0,PendShorts=0;
//---
   if(total==0 && OpenLongOrders==0 && OpenShortOrders==0 && PendLongs==0 && PendShorts==0 && OP_BUY_SELL_again==true) //I want only count orders with magic number=1234 or 9999
      {
      openbuy();
      printf("0 trades");
      }
  
//---
   int i;
   for(i=0;i<total;i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
      {if( OrderMagicNumber()==MyMagicNumber_B && OrderSymbol()==Symbol())
        
        {
         int type=OrderType();

         if(type == OP_BUY )       {OpenLongOrders=OpenLongOrders+1;}
         if(type == OP_SELL )      {OpenShortOrders=OpenShortOrders+1;}
         if(type == OP_BUYSTOP )   {PendLongs=PendLongs+1;}
         if(type == OP_SELLSTOP )  {PendShorts=PendShorts+1;}
                  
           
//--- Buy Direction        
       
       
         if(total==1 && OpenLongOrders==1 && OpenShortOrders==0 && PendLongs==0 && PendShorts==0) // if there is manually open positions will be count also. but I need to count expert positions only
           {
            sellstop1();
           }  
Juvenille Emperor Limited
Moderator
10421
Eleni Anna Branou  

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


Mohamed Abdelwaged
242
Mohamed Abdelwaged  
Eleni Anna Branou:

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


done
Marco vd Heijden
Moderator
12735
Marco vd Heijden  

manual positions will be skipped because they do not meet the :

OrderMagicNumber();


void OnTick()
  {
//---
  int total=OrdersTotal();
  
   double OpenLongOrders=0,OpenShortOrders=0,PendLongs=0,PendShorts=0;
//---
   if(total==0 && OpenLongOrders==0 && OpenShortOrders==0 && PendLongs==0 && PendShorts==0 && OP_BUY_SELL_again==true) //I want only count orders with magic number=1234 or 9999
      {
      openbuy();
      printf("0 trades");
      }
  
//---
   int i;
   for(i=0;i<total;i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
       {
       if( OrderMagicNumber()==MyMagicNumber_B && OrderSymbol()==Symbol())
         {
         int type=OrderType();

         if(type == OP_BUY )       {OpenLongOrders=OpenLongOrders+1;}
         if(type == OP_SELL )      {OpenShortOrders=OpenShortOrders+1;}
         if(type == OP_BUYSTOP )   {PendLongs=PendLongs+1;}
         if(type == OP_SELLSTOP )  {PendShorts=PendShorts+1;}
         }
       }
     }         
           
//--- Buy Direction        
       
       
         if(total==1 && OpenLongOrders==1 && OpenShortOrders==0 && PendLongs==0 && PendShorts==0) // if there is manually open positions will be count also. but I need to count expert positions only
           {
            sellstop1();
           } 

Do you know where the name C++ came from ? the ++ stands for plus one.

So this :

PendShorts=PendShorts+1;

Could also be written as this:

PendShorts++;
Mohamed Abdelwaged
242
Mohamed Abdelwaged  
Marco vd Heijden:

manual positions will be skipped because they do not meet the :


Do you know where the name C++ came from ? the ++ stands for plus one.

So this :

Could also be written as this:

thnx . i'm still beginner in coding.
To add comments, please log in or register