I'm new at all this. Pls help. I need to trade a set % Margin, eg 10% of the all-time high of Portfolio Value. So when then portfolio value decreases, it will be adjusted by buying more to equal the margin, eg 10%. Also when the margin% increases to an adjustable margin%, eg 12%, the extra 2% should be sold automatically. I trade it successfully manually via excel spreadsheet., but now want to do an automatic robot. Any help will be appreciated.
Margin is irrelevant. It is what you need for your broker to allow the trade. You don't trade % Margin, you trade risk.
In the name of honesty and pure science:
A trader can only make consistent profits when he/she has a profitable trading plan.
A trader should only trade live once he/she honestly (don´t fool yourself) is profitable on the Demo account.
This may take the trader anywhere from 10 000 + hours on the Demo account, thus maybe 3 to 5 years in time.
Never trade without a Stop Loss.
Logical conclusion: Once you have a validly profitable trading plan, trade 100% of your own capital because you manage your risk with your Stop Loss policy.
Critical factor: Have a genuinely consistently profitable trading plan which includes an always present Stop Loss policy.
When you do not have such a trading plan, don´t trade on a live account.