Correct optimization target and approach

Hi, I've two questions, one of them relatively simple, so I'll post it first.

1st) Question:
I want to simulate a backtest and optimization on which my Initial Capital can be leverage 3x (ie 300%), every instance is given 75% (out of the 300%) of this maximum balance, -I've already read the guide to testing futures- I wanted to confirm if in order to do that, I would need to code it into the .AFL, or, It can be done by using the "account margin" box in Analysis>Settings

And if so, what amount should I put? Considering each instance uses equally divided leverage capping at 300x

2nd) Question:

I'm currently testing an intraday Margin strategy for Cryptocurrency markets.
The data period I'm optimizing is Jan-17 - March-19,
Since this would cover the whole bull/bubble/bear cycle, and all the pump and dumps along the way, this data set encompasses a lot of market behaviors.
Based on recent optimizations that I've been running (to clarify, I'm avoiding putting 500 variables to optimize, I know the trap I can fall if I have more var than data points) using CAR/MDD, I feel that 2017 is putting too much weight on profits, therefore, I don't think my system is solid, since the profits are too high and the MDD -compared- is relatively low.

What should be my correct optimization target/approach?
I don't wish to fall for the trap of getting N,000% profit in 2017-2019, and then getting a max sys loss of 50% on the report, since it is more probable to get a -50% than a N,000% in the future.
Considering the options that are built on the Walk-Foward tab, besides CAR/MDD, what is another possible alternative?

I want to curve the profits and losses to find and adequate balance as an optimization model.

"Account margin" setting of Analysis>Settings>General is for trading stocks but not for futures.

As for futures you need to read here http://www.amibroker.com/guide/h_futbacktest.html (again).
See MarginDeposit etc. (UI settings or AFL variables).

Margin deposit
The margin is the amount of money required to open single contract position. You can specify per-symbol margin in the Symbol-Information page (picture above). Positive values describe margin value in dollars, while negative express margin value as percentage of contract price. Margin value of zero is used for stocks (no margin). Margin can be also specified in the formula by using MarginDeposit reserved variable:

e.g. 3:1

MarginDeposit = -33.33;

1 Like

Thank you for the reply, a detail that I easily missed.

Any remarks about my second question?

To clarify,

MarginDeposit = -33.33;

Would be equal to using 33% of the account leverage...?
Because the way my code calculates is based on the maximum balance

So $100, becomes $300 (3x)
I'm using leverage for my long and short positions from $300, not the $100
So -33.33% is taking from my initial equity or from my maximum balance?

sorry, wanted to clarify since I got confused even after reading the article couple of times..

-33.33 means 33.33% min. margin requirement if max. leverage ratio of account is 3:1.

A 50:1 leverage ratio means that the minimum margin requirement for the trader is 1/50 = 2%.

And

To trade $100,000 of currency, with a margin of 1%, an investor will only have to deposit $1,000 into her or his margin account. The leverage provided on a trade like this is 100:1.

So if (max.) leverage was 100:1 then AB setting would be

MarginDeposit = -1; // e.g. if trading $100k trader would have to deposit min. $1k

If leverage ratio was 200:1 then

MarginDeposit = -0.5; // e.g. if trading $100k trader would have to deposit min. $500

If leverage ratio was 1:1 then

MarginDeposit = -100; // e.g. if trading $100k trader would have to deposit min. $100k

etc.

Generally, any performance metric will do as long as the model / strategy generalizes well on unseen / future data.

but you might want to check this: