Can anyone help with this function - it's "looping" at for(int i=0; i < OrdersTotal(); i++)
I should say, I went the thru education system in the "steam age", so all my "coding" is self taught (I know, how do you help someone like that)
Here's the code
Code: Select all
void DisplayAggregateLotsize()//sum buyorders less sellorders, change color of button to reflect step change in fiblot size
{
for(int i=0; i < OrdersTotal(); i++)//THIS IS LOOPING! CANT SEE WHY
{
Print ("Order Totalizer Initiated"); //maybe put a sleep or slow down option here to reduce cpu usage
if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES) == true)
{
if(OrderSymbol() == Symbol()) { // match the symbol EUR/USD or EUR/CHF, etc
if(OrderType() == OP_BUY)
totalBuyLots += OrderLots();
if(OrderType() == OP_SELL)
totalSellLots += OrderLots();
}
if (totalSellLots >= totalBuyLots){//change color of button
AggregateLots = totalSellLots - totalBuyLots;
netSell = true;
}else{//change color of button
AggregateLots = totalBuyLots - totalSellLots;
netSell = false;
if (AggregateLots == 0.02){// call set marker function
CurrentMarker = Marker0;
if (netSell){
MarkerColor002 = Blue;
}else{
MarkerColor002 = Red;
}
}else{MarkerColor002 = White;
}
if (AggregateLots == 0.03){// call set marker function
CurrentMarker = Marker1;
if (netSell){
MarkerColor003 = Blue;
}else{
MarkerColor003 = Red;
}
}else{MarkerColor003 = White;
}
}
Comment("\nTotal No of Orders = " + OrdersTotal() +
"\nAggregate Lotsize = " + DoubleToStr(AggregateLots),5);
showMarkers();
}
Comment("\nTotal No of Orders = " + OrdersTotal() +
"\nAggregate Lotsize NOT in FIB Seq = " + DoubleToStr(AggregateLots),2);
}
Comment("\nNo trade open, last lotsize was ....?. " +DoubleToStr(AggregateLots),2);
}