Max Lot Size - EA for MT4

 

hi all,

I have an EA which opens positions every tick when certain conditions are met on 9 CFDs.

In order to introduce a concept of money management I am looking for a way to insert one of the following concepts, whichever is the simplest should work fine since at the end of the day the idea is to ensure only certain % of the equity is at stake.

a) I want to limit the maximum total number of Lots : say I work on 9 CFDs, even if conditions are met the maximum lot size which is open should not exceed 2 let's say. (on each CFD EA automatically opens 0,5 lots, so there should only be 4 positions in 9 CFDs)

b) I could indirectly limit the % of equity or % of free margin per se

I would very much like if you could suggest ways to code this in a basic way in mql4 language

thank you for your help

all the best

Reason: