Back to Community
Huge profits: Looking for an explinaton of "how come?"

So I've set an Algo that is re-balance is every 7 days, with initial capital of 4000$. It buys 4 stocks every time. and the simple rule is:

-go into a trade when last price crosses above the 13-period-EMA, if market cap is above 200M.
-Sell/short when crossing below the 13 EMA.

Target profit is 16 and trailing loss is 4.

Ideas of why it reaches 215% in the first year ?

(of course it compounds to 50000% after 5 years ).

Why the backtest looks so promising?!

7 responses

you can attach a "full backtest" to your post by clicking the attach button when you make a post and we will be able to read your code and find out. I can tell you now though that it's probably leveraging like crazy. You'll need to strictly control the trading conditions to simulate real live trading

It is actually not leveraged at all.
I can't attach backtest as it ain't on quantopian.
But the model is precisely as I have described it above, so anyone can create it here.

Hi Naor! Did you take a good look at your ordering logic? This is just as important as your code behind equity selection.

Incidents such as your algorithm not being able to exit positions or having a back log of buy orders that it cannot immediately fill can mess with your algorithm's performance and will almost always lever up your returns. Not accounting for this will distort your algo's backtest.

Attach a backtest so the community can better help you out!

Hi Gil , thanks!.
The log looks like it is closing positions right.
As I said I don't know yet to program with python... 😞
But I'll attach the log soon, maybe it will be helpful.

No problem! In addition, you can add this line to your record variables routine:

Record (context.account.leverage)

Afterwards run your algo- you should see that the back test now records day end leverage- from here we can determine if there is a leveraging problem.


Is it possible to disable leverage and simulate only cash accounts in backtest or live trading in paper account IB? I have an algo which has high returns and I am also searching for an answer as to how can it be possible. The range of leverage recorded for my algo is from 0.20 to 4.0


It's not possible to disable, but it is possible to control your leverage using the right orders and logic, the main thing is making sure that you are not placing a new order while one already exists