My approach. The core is the engine. - page 129

 
I'll put in my five cents. I don't have time for it at the moment. But there is such an idea to implement a similar panel at home. So I think not just make a cross to close a position (although it is necessary), but also make a mark, specify the lot and do it wholesale closing. That will give more flexible work with positions, as well as their partial closing.
 
Vasiliy Sokolov:

Work with the version of the engine you attached as a demonstration.

It's pretty straightforward. If your approach works as I think it does, then I don't see any problems with either a dynamic table or updating position values via a timer. Peter, why did you make a mess from the start?)

Vasiliy, the main thing is not to rush to conclusions. Neither for you nor for me)).

 
Konstantin Nikitin:
I'll put in my five cents. I don't have time for it at the moment. But there is such an idea to implement a similar panel at home. So I think not just do a cross to close the position (although it is necessary), but also make a mark, specify the lot and do this wholesale closing. That will give more flexible work with positions, as well as their partial closing.

I can do that.

 
Vasiliy Sokolov:

Peter, make a for loop in the timer, which would go through the open orders and send changes in the orders list to your table. Also, make the order profit in your table also change dynamically.

Vasily, please paste this code into the test EA file (the tick and timer functions instead of the old ones)

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   //---------------------------------------------
   //Количество ордеров не менялось.
   //---------------------------------------------      
   if(ArraySize(Orders) == OrdersTotal())
     {
      for(int a1 = 0; a1 < OrdersTotal(); a1++)
        {
         if(OrderSelect(a1,SELECT_BY_POS))
           {
            E_Main_form_1__PnL(OrderTicket(),OrderProfit()); 
           }
        }
     }        
  }
//--------------------------------------------------------------------+

//+------------------------------------------------------------------+
//| Timer function                                                   |
//+------------------------------------------------------------------+
void OnTimer()
  { 
   //---------------------------------------------
   //Ордер открылся.
   //---------------------------------------------     
   if(ArraySize(Orders) < OrdersTotal())
     {Alert("Ордер открылся!");
      ArrayResize(Orders,OrdersTotal());
      
      //---------------------------------------
      if(OrderSelect(OrdersTotal() - 1,SELECT_BY_POS))
        {
         if(OrderSelect(OrderTicket(),SELECT_BY_TICKET,MODE_TRADES))
           {
            //----------------------------------------------------
            E_Main_form_1__Order(OrderTicket(),OrderTicket());
            E_Main_form_1__Opening_Time(OrderTicket(),TimeToStr(OrderOpenTime(),TIME_MINUTES|TIME_SECONDS));
            E_Main_form_1__Volume(OrderTicket(),OrderLots());
            E_Main_form_1__Symbol(OrderTicket(), OrderSymbol());
            E_Main_form_1__Price(OrderTicket(), OrderOpenPrice());
            E_Main_form_1__Comission(OrderTicket(), OrderCommission());
            E_Main_form_1__Swap(OrderTicket(), OrderSwap());
            E_Main_form_1__PnL(OrderTicket(), OrderProfit());
            E_Main_form_1__Type(OrderTicket(),OrderType()); 
            //----------------------------------------------------
           }
          //--------------------------------------  
          ArrayResize(Orders,OrdersTotal());
          Orders[OrdersTotal() - 1] = OrderTicket();   
          //--------------------------------------
        }
      //---------------------------------------  
     }
   //---------------------------------------------
   //Ордер закрылся.
   //---------------------------------------------  
   if(ArraySize(Orders) > OrdersTotal())
     {
      for(int a1 = 0; a1 < 100; a1++)
        {
         if(OrderSelect(Orders[a1],SELECT_BY_TICKET) && OrderCloseTime())
           {Alert("Ордер закрылся!");
            //--------------------------------------------------
            for(int a3 = 0; a3 < 100; a3++)
              { 
               if(Orders[a3] == OrderTicket())
                 {
                  E_Main_form_1_CLOSE_ROW___Orders_table(OrderTicket());
                  Orders[a3] = 0;
                  //--------------------------------------------------
                  int deleted = 0,q = 0;
                  //--------------------
                  for(int a2 = 0; a2 < ArraySize(Orders); a2++)
                    {
                     if(deleted)Orders[q] = Orders[q+deleted];
                     if(!Orders[q]){deleted++; q--;}
                     q++;
                    }
                  //--------------------------------------------------  
                  ArrayResize(Orders,q);
                  //--------------------------------------------------                      
                 } 
              } 
          }
      }         
 }

}
      
