what or how to edit the EA to set lot size based on positions numbers

 
hello guys I'm using an EA shockbar 1.1 and i want to add a feature to it that make the EA set the lot size automatically based on the number of positions for example: the the first position will be 0.04 and the second will be 0.03 third will be 0.02 and all positions after that will be 0.01 until all positions closed and then it will be 0.04 again. this if the price go down for buy positions of course but if the price is up it will continue to open one or two positions at most first will be 0.04 and second will be 0.03 and vice versa to sell positions if the price go down it will continue to open at the highest price but if the price go up it will decrease the lot size as i iset it to do I'm just trying to make trade at the highest lot size if the price in the right direction if not i want from it to decrease the lot size to prevent high loses so if anyone know the algorithm i will appreciate if he/she help me. thank you.
Documentation on MQL5: Trade Functions / PositionsTotal
Documentation on MQL5: Trade Functions / PositionsTotal
  • www.mql5.com
PositionsTotal - Trade Functions - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
double lotOrdr=0.04;

if(OrdersTotal()==0) lotOrdr=0.04;

Then create a function for openning a position, after  successfully placing the trade request, decrease the lot.

if(lotOrdr!=0.01) lotOrdr -= 0.01;
 
_MAHA_ #:

Then create a function for openning a position, after  successfully placing the trade request, decrease the lot.

thank you so much

Reason: