Algoritma dan Strategi Forex Mekanikal | OneStepRemoved

  • Articles
  • Sophisticated Web Sites
  • Dagangan automatik
  • Testimonial
  • Hubungi

One line of code makes all the difference

Februari 9, 2017 oleh Shaun Overton 4 Komen

I was really excited about my Pilum strategy two months ago. The research looked great and everything was ready to rock and roll. Demo testing began and then… not much happened.

The Quantilator is (mostly) finished, which finally gave me time to circle back and review what happened with Pilum.

Live demo trading of Pilum

Live demo trading of Pilum. Disember 9, 2016 to Feb 7, 2017

The expected outcome was that I would win 75% masa. Trades were infrequent, so I thought maybe I’m just having bad luck. But then my win rate remained stuck around 50%. Simple statistical tests told me this was unlikely to be bad luck.

I used the research time to pour over my research code and to compare it with live trades. What I found was that a single line of code (AHHHHHHHHHHHHHHH!) was incorrectly calculating my entry price, dramatically overstating the profits.

Yang flawed code produced this equity curve from a single combination of settings:
Flawed Pilum backtest

When the actual, correct result looks like this with those same settings:

The accurate backtest of Pilum

The accurate backtest of Pilum

I’ll be honest… I like the flawed backtest a lot more!

The new, single-setting backtest isn’t as good, but it’s still trade-worthy. There are some characteristics that I dislike and features that I love. Let’s dig into those.

What I dislike

The frequency of trades is very low. Out of 19 months there were a total of 43 dagangan. 43 trades to comprise a backtest on 40+ instruments is a very small number.

If it weren’t for the statistical pattern backing up the frequency, I would not consider the test. Walau bagaimanapun, there are 20,000 bars each on the 44 instruments. Ada 880,000 total bars used to analyze whether my Pilum pattern offers any predictive value.

The most valuable predictions, Walau bagaimanapun, are also exceptionally rare. That’s why I’m not able to get the trading frequency higher, which would potentially smooth the returns.

What I love

My previous systems like QB Pro and Dominari traded actively for relatively small wins. Trading costs exercised a massive impact on the overall performance.

The accurate backtest of Pilum

The accurate backtest of Pilum

Now look again at the correct equity curve (the image to the right). Do you see the final profit of roughly 0.14? That’s a 14% unleveraged return over a 19 tempoh bulan.

Allocating 2:1 atau 3:1 leverage on this strategy could average annual returns of 15-25%.

Detecting hidden risk

A key measure of risk is skewness. You may not use that term yourself, but it’s something most of you already understand. The biggest complaint about people trading Dominari was that the average winner relative to the average loser was heavily skewed towards the losers.

Dominari wins on most months, but when it lost in December it was devastating. I implemented what I thought was a portfolio stop after the December 9th aftermath. Then I had a smaller, but still very painful, loss in January. The portfolio level stop loss of 3% should prevent future blowouts now that I know what goes wrong.

I still believe in Dominari. Tetapi, I obviously lost the work of most of the year due to those events.

Knowing that skewness is a good measure of blowout risk (even if you’ve never seen it in a backtest, like happened with Dominari), Pilum looks extremely encouraging.

This is a histogram of profit and loss by days. You should notice a few things.

The tallest bar is to the right of 0. That means that the most frequent outcome is winning.

worst and best days

The biggest winning day is dramatically better than the worst losing day. The worst outcome was a loss of 2%. The best outcome is gains near 10% dalam satu hari (unleveraged!).

This is the statistical profile of an idea that’s much more likely to grab an avalanche of profits than it is to get blown out.

It gets even better

low correlation

Would you say that the blue and red equity curves are highly or loosely correlated? Look closely.

Writing this blog post made me think carefully about the Pilum strategy. I decided that maybe I should see if all of the profits are coming from different settings at the same time. There’s very little risk of overfitting the data as my strategy only has 1 degree of freedom.

The blue bars are the equity curve of Setting 1.

The red bars are for Setting 2.

Do you think these are tightly or loosely correlated?

If you said loosely correlated, then you are correct. Notice how each equity curve shows large jumps of profit. Did you notice how those profit jumps occur on different days?

The blue setting skyrockets on a single day in November 2016. It leaves the red equity curve choking in its dust.

Tetapi kemudian, look what happens as I advance into December. The red curve dramatically catches up to the blue curve and even overtakes it.

