stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

I just can't see what's wrong with this!
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=4921
Page 1 of 1
Author:  STEIGO [ Wed Sep 28, 2016 6:58 pm ]
Post subject:  I just can't see what's wrong with this!

I'm missing something obvious ... but I've been over and over it.

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);
                         
}
All times are UTC Page 1 of 1