//---------------------------------------------

And also, you have to replace line 68 and line 114 in the External Connection file.

E_Main_form_1__Opening_Time(ticket,TimeToStr(OrderOpenTime(),TIME_MINUTES|TIME_SECONDS));
E_Main_form_1__Opening_Time(ticket,TimeToStr(OrderOpenTime(),TIME_MINUTES|TIME_SECONDS));

A little bit mixed up there. Instead ofOrderOpenTime() putOrderOpenPrice().


It should work fine. Check it.

 
Note, I've tweaked the code a bit above (if you've already put it in).
 

Eh, not the canonical thing to do - separate data(model) from views and use the observer pattern to subscribe specific views to model changes or specific model fields.

But that would require the user of such a library, to think object-oriented and shove their EA data into the proposed object structure (yes, yes, you need to learn the methods of that library/framework to build an interface). And many people don't know a thing about OOP.

But Peter says you don't have to learn anything! Just go ahead and stick your global variables in the ready-made spool of generated handlers and the interface will work. Yes it's a godsend guys! It's not "make planks for a shelf, connect them according to the instructions and arrange books", but "draw your shelf and arrange your books on it". Code Less Do More ((c)/JQuery if you are)


Clearly, there are problems with product positioning. And what if it is? Hey, programmer! Do you want to make some money? You may sell what looks good! Take a hundred or so Expert Advisors without interface and sell them with interface. hahaha ))


Well, there's a disadvantage of interface file, in which the handlers of controls "stick out" - it's static. I'll have to rack my brains and create a new handler type that would act as a template and accept user/program data via input parameters.

 
Igor Volodin:

Eh, not to do the canon...

It's OK, Rehtag will do Konowam. )))

 
Igor Volodin:

Eh, not the canonical thing to do - separate data(model) from views and use the observer pattern to subscribe specific views to model changes or specific model fields.

But that would require the user of such a library, to think object-oriented and shove their EA data into the proposed object structure (yes, yes, you need to learn the methods of that library/framework to build the interface). And many people don't know a thing about OOP.

But Peter says you don't have to learn anything! Just go ahead and stick your global variables in the ready-made spool of generated handlers and the interface will work. Yes it's a godsend guys! It's not "make planks for a shelf, connect them according to the instructions and arrange books", but "draw your shelf and arrange your books on it". Code Less Do More ((c)/JQuery if you are)


Clearly, there are problems with product positioning. And what if it is? Hey, programmer! Do you want to make some money? You may sell what looks good! Take a hundred or so Expert Advisors without interface and sell them with interface. hahaha ))


Well, there's a disadvantage of interface file, in which the handlers of controls "stick out" - it's static. I'll have to rack my brains and create a new handler type that would act as a template and accept user/program data via input parameters.

At first I thought it's another batch of negativity, but then I read it better and it turned out not. Just emotions.

This constructor is intended for people who are really keen on algorithmic trading. It makes sense for them not to waste their time studying graph libraries but just to create such a code:

//====================================================================================================================
NEW_WINDOW,  W_NAME, "Main form 1",  W_ICON, 12,  W_TYPE, SETTINGS, ALWAYS_ON_TOP,    OOI,
//----------------------------------------------------------------------------------
//----------------------------------------------------------------------------------
GROUP, A,

__, BUTTON,"BUY",text,N_COLOR,(int)clrBlue, GAP,50,  BUTTON,"SELL", text,N_COLOR,(int)clrRed,

END_GROUP,
//-------------------------- 
i, AT, _X2X, "MF", 10, _Y2Y,"MF", 10,

i,BUTTONS, PARAM_TYPE,_BOOL, TEXT_FONT,"Times New Roman",  W,100, H,34, FONT_SIZE,11,   END,

//----------------------------------------------------------------------------------
GROUP, A,

__,V_BOX,"V1",W,860,  _,H,248,_,N_FRAME,1,_,NP_FRAME,1,

