I have an issue in the below code where some labels do not appear on the chart, and I get different results when I count down or up on the ObjectCreate loop, as shown in the images attached below.
Also as a beginner in coding, and just learned to use arrays. This code is part of a huge code as a dashboard that reads data from trades placed by the other 2 EAs, so the table consists of around 30 rows. All rows are like this part of the code, I just paste this one to make it simpler to discuss. So the entire code repeating the same part for all rows, I would appreciate it if suggest more effective methods I can research and learn about to implement in this code
externdouble GAP=90;
externint S_EA_MagicNumber=45311143;
externstring Symbol1="GBPJPYx";
externstring Symbol2="AUDUSDx";
externstring Symbol3="AUDCHFx";
externstring Symbol4="EURAUDx";
externstring Symbol5="USDJPYx";
externstring Symbol6="USDCHFx";
externstring Symbol7="GBPAUDx";
externstring Symbol8="EURUSDx";
voidOnTick()
{
delete_OBJ_LABEL(); // Delete Labels Function//========================================ROW:S_Sell Lot Valuedouble SSLVAT[8];
for(int SSLVATi=OrdersTotal()-1;SSLVATi>=0;SSLVATi--)
//for(int SSLVATi=0;SSLVATi<=OrdersTotal();SSLVATi++)
{
if (OrderSelect(SSLVATi,SELECT_BY_POS))
if(OrderType()==OP_SELLLIMIT && OrderMagicNumber()==S_EA_MagicNumber)
if(OrderSymbol()==Symbol1) SSLVAT[0]= OrderLots();
elseif(OrderSymbol()==Symbol2) SSLVAT[1]= OrderLots();
elseif(OrderSymbol()==Symbol3) SSLVAT[2]= OrderLots();
elseif(OrderSymbol()==Symbol4) SSLVAT[3]= OrderLots();
elseif(OrderSymbol()==Symbol5) SSLVAT[4]= OrderLots();
elseif(OrderSymbol()==Symbol6) SSLVAT[5]= OrderLots();
elseif(OrderSymbol()==Symbol7) SSLVAT[6]= OrderLots();
elseif(OrderSymbol()==Symbol8) SSLVAT[7]= OrderLots();
}
//===lablesstring SSLVAT_labels[8];
SSLVAT_labels[0]=SSLVAT[0];
SSLVAT_labels[1]=SSLVAT[1];
SSLVAT_labels[2]=SSLVAT[2];
SSLVAT_labels[3]=SSLVAT[3];
SSLVAT_labels[4]=SSLVAT[4];
SSLVAT_labels[5]=SSLVAT[5];
SSLVAT_labels[6]=SSLVAT[6];
SSLVAT_labels[7]=SSLVAT[7];
int SSLVAT_L_end = ArraySize(SSLVAT_labels);
for( int SSLVAT_Li=SSLVAT_L_end-1; SSLVAT_Li>=0 ; SSLVAT_Li--)
//for( int SSLVAT_Li=0; SSLVAT_Li<=SSLVAT_L_end ; SSLVAT_Li++)
{
ObjectCreate(SSLVAT_labels[SSLVAT_Li],OBJ_LABEL,0,0,0);
ObjectSet(SSLVAT_labels[SSLVAT_Li],OBJPROP_CORNER,CORNER_LEFT_UPPER);
ObjectSet(SSLVAT_labels[SSLVAT_Li],OBJPROP_XDISTANCE,(SSLVAT_Li+1)*GAP);
ObjectSet(SSLVAT_labels[SSLVAT_Li],OBJPROP_YDISTANCE,70);
ObjectSetText(SSLVAT_labels[SSLVAT_Li],SSLVAT_labels[SSLVAT_Li],15,"Impact",White);
}
Comment(Symbol1,": ",SSLVAT[0],"\r\n",Symbol2,": ",SSLVAT[1],"\r\n",Symbol3,": ",
SSLVAT[2],"\r\n",Symbol4,": ",SSLVAT[3],"\r\n",Symbol5,": ",SSLVAT[4],"\r\n",
Symbol6,": ",SSLVAT[5],"\r\n",Symbol7,": ",SSLVAT[6],"\r\n",Symbol8,": ",SSLVAT[7]); //comment on chart only to validate the labels
//============================Header: Symbols =========================string Symbols_labels[8];
Symbols_labels[0]=Symbol1;Symbols_labels[1]=Symbol2;Symbols_labels[2]=Symbol3;
Symbols_labels[3]=Symbol4;Symbols_labels[4]=Symbol5;Symbols_labels[5]=Symbol6;
Symbols_labels[6]=Symbol7;Symbols_labels[7]=Symbol8;
int s_end = ArraySize(Symbols_labels);
for( int si=s_end-1; si>=0; si-- )
{
ObjectCreate(Symbols_labels[si],OBJ_LABEL,0,0,0);
ObjectSet(Symbols_labels[si],OBJPROP_CORNER,CORNER_LEFT_UPPER);
ObjectSet(Symbols_labels[si],OBJPROP_XDISTANCE,(si+1)*GAP);
ObjectSet(Symbols_labels[si],OBJPROP_YDISTANCE,20);
ObjectSet(Symbols_labels[si],OBJPROP_ZORDER,1);
ObjectSetText(Symbols_labels[si],Symbols_labels[si],15,"Impact",White);
}
} // End OnTick//============================= deleting functionvoid delete_OBJ_LABEL()
{
for(int ii = ObjectsTotal() -1; ii >=0; ii--)
{
ObjectsDeleteAll(0,0,OBJ_LABEL); //This will delete only Lable objects//ObjectDelete(ObjectName(ii)); //This will delete all objects
}
}
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Hi
I have an issue in the below code where some labels do not appear on the chart, and I get different results when I count down or up on the ObjectCreate loop, as shown in the images attached below.
Also as a beginner in coding, and just learned to use arrays. This code is part of a huge code as a dashboard that reads data from trades placed by the other 2 EAs, so the table consists of around 30 rows. All rows are like this part of the code, I just paste this one to make it simpler to discuss. So the entire code repeating the same part for all rows, I would appreciate it if suggest more effective methods I can research and learn about to implement in this code
.