New Order (Market Execution) with % Volume Possible ?

 

Hi everybody,
I'm wanting to know if it is possible to make it so that when you click on the 'New Order' button the Volume is automatically set based upon a calculation?
I would like to have it automatically set to a percentage of Free Margin relative to unit price.

Volume = Free Margin / Price * .0001

I had a bit of a read and as I understand it I need to set Lots_New to the value, I just have no idea where to start or if this is even possible... :/
I assume it can be done for automatic trades but can it be done for manual trades?

If that is not possible, would it be possible to have an indicator that would show the current value of the calculation and then enter it manually?
thanks, Al

 

...I assume it can be done for automatic trades but can it be done for manual trades?...

Yes, if you use a Script.