END_GROUP,
//--------------------------
i, AT, _X2X, "MF", 10, _Y2Y,"MF", 50,
//----------------------------------------------------------------------------------

//----------------------------------------------------------------------------------
//Объявляем таблицу:
//----------------------------------------------------------------------------------
GROUP,"Orders table", IS_TABLE,  

__,     T_HEADER, "#",W,20,_,H,30, C_HEADER, "Order",     C_HEADER, "Opening Time",W,90, C_HEADER, "Type", W,90,  C_HEADER, "Volume", W,90,  C_HEADER, "Symbol", W,90, 
                               C_HEADER, "Price",       W,90,    
                               C_HEADER, "Comission",   W,90, C_HEADER, "Swap", W,90,  C_HEADER, "PnL",    W,90,  C_HEADER, "Close",  W,40,

__,     R_HEADER,"1", CELL, A,  CELL, A,  CELL, A,   CELL, A,  CELL, A,   CELL, A, CELL, A, CELL, A, CELL, A,  I_BUTTON, A,     
__,     R_HEADER,"2",CELL, A,   CELL, A,  CELL, A,   CELL, A,  CELL, A,   CELL, A, CELL, A, CELL, A, CELL, A,  I_BUTTON, A, 
__,     R_HEADER,"3",CELL, A,   CELL, A,  CELL, A,   CELL, A,  CELL, A,   CELL, A, CELL, A, CELL, A, CELL, A,  I_BUTTON, A, 
__,     R_HEADER,"4",CELL, A,   CELL, A,  CELL, A,   CELL, A,  CELL, A,   CELL, A, CELL, A, CELL, A, CELL, A,  I_BUTTON, A, 
__,     R_HEADER,"5",CELL, A,   CELL, A,  CELL, A,   CELL, A,  CELL, A,   CELL, A, CELL, A, CELL, A, CELL, A,  I_BUTTON, A, 
__,     R_HEADER,"6",CELL, A,   CELL, A,  CELL, A,   CELL, A,  CELL, A,   CELL, A, CELL, A, CELL, A, CELL, A,  I_BUTTON, A, 
__,     R_HEADER,"7",CELL, A,   CELL, A,  CELL, A,   CELL, A,  CELL, A,   CELL, A, CELL, A, CELL, A, CELL, A,  I_BUTTON, A, 
__,     R_HEADER,"8",CELL, A,   CELL, A,  CELL, A,   CELL, A,  CELL, A,   CELL, A, CELL, A, CELL, A, CELL, A,  I_BUTTON, A, 
__,     R_HEADER,"9",CELL, A,   CELL, A,  CELL, A,   CELL, A,  CELL, A,   CELL, A, CELL, A, CELL, A, CELL, A,  I_BUTTON, A, 
__,     R_HEADER,"10",CELL, A,  CELL, A,  CELL, A,   CELL, A,  CELL, A,   CELL, A, CELL, A, CELL, A, CELL, A,  I_BUTTON, A, 
__,     R_HEADER,"11",CELL, A,  CELL, A,  CELL, A,   CELL, A,  CELL, A,   CELL, A, CELL, A, CELL, A, CELL, A,  I_BUTTON, A, 
__,     R_HEADER,"12",CELL, A,  CELL, A,  CELL, A,   CELL, A,  CELL, A,   CELL, A, CELL, A, CELL, A, CELL, A,  I_BUTTON, A, 
__,     R_HEADER,"13",CELL, A,  CELL, A,  CELL, A,   CELL, A,  CELL, A,   CELL, A, CELL, A, CELL, A, CELL, A,  I_BUTTON, A, 
__,     R_HEADER,"14",CELL, A,  CELL, A,  CELL, A,   CELL, A,  CELL, A,   CELL, A, CELL, A, CELL, A, CELL, A,  I_BUTTON, A, 
__,     R_HEADER,"15",CELL, A,  CELL, A,  CELL, A,   CELL, A,  CELL, A,   CELL, A, CELL, A, CELL, A, CELL, A,  I_BUTTON, A, 
__,     R_HEADER,"16",CELL, A,  CELL, A,  CELL, A,   CELL, A,  CELL, A,   CELL, A, CELL, A, CELL, A, CELL, A,  I_BUTTON, A, 
__,     R_HEADER,"17",CELL, A,  CELL, A,  CELL, A,   CELL, A,  CELL, A,   CELL, A, CELL, A, CELL, A, CELL, A,  I_BUTTON, A, 
__,     R_HEADER,"18",CELL, A,  CELL, A,  CELL, A,   CELL, A,  CELL, A,   CELL, A, CELL, A, CELL, A, CELL, A,  I_BUTTON, A, 
__,     R_HEADER,"19",CELL, A,  CELL, A,  CELL, A,   CELL, A,  CELL, A,   CELL, A, CELL, A, CELL, A, CELL, A,  I_BUTTON, A, 
__,     R_HEADER,"20",CELL, A,  CELL, A,  CELL, A,   CELL, A,  CELL, A,   CELL, A, CELL, A, CELL, A, CELL, A,  I_BUTTON, A, 
__,     R_HEADER,"21",CELL, A,  CELL, A,  CELL, A,   CELL, A,  CELL, A,   CELL, A, CELL, A, CELL, A, CELL, A,  I_BUTTON, A, 
 