The correlation between the 2 strategies is only 57%.

Combine multiple settings into 1 portfolio

Combined settings Pilum equity curve

This is a much nicer equity curve!

Loose correlations are a GIFT. Combining two bumpy equity curves into a single strategy makes the performance much, much smoother.

The percentages of days that are profitable also increases. Setting 1 is profitable on 58.0% of days. Setting 2 is profitable on 53.5% of days.

Tetapi… combining them makes Pilum profitable on 68.2% of days. Menggerunkan!

That also provides more data, which puts me in a stronger position to analyze the strategy’s skewness. Look at the frequency histograms below. They’re the same type of histograms that I showed you in the first section of this blog post. As you’ll notice, they look a lot different.

Pilum most probable daily profit and loss

The most probable outcome for any given day is a small winner

The tall green bar is the most probable trading outcome for any given day with filled orders. The average day is a positive return of 0-1%.

The small red bar is the worst trading day of the combined strategy.

The small green bars are the best trading days of the combined strategy.

Look how far to the right the green bars go. The largest winner is more than 3x the biggest loss. Dan, there are so many more large winners compared to losers.

Giant winners are far more likely than comparable losses.

The Plan

I immediately pushed Pilum into live trading this combination of two strategies. I expect that adding a second degree of freedom and running about 30 different versions of the strategy – all with different settings – will add to the performance and smooth the returns even further.

Dominari hasn’t been working on my FXCM account, which is very difficult to accept because the lacking performance seems to be a buried execution issue. Pilum, Walau bagaimanapun, trades very infrequently. It’s unlikely that execution quality will make a dramatic difference in the long term outcomes.

Jadi, I’m going to convert the FXCM account to trading Pilum exclusively. That will be offered as a strategy on Collective2 within the next few weeks, a company with whom I’ve been working closely. Their users are more investor rather than trading oriented – they’re far more likely to view low trading frequency as a good thing. I suspect that most people here have a different opinion and want to see a lot of market action.

I’ll write an update on Dominari shortly.

Filed Under: Pilum, Idea strategi perdagangan Tagged With: korelasi, lengkung sesuai, darjah kebebasan, Peraturan, lengkung ekuiti, kekerapan, FXCM, histogram, leverage, QB Pro, risiko, skew, Statistik

How badly do I want in?

Mac 22, 2016 oleh Shaun Overton 10 Komen

You absolutely must check your trading system’s performance on a regular basis. You’re going to miss most of the problems from watching your equity curve alone.

That almost happened to me a few weeks ago. When I observed my account, I noticed that the real results had dramatically underperformed the hypothetical results. A quick review showed me that I only took 271 trades over the prior week, whereas my backtest expected to find 360.

I was only trading 75% of the setups! What could explain the missing trades?

Finding the flaw

One feature that I wrote into the MetaTrader version of the Dominari was a maximum spread feature. I’m paying commissions, so the idea of the rare but possible scenario of paying a 10 pip spread to enter a trade seemed intolerable. I added a maximum spread feature to prevent getting ripped off.

I also didn’t put much thought into what happens if the spread is too wide. My initial instinct was to put the EA into hibernation for a few seconds. It would then wake up and check the spread. If the spread narrowed enough, it would send a market order. But in my haste to start trading, I forgot to also require that the price be near my original requested price. That design would have allowed the market to drift up 10 pips and then, if the spread narrowed, dramatically overpay to get in the trade.

The new method for capping the spread paid uses limit orders if the spread is too wide. The advantage to this method is that it solves two simultaneous problems. The first one is easy to understand. A limit order has a limited price. It’s not possible for the price drift described in the above paragraph to occur. I either get the price I want or the market moves without me and I miss the trade.

Equity curve since I made the execution changes on March 16.

Equity curve since I made the execution changes on March 16.

The second advantage to using limit orders on entry is the fact that a limit order rests on the broker’s server. The hibernating method could potentially miss fractions of a second where the spread temporarily narrows to an acceptable price. Limit orders catch all price quotes, improving my theoretical likelihood of a fill.

Reality proved the theory after a week of trading. Instead of taking 75% of all possible signals, I’m now taking 87.5% of signals. That’s a result of the new limit method and my willingness to pay a wider spread to enter a trade.

More improvement

The question at the top of my mind was, “Should I be willing to pay even more to enter these trades?” Like a good quant, I immediately decided to calculate the question instead of haphazardly guessing.

I wrote a script in MetaTrader to search for every limit order in my account which was cancelled. I then looked at what the hypothetical performance of those trades would have been if I had simply paid the exorbitant spread.

It turns out that I should be willing to pay a lot more money to enter these trades.

There have been 50 cancelled limit orders within the past week, 44 of which were theoretically profitable. The average theoretical profit per trade was €1.28 compared to €0.33 for all executed trades. That’s a massive 287% difference in profitability!

The other shocker was the percent accuracy. 44 daripada 50 implies an accuracy of 88%, berbanding dengan 64% accuracy on executed trades. 50 signals isn’t a lot. Am I getting too excited about missed profits or is that bad luck?

Basic statistics gives an answer with a high degree of precision. If the real accuracy is 64%, then you would expect to see 50 * 0.64 = 32 winning trades in a random sampling. My observed, theoretical accuracy with these limit orders was 44 orders out of 50, yang 88% tepat.

It turns out that I should be willing to pay a lot more money to enter these trades.

Yang sisihan piawai untuk 64% accuracy on 50 orders is 0.48, which we can then use to calculate the standard error. The standard error on 50 orders is sqrt(50) * 0.48 = 3.42 pesanan.

And finally, the standard error gives us enough information to compute the z-score. The z-score is the observed values-expected values/standard error, yang (44-32) / 3.42 = 3.5. A z-skor daripada 3.5 has a probability of 0.000233 occurring due to random chance, or about 1 dalam 4,299 ujian.

Kesimpulan: The statistics say with high confidence that my non-executed orders are substantially more accurate than my executed orders.

With the orders being both more accurate and having a higher per trade value, I increased the maximum spread that I’m willing to pay by 53%. While that sounds oddly precise, the per trade value might be substantially overestimated. I ball parked a guess that paying 40% in trade costs for a high quality trade seems reasonable. That number may have to go higher in order for me to measure the details.

Ideas for exploration

The amazing extrapolation from the live order analysis is that the spread seems to predict my likelihood of success. Wider spreads make me more likely to succeed and with a better risk:reward ratio. My project over the next few days will be to start logging my spreads at signal generation time to evaluate whether the spread predicts the profitability of my signals.

Cukup aneh, there might even be a paradoxical outcome where narrow spreads predict my failure. More on that when I have enough data to answer the question.

Filed Under: Peraturan Tagged With: execution, had, quant, gelinciran, sisihan piawai, standard error, Statistik, Z-skor

Rawak Trailing Had

Mac 12, 2012 oleh Shaun Overton 14 Komen

Saya mendapat idea untuk had trailing dari Van Tharpe ini pasaran klasik Berdagang Way Anda untuk Kebebasan Kewangan. Saya membuat Jon Rackley membaca buku ini sebagai sebahagian daripada latihan beliau apabila saya mula-mula dia mengupah. Beliau menarik perhatian saya kepada tuntutan yang luar biasa yang dibuat pada halaman 267. Van Tharpe mengatakan bahawa ia sering mungkin untuk membuat wang walaupun dengan nombor rawak.

Nombor rawak adalah teori haiwan kesayangan saya. Saya telah lama meletakkan usaha ke dalam memikirkan sama ada saya boleh membangunkan strategi yang tersenarai sama sekali secara rawak dan masih membuat wang. Sebagai pemilik sebuah syarikat pengaturcaraan untuk peniaga-peniaga, dan sebagai sebahagian daripada latihan awal Jon kerana NinjaTrader pada bulan Disember, Saya ditugaskan kepadanya tugas pengaturcaraan strategi kepada kod.

Buku ini menyatakan bahawa perdagangan dengan penyertaan betul-betul rambang dan 3 ATR trailing stop secara amnya membawa kepada membuat wang. Flip duit syiling. Anda pergi lama jika ia mendarat di kepala. Pergi pendek jika tanah ekor. Satu nota penting ialah kami memilih untuk menggunakan nombor rawak tulen dalam pengaturcaraan kita dan bukannya nombor pseudo-rawak yang komputer menjana. Berbuat demikian membolehkan kita untuk mengelakkan berat sebelah semasa proses pembenihan yang biasanya muncul apabila benih yang digunakan adalah berhampiran bersama-sama dalam masa.

Versi kerja pertama yang saya semula dipaparkan segala yang bertentangan dengan tuntutan Van Tharpe ini. Menggunakan berhenti mengekori, tanpa mengira rangka instrumen dan masa yang diuji, tidak dapat tidak membawa kepada kerugian dahsyat. Faktor-faktor keuntungan secara konsisten datang berhampiran 0.7, beberapa benar-benar mengerikan.

Kami melakukan apa yang kebanyakan pelanggan kami lakukan apabila mereka mendapati strategi yg berkeras. Kami dibalik strategi di kepala. Strategi baru menggunakan hanya satu 3 ATR (50 tempoh) had trailing.

Trailing Analisis Had

Kesimpulan awal ialah had trailing seolah-olah menawarkan banyak potensi. Walaupun Jon menghantar saya kod di beberapa bulan yang lalu, ia hanya malam ini bahawa saya mempunyai peluang untuk mengkaji semula dengan betul dan menguji semua.

Faktor-faktor keuntungan adalah amat menggalakkan. Ia bergantung pada carta yang saya diuji. Yang paling buruk yang saya dapati adalah 1.0 faktor keuntungan. Semua yang lain keluar dengan faktor keuntungan lebih besar daripada 1. Jadual kecil di bawah mengandungi keputusan ujian awal. Sebelum anda pergi salivating bahawa ini adalah pemenang panas seterusnya, terdapat beberapa pertimbangan yang perlu diingat:

  1. Keputusan bergantung sepenuhnya kepada urutan nombor rawak digunakan. Menggunakan set nombor rawak akan menyebabkan hasil yang berbeza.
  2. Keputusan yang lebih baik pada masa yang lebih tinggi bingkai hasil mungkin dari ralat pensampelan. Jumlah dagangan terlibat hanya ~ 160, yang tidak cukup untuk membuat kesimpulan muktamad mengenai sifat prestasi. Saya lebih suka melihat 400 atau lebih perdagangan sebelum membuat kesimpulan muktamad.
  3. Keputusan ini tidak termasuk penyebaran kos atau komisen.
Mata WangTempohFaktor keuntunganTarikh Diuji
EURUSDM11.129/12/2011-3/12/2012
GBPUSDM11.169/12/2011-3/12/2012
USDJPYM11.259/12/2011-3/12/2012
EURUSDM51.112011
GBPUSDM51.02011
USDJPYM51.062011
EURUSDH11.262011
GBPUSDH11.252011
USDJPYH11.482011
Random trades sometimes produce solid looking equity curves

Perdagangan rawak kadang-kadang menghasilkan lengkung ekuiti pepejal mencari. Ingat bahawa ini telah dijana dengan nombor semata-mata rawak dan had trailing

Apa yang membuatkan saya berasa lebih baik mengenai keputusan telah mengkaji masuk dan keluar kecekapan setiap strategi. Bilangan perdagangan yang terlibat benar-benar berantakan grafik. Saya berlari Backtest pada tempoh masa yang lebih singkat supaya mendatar, garis biru akan kelihatan dengan jelas pada setiap graf.

The entry efficiency of a random entry is... random

The entry efficiency of a random entry is… rawak (45.45% kecekapan masuk)

The exit efficiencies of random entries with traililng limits are outstanding

Kecekapan keluar entri rawak dengan had trailing dimatikan carta. (77.73% kecekapan keluar)

Kecekapan kemasukan memberitahu kita apa yang kita inginkan untuk mencari. Sekerja yang memasukkan secara rawak tidak melakukan lebih baik daripada rawak (jelas). Apa yang menarik ialah bagaimana had strategi keluar belakang sebenarnya skews kecekapan masuk untuk membaca sedikit lebih buruk daripada rawak. Ini adalah satu contoh yang baik mengapa ia berbahaya untuk bergantung semata-mata kepada statistik. Menyimpan gambar yang besar dalam fikiran mengurangkan kemungkinan membuat kesimpulan yang salah, dalam kes ini bahawa mungkin ada sesuatu “salah” dengan penyertaan sempurna rawak kami.

Strategi keluar, iaitu apa yang kita benar-benar ujian, kelihatan benar-benar cemerlang. Ini menunjukkan bahawa yang bertindak sebagai kebarangkalian bersyarat membolehkan banyak pergerakan buruk manakala menangkap mata melampau langkah.

Menambah Pengurusan Wang

Peratusan pemenang untuk carta diuji antara 60-67% ketepatan. Peratusan yang tinggi pemenang sering membawa kepada jalur-jalur kemenangan. Pandangan sepintas saya melalui carta menyebabkan saya mudah mencari contoh yang sesuai untuk pick ceri. Di sini, 5 perdagangan berturut-turut sampai mengambil keuntungan maksimum berhampiran mereka.

Random trades on a hot streak

Memilih perdagangan secara rawak kadang-kadang membawa kepada jalur-jalur pemenang bertuah

Ujian yang saya telah lakukan pada masa lalu memberitahu saya bahawa itu sering berfaedah untuk meningkatkan saiz kedudukan berdasarkan pemenang berturut-turut apabila strategi yang lebih daripada 50% tepat. Idea saya yang pertama selepas menyemak segala keputusan awal untuk mengubah suai dalam pengurusan wang forex strategi untuk mengejar pemenang berturut-turut. Malangnya, kami tidak mempunyai masa untuk perubahan dalam kod sekarang. Hubungi saya jika anda berminat untuk melihat ini dan kami akan menjadikannya keutamaan sekiranya pembaca cukup bertindak balas.

Walaupun peningkatan risiko selepas pemenang berturut-turut bekerja di luar statistik memihak kepada anda, ia menambah risiko. Ia adalah mustahil untuk “memenangi” set urus niaga dagangan untuk mula kehilangan semata-mata berdasarkan strategi pengurusan Wang. Tiada cara untuk mengetahui sama ada anda set perdagangan akan nasib waris risiko tambahan atau sama ada ia akan kalah tidak mungkin.

Kesimpulan

Semua orang bercakap mengenai perhentian. Anda sentiasa perlu mempunyai berhenti. Blah blah blah. Saya tahu ia akan menjadi soalan pertama yang semua orang meminta.

Kajian saya menunjukkan bahawa perdagangan dengan berhenti adalah untuk sulur. Larry Connors’ buku Strategi Trading Jangka Pendek Itu Kerja adalah buku perdagangan pertama di mana saya benar-benar berasa seperti saya membaca maklumat berharga. Salah satu bahagian kegemaran saya adalah pada kerugian berhenti. Kajian beliau menunjukkan bahawa menggunakan stop loss (walaupun 50% menghentikan kerugian) sentiasa mengurangkan prestasi strategi. Analisis bebas saya sendiri menanggung ini keluar.

Tidak menggunakan perhentian tidak bermakna tidak pernah mengambil kerugian. Sebaliknya, enggan keluar dari pasaran rugi membuat untuk 100% kemungkinan meletupkan satu hari. Titik menggunakan berhenti atau had adalah untuk menentukan secara empirik, dan tidak pernah ragu-ragu dari, suatu perkara tertentu atau mata dalam pasaran di mana anda akan keluar. Had Kuasa melakukan ketinggalan matlamat yang mengagumkan.

Menariknya, had trailing adalah satu ciri yang FAP Turbo menggabungkan bahawa saya belum lagi untuk mencari di mana-mana penasihat pakar yang lain. Walaupun saya bukan peminat jenis FAP Turbo strategi, ia pasti tidak menarik minat saya bahawa salah satu ciri-ciri utamanya menyelaraskan dengan penyelidikan ini. Juga diperhatikan adalah fakta bahawa had belakang terus ke bawah hingga ke tahap di mana ia menerima kerugian.

Filed Under: NinjaTrader Tips, Menguji konsep anda sejarah, Idea strategi perdagangan Tagged With: ATR, faktor keuntungan, rawak, Statistik, had trailing, trailing berhenti, Daripada Tharpe

Strategi perdagangan PERCUMA melalui e-mel

Tren

Maaf. Tiada data setakat.

Arkib

  • Peraturan
  • Bagaimana untuk kerja pasaran tukaran mata wang asing?
  • Petunjuk
  • MetaTrader Tips
  • MQL (untuk nerds)
  • NinjaTrader Tips
  • Pilum
  • QB Pro
  • Hentikan kehilangan wang
  • Menguji konsep anda sejarah
  • Idea strategi perdagangan
  • Uncategorized
  • Apa yang sedang berlaku di pasaran semasa?

Terjemahan


Strategi Trading Percuma

Dasar PrivasiRisk Disclosure

Hak cipta © 2023 OneStepRemoved.com, Inc. Hak Cipta Terpelihara.