New Monte Carlo tests, Money management snippet and Custom blocks

In recent months, the sharing server and Strategy Quant X have both been updated with new snippets, which provides the ability to assess the robustness of strategies. We define “robustness” as the ablity of strategies to preserve their qualitative attributes over time.

We have included three new Monte Carlo tests and one Money Management snippet. We will now provide a concise description of each of them and how they can assist in the successful expansion of the equity curve of your strategies, thereby enabling you to successfully navigate the path of an algorithmic trader.

We have added the following new snippets:

  • Monte Carlo – Modified Randomize strategy parameters 
  • Monte Carlo – Randomize SWAP of a whole backtest  
  • Monte Carlo –  Randomize SWAP of a every trade 
  • Fixed proportional position sizing
  • New Custom blocks based on Is rising/ Is falling logic

 

This blog article will explain and detail these snippets and how to use them.

 

Monte Carlo – Customizable Randomize Strategy parameters

It is a modified Randomize Strategy parameter test.  For the default test, the parameters that are randomized are predetermined. The Trading options are randomized in practice, while the Shifts are not. Such a setup, in my opinion, prevents us from evaluating the start strategies in as much detail as we would need.

You can see the snippet’s setting in the example above.

 

Monte Carlo Modified Randomize Strategy parameters is a parameterizable snippet that allows you to randomize the parameters used in strategies. You can specify what you want to randomize.

  • Periods
  • シフト
  • Constants
  • Other Params
  • Exit Used
  • Exit Unused
  • Boolean
  • Trading Options

This test significantly improves your ability to test strategies and. My typical workflow includes several steps for using these tests.

  1. I randomize the periods of the indicators.
  2. I randomize the exit used – stop loss and profit targets.
  3. I randomize the constants. 
  4. …

 

Most strategies include an indicator with a Period type parameter (for example, Moving Average  has a period of 20).This is the first one in which I determine whether the strategy is not overoptimized at the Period level. Then I randomize the parameters of a type: Exit Used (stop loss and profit targets). In the case of shifts, If you are testing Shift type parameter , use maximum change values of 100 or greater. The maximum change of 100 or more indicates that the shift can move down or up by 100% or more (from 1 to 2).

The symmetry of the parameters (the same parameters apply to both long and short trades) can also be set. By default, this parameter is set to True.

 

Monte Carlo Randomize SWAP of a whole backtest 

A SWAP is the interest fee or credit that is applied to a trader’s account when they hold a position overnight in forex or CFD trading. This fee is determined by the interest rate differential between the two currencies in a forex pair or the cost of maintaining a position in CFDs. It can be either positive (a credit) or negative (a debit) depending on the direction of the trade and the interest rate differential.

 

If we apply this Monte Carlo test, each backtest will contain swap values that are randomly generated within the range [-Range,Range].Simply said, by doing 500 (or a different number) backtests with randomly generated swaps, you can acquire a Monte Carlo analysis perspective on the altering of the Swaps. 

In this particular example, we have run 100 simulations with randomised SWAP for every trade.

 

This parameter in the snippet is a subject to randomization:

  • Range: the range within which the swap is selected.

A random number within the range of -20 to 20 is generated when Range = 20 is selected. The second random number will be negative if the first one is positive. This will ensure that we consistently specify both positive and negative spread.

The following parameters are fixed and not subject to randomization:

  • Swap Type – Method of swap calculation ( points, money, percentages) 
  • Tripple Swap The day when a triple swap is applied 
  • Hour during which the swap is counted

先ほど述べた各パラメータを変更することが可能です。.

 

Monte Carlo Randomize SWAP of every trade 

In this particular example, we have run 100 simulations with randomised SWAP for every trade.

 

This test differs from the previous one in that it randomizes each trade in the current backtest. The initial trade may involve a positive long swap and a negative short swap, while the subsequent trades may have swap combinations that are entirely distinct. Therefore, this test implements a random swap for each trade. If the number of Monte Varlo simulations is set to 500, there will be 500 existing backtests, each of which has a unique swap.

The performance of the strategy in the presence of changing interest rates that influence the size of swaps should be simulated by both of these tests.

 

Fixed proportional position sizing.

Fixed proportional position sizing is a money management snippet that enables you to connect the fixed size of lot contracts with a specific proportion of the balance. This enables a more effective adaptation to the balance’s increase or decrease during backtests.

The example above illustrates the increasing equity/balance curve and the increasing number of lots traded in each trade.

 

Example of Fixed Proportional Sizing in Futures

The strategy with Fixed Money proportional sizing trades one micro Nasdaq contract for every 2000 balance. If the balance is 4000, the strategy will trade two microcontracts.

Example of Fixed Proportional Sizing in Forex

I have a balance of 2000 and would like to trade every 500 0.01 lots. In this case, I’ll trade 0.04 lots and have between $2000 and $2500 in my account. If my balance reaches 2501, I’ll trade 0.05 lot.

Paramaters 

  • Order Size per per balance proportion
  • Proportion of the balance
  • Mininmum  Order Size

Money management is implemented for platforms Metatrader 4, Metatrader 5, Tradestation, and Multicharts.

 

上昇中/下降中カスタムブロック 

StrategyQuant Xにおいて、アルゴリズム取引戦略の柔軟性を最大限に高めるためには、カスタムブロックが不可欠です。これにより、ユーザーはプラットフォームで利用可能な標準的な指標やアクションに加え、独自の取引ロジックやルールを設定することができます。.

カスタムブロックを使用して、特定の取引戦略に適した独自の条件、シグナル、またはインジケーターを作成することができます。たとえば、相対力指数(RSI)が指定された期間(本数)にわたって所定の閾値を超えているかどうかを判断するカスタムブロックを作成することが可能です。これにより、ユーザーは、特定の市場状況に対して戦略が経時的にどのように反応するかを制御できるようになります。 

偽のブレイクアウトの検出、連続した価格変動、あるいは複数の比較を伴うカスタマイズされた条件といった高度なロジックも、カスタムブロックに組み込むことができます。これらのブロックは、Algo Wizardで設定したり、StrategyQuantのBuilder内や戦略テンプレート内で直接利用したりすることができます。.

isRising/isFallingカスタムブロックのロジックにより、カスタマイズの可能性が広がりました。これらはデフォルトのものよりも正確にパラメータ化されており、上昇または下降の持続時間を2本以上のバーで設定・最適化できます。.

In this example we can see that custom block Is Rising BarRange can be optimized from 2 – 24 bars.

 合計54個の新しいカスタムブロックがあります。.

 

You can download all of the snippets in codebase ここ.

 

 

クローネックス / イヴァン・フーデツ

イヴァン・フデツ — フォーラム上の「クロネックス」

私は15年間トレードを続けており、2014年からStrategyQuant Xを活用してシステムを構築しています。 現在は主に3つの活動を行っています。自動取引戦略の開発と実戦テスト、SQX本体をカスタムインジケーターやスニペット、機械学習やクオンツ研究のためのPythonツールで拡張すること、そして他のトレーダーが、私がこれまで経験してきたような長年にわたる高価な失敗をせずに、より早く目標に到達できるよう支援することです。.
ほとんどのリテール向け戦略はバックテストでは素晴らしく見えても、実運用では崩壊します。私の仕事はその逆です。すなわち、誠実で、検証済みであり、リアルマネーを託せるほど頑健な戦略です。そのプロセスにおける良い点、醜い点、そして誰も語らない過剰適合について、私のサイト(algotrading.space)で書いています。.
バリデーションやカスタムSQXの開発、データとコードを活用した本当のエッジ構築についてさらに深く掘り下げたい場合は、そこでそのすべてを共有しています。.  www.algotrading.space

1 コメント
最古の
最新 最も投票された
Chris G
Chris G
2. 10. 2024 2:59 am

This is incredible, the Montecarlo in detail is always needed!!!

続きを読む