END_GROUP,
//------------------------------------
i,AT, LEFT_TOP, 0,0,
i, IN, "V1",
//-----------
i, Y_GAP,-1,
i, X_GAP,-1,
//-----------
i, IS_ZEBRA_STYLE,
i, DnD_RECIEVER,
i, R_HEADERS,   W,20, N_COLOR,(int)C'0,235,0', END,
i, C_HEADERS,   H,30,                          END,
i, CELLS,       H,25,                          END,
i, C_HEADERS,   DnD_ON, DnD_FUNCTION, ROTATE_COLOMNS, END,
i, I_BUTTONS, C_FUNCTION, DELETES_ROW,   text,HIDE,1, N_FRAME,1,A_FRAME,1, NP_FRAME,1, AP_FRAME,1, N_LABEL,745, END,
i, IS_DINAMIC,
//----------------------------------------------------------------------------------
"Order", H,30,
//----------------------------------------------------------------------------------
END_WINDOW,
//====================================================================================================================

And get a window with a din table.


In the interface file the user will get this code:

//=====================================================================================================================
//WINDOW:   Main form 1 | element: BUTTON  | name: BUY  |  Location: Window's Main Frame
//=====================================================================================================================
case BUTTON3____BUY:
               //------------------------------------------------------------------------------------------------------
               //What to do when button pressed or released?
               //------------------------------------------------------------------------------------------------------
               switch((int)action)
               {
                case pressed:     break;
  
                case released:     break;
               }
               //------------------------------------------------------------------------------------------------------
               //Your comment:
               //------------------------------------------------------------------------------------------------------
               break;
  
//=====================================================================================================================
//WINDOW:   Main form 1 | element: BUTTON  | name: SELL  |  Location: Window's Main Frame
//=====================================================================================================================
case BUTTON4____SELL:
               //------------------------------------------------------------------------------------------------------
               //What to do when button pressed or released?
               //------------------------------------------------------------------------------------------------------
               switch((int)action)
               {
                case pressed:     break;
  
                case released:     break;
               }
               //------------------------------------------------------------------------------------------------------
               //Your comment:
               //------------------------------------------------------------------------------------------------------
               break;
  
//=====================================================================================================================
//WINDOW:   Main form 1 | element: I_BUTTON  | name: 1_Close  |  Location: Window's Main Frame   | Table: 300000007
//=====================================================================================================================
case I_BUTTON14___Close:
               //------------------------------------------------------------------------------------------------------
               //What to do when button pressed or released?
               //------------------------------------------------------------------------------------------------------
               switch((int)action)
               {
                case pressed:     break;
  
                case released:     break;
               }
               //------------------------------------------------------------------------------------------------------
               //Your comment:
               //------------------------------------------------------------------------------------------------------
               break;
  
   }
}
//=================================================================================================================

And it will determine what to do and how to do it on button click events.

 

The next dynamic table will be even more interesting. The cells will have input fields, pop-up lists, checkboxes, buttons, radio buttons, progress bars, and input fields with +/- buttons.

The tricky part is the dynamism of such a table. After all, accessing elements and getting their values is not tied to specific parameters, but depends on the row layout.

Reason: