Hi everyone, I am a beginner coder. I have no programming background. Everything I try to self-study.
I want to pick up the order that have biggest and second biggest volume to keep track its profit.
Can anyone help me?
I have 0.01 - 0.08 - 0.09, EA said biggest 0.09, second biggest 0.08
if I detele 0.08 order, it should recaculate biggest 0.09 and second is 0.01 but it doesnt.
this is code I put on OnTick() function
I want to pick up the order that have biggest and second biggest volume to keep track its profit.
Can anyone help me?
Inserted Code
double biggest_lot=0; // biggest order Lot
double second_biggest_lot=0; // second biggest order Lot
// Find the biggest and second biggest order Lot
double biggest_vol(){
for(int i=0; i <= OrdersTotal(); i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)){
string ordSym=OrderSymbol();
double ordLot=OrderLots();
int ordMag=OrderMagicNumber();
Sleep(300);
if(ordSym==Symbol())
{
if(biggest_lot <ordLot)
// second_biggest_lot= biggest_lot;
biggest_lot = ordLot;
biggest_lot = NormalizeDouble(biggest_lot,2);
RefreshRates();
/* second_biggest_lot=NormalizeDouble(second_biggest_lot,2);
biggest_lot=NormalizeDouble(biggest_lot,2); */
}
}
}
return(biggest_lot);
}
// Find the biggest and second biggest order Lot
double second_biggest_vol(){
for(int i=0; i <= OrdersTotal(); i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)){
string ordSym=OrderSymbol();
double ordLot=OrderLots();
int ordMag=OrderMagicNumber();
Sleep(300);
if(ordSym==Symbol())
{
if(second_biggest_lot <ordLot)
if(ordLot != biggest_lot)
second_biggest_lot = ordLot;
second_biggest_lot = NormalizeDouble(second_biggest_lot,2);
RefreshRates();
/* second_biggest_lot=NormalizeDouble(second_biggest_lot,2);
biggest_lot=NormalizeDouble(biggest_lot,2); */
}
}
}
return(second_biggest_lot);
} I have 0.01 - 0.08 - 0.09, EA said biggest 0.09, second biggest 0.08
if I detele 0.08 order, it should recaculate biggest 0.09 and second is 0.01 but it doesnt.
this is code I put on OnTick() function
Inserted Code
void OnTick()
{
//---
biggest_vol();
second_biggest_vol();
Print(" second_biggest_lot: ",second_biggest_lot);
Print(" biggest_lot: ",biggest_lot);
}