HOW TO CODE???

 
I've tried everything to get my code working, something is wrong but what?  I'm simply trying to keep BUY && SELL ratios approximately even.  I've allowed for in the code a situation whereby five positions can be unhedged, why does my code not work?  Any help greatly appreciated and thankyou.
 

Try posting a legible copy of your code

 

Thanks Phy, I wasn't aware the code was illegible, from my end is ok. I know I'm making silly errors in programming but I just can't see where so all help is greatly appreciated. Thankyou

 

One problem, discussed many times before...

Use

for(i = OrdersTotal() -1; i >=0; i--)

when closing orders.

Close from top down, not bottom up

 

Thanks Phy yes but I have also tried that and we are still trying to get the program to work, via bool, history etc. I should have uploaded the code with your suggestion but it seems to me I can't be far off with my programming so that is encouraging. Thankyou for your time.

Reason: