avatar殷琦

Free AI web copilot to create summaries, insights and extended knowledge, download it at here

6094

Abstract

nge(len(<span class="hljs-class"><span class="hljs-keyword">data</span>)):</span>

        try:
            
            <span class="hljs-class"><span class="hljs-keyword">data</span>[i, where] = (<span class="hljs-title">data</span>[<span class="hljs-title">i</span> - <span class="hljs-title">lookback</span> + 1:<span class="hljs-title">i</span> + 1, <span class="hljs-title">close</span>].<span class="hljs-title">mean</span>())</span>
        
        except <span class="hljs-type">IndexError</span>:
            
            pass
        
<span class="hljs-class"><span class="hljs-keyword">data</span> = jump(<span class="hljs-title">data</span>, <span class="hljs-title">lookback</span>)</span>

return <span class="hljs-class"><span class="hljs-keyword">data</span></span></pre></div><div id="0f03"><pre><span class="hljs-attribute">def</span> demarker(Data, lookback, high, low, where):

<span class="hljs-comment"># Calculating DeMAX</span>
<span class="hljs-attribute">for</span> i in range(len(Data)):
    
    <span class="hljs-attribute">if</span> Data[i, high] &gt; Data[i - <span class="hljs-number">1</span>, high]:
        <span class="hljs-attribute">Data</span>[i, where] = Data[i, high] - Data[i - <span class="hljs-number">1</span>, high]
    <span class="hljs-attribute">else</span>:
        <span class="hljs-attribute">Data</span>[i, where] = <span class="hljs-number">0</span>

<span class="hljs-comment"># Calculating the Moving Average on DeMAX</span>
<span class="hljs-attribute">Data</span> = ma(Data, lookback, where, where + <span class="hljs-number">1</span>)        
        
<span class="hljs-comment"># Calculating DeMIN</span>
<span class="hljs-attribute">for</span> i in range(len(Data)):
    
    <span class="hljs-attribute">if</span> Data[i - <span class="hljs-number">1</span>, low] &gt; Data[i, low]:
        <span class="hljs-attribute">Data</span>[i, where + <span class="hljs-number">2</span>] = Data[i - <span class="hljs-number">1</span>, low] - Data[i, low]
    <span class="hljs-attribute">else</span>:
        <span class="hljs-attribute">Data</span>[i, where + <span class="hljs-number">2</span>] = <span class="hljs-number">0</span>    

<span class="hljs-comment"># Calculating the Moving Average on DeMIN</span>
<span class="hljs-attribute">Data</span> = ma(Data, lookback, where + <span class="hljs-number">2</span>, where + <span class="hljs-number">3</span>)        


<span class="hljs-comment"># Calculating DeMarker</span>
<span class="hljs-attribute">for</span> i in range(len(Data)):
    
    <span class="hljs-attribute">Data</span>[i, where + <span class="hljs-number">4</span>] = Data[i, where + <span class="hljs-number">1</span>] / (Data[i, where + <span class="hljs-number">1</span>] + Data[i, where + <span class="hljs-number">3</span>]) 

<span class="hljs-comment"># Removing Excess Columns</span>
<span class="hljs-attribute">Data</span> = deleter(Data, where, <span class="hljs-number">4</span>)

<span class="hljs-attribute">return</span> Data</pre></div><figure id="a207"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*Hzlb4TnTDcvH3sxeXwjTUQ.png"><figcaption><b>EURUSD in the first panel with the 21-period Demarker in the second panel.</b></figcaption></figure><p id="9cfd">Check out my weekly market sentiment report to understand the current positioning and to estimate the future direction of several major markets through complex and simple models working side by side. Find out more about the report through this link:</p><div id="7415" class="link-block">
      <a href="https://coalescence.substack.com/">
        <div>
          <div>
            <h2>Coalescence</h2>
            <div><h3>A Weekly Report Covering FX &amp; Equities Market Positioning Using Complex Models. Let me read it first This site requires…</h3></div>
            <div><p>coalescence.substack.com</p></div>
          </div>
          <div>
            <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/0*7zo8Jv6sfnts5WCL)"></div>
          </div>
        </div>
      </a>
    </div><h1 id="8210">Using the Demarker</h1><p id="0df8">I am not a strong believer in the 0.30/0.70 overbought/oversold levels as I prefer to widen them a little bit to at least 0.20/0.80. Therefore, when we see the signals on the chart following the 0.20/0.80 rule, we can get something like the below plot.</p><ul><li><b>A long (Buy) signal is generated whenever the Demarker reaches 0.20 with the previous value above 0.20.</b></li><li><b>A short (Sell) signal is generated whenever the Demarker reaches 0.80 with the previous value below 0.80.</b></li></ul><div id="ff6e"><pre><span class="hljs-keyword">def</span> <span class="hljs-title function_">signal</span>(<span class="hljs-params"><span class="hljs-title class_">Data</span>, what, buy, sell</span>)<span class="hljs-symbol">:</span></pre></div><div id="0e12"><pre><span class="hljs-type">Data</span> = adder(<span class="hljs-type">Data</span>, <span class="hljs-number">10</span>)</pre></div><div id="4a8f"><pre><span class="hljs-symbol">for</span> i in range(len(<span class="hljs-meta">Data</span>)):
        
    <span class="hljs-meta">if</span> <span class="hljs-meta">Data</span>[i, what] &lt; lower_barrier <span class="hljs-keyword">and</span> <span class="hljs-meta">Data</span>[i - <span class="hljs-number">1</span>, what] &gt; lower_barrier:
        <span class="hljs-meta">Data</span>[i + <span class="hljs-number">1</span>, buy] = <span class="hljs-number">1</span>
        
    <span class="hljs-meta">if</span> <span class="hljs-meta">Data</span>[i, what] &gt; upper_barrier <span class="hljs-keyword">and</span> <span class="hljs-meta">Data</span>[i - <span class="hljs-number">1</span>, what] &lt; upper_barrier:
        <span class="hljs-meta">Data</span>[i + <

Options

span class="hljs-number">1</span>, sell] = -<span class="hljs-number">1</span>

return <span class="hljs-meta">Data</span></pre></div><figure id="7ee7"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*Vwt17ycpypw7FqWrOQ2urQ.png"><figcaption><b>Signal chart.</b></figcaption></figure><p id="251c">Another strategy can be created which states that only the exit of the extreme zones will yield a trade:</p><ul><li><b>A long (Buy) signal is generated whenever the Demarker exits 0.20 with the previous value below 0.20.</b></li><li><b>A short (Sell) signal is generated whenever the Demarker exits 0.80 with the previous value above 0.80.</b></li></ul><div id="47c0"><pre><span class="hljs-keyword">def</span> <span class="hljs-title function_">signal</span>(<span class="hljs-params"><span class="hljs-title class_">Data</span>, what, buy, sell</span>)<span class="hljs-symbol">:</span></pre></div><div id="2fa6"><pre><span class="hljs-type">Data</span> = adder(<span class="hljs-type">Data</span>, <span class="hljs-number">10</span>)</pre></div><div id="f24b"><pre><span class="hljs-symbol">for</span> i in range(len(<span class="hljs-meta">Data</span>)):
        
    <span class="hljs-meta">if</span> <span class="hljs-meta">Data</span>[i, what] &gt; lower_barrier <span class="hljs-keyword">and</span> <span class="hljs-meta">Data</span>[i - <span class="hljs-number">1</span>, what] &lt; lower_barrier:
        <span class="hljs-meta">Data</span>[i + <span class="hljs-number">1</span>, buy] = <span class="hljs-number">1</span>
        
    <span class="hljs-meta">if</span> <span class="hljs-meta">Data</span>[i, what] &lt; upper_barrier <span class="hljs-keyword">and</span> <span class="hljs-meta">Data</span>[i - <span class="hljs-number">1</span>, what] &gt; upper_barrier:
        <span class="hljs-meta">Data</span>[i + <span class="hljs-number">1</span>, sell] = -<span class="hljs-number">1</span>
        
return <span class="hljs-meta">Data</span></pre></div><figure id="2c88"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*_4OQFQtIqhz1AfcsJcXosg.png"><figcaption><b>Signal chart.</b></figcaption></figure><p id="d761">The second technique of waiting before initiating the position showed slightly better results but not statistically different. In anyways, both are losing strategies with the second one losing less (0.94 profit factor compared to 0.96).</p><p id="3618">I have recently partnered with Lumiwealth, and if you want to see how to create all sorts of algorithms yourself, feel free to check out the below link. From algorithmic trading to blockchain and machine learning, they have hands-on detailed courses that I highly recommend.</p><div id="fead" class="link-block">
      <a href="https://www.lumiwealth.com/algorithmic-trading-landing-page/?utm_source=influence&amp;utm_medium=medium&amp;utm_campaign=sofien">
        <div>
          <div>
            <h2>Learn Algorithmic Trading with Python Lumiwealth</h2>
            <div><h3>undefined</h3></div>
            <div><p>undefined</p></div>
          </div>
          <div>
            <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/0*FbCz_ARtbOdywMlC)"></div>
          </div>
        </div>
      </a>
    </div><h1 id="e420">Summary</h1><p id="05a4">To sum up, what I am trying to do is to simply contribute to the world of objective technical analysis which is promoting more transparent techniques and strategies that need to be back-tested before being implemented. This way, technical analysis will get rid of the bad reputation of being subjective and scientifically unfounded.</p><p id="570c">Medium is a hub to interesting reads. I read a lot of articles before I decided to start writing. Consider joining Medium using my referral link (at <b>NO </b>additional cost to you).</p><div id="de8c" class="link-block">
      <a href="https://kaabar-sofien.medium.com/membership">
        <div>
          <div>
            <h2>Join Medium with my referral link — Sofien Kaabar</h2>
            <div><h3>As a Medium member, a portion of your membership fee goes to writers you read, and you get full access to every story…</h3></div>
            <div><p>kaabar-sofien.medium.com</p></div>
          </div>
          <div>
            <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/0*XBqK-oHjNF_4ydU8)"></div>
          </div>
        </div>
      </a>
    </div><p id="5d41">I recommend you always follow the the below steps whenever you come across a trading technique or strategy:</p><ul><li>Have a critical mindset and get rid of any emotions.</li><li>Back-test it using real life simulation and conditions.</li><li>If you find potential, try optimizing it and running a forward test.</li><li>Always include transaction costs and any slippage simulation in your tests.</li><li>Always include risk management and position sizing in your tests.</li></ul><p id="beb3">Finally, even after making sure of the above, stay careful and monitor the strategy because market dynamics may shift and make the strategy unprofitable.</p><p id="4f75">For the paperback link of the book, you may use the following link:</p><div id="355f" class="link-block">
      <a href="https://www.amazon.com/dp/B09VG3SH2P?&amp;linkCode=sl1&amp;tag=sofien-20&amp;linkId=f0daa140733c5f6b08c1e744bd1b98b5&amp;language=en_US&amp;ref_=as_li_ss_tl">
        <div>
          <div>
            <h2>Contrarian Trading Strategies in Python</h2>
            <div><h3>Amazon.com: Contrarian Trading Strategies in Python: 9798434008075: Kaabar, Sofien: Books</h3></div>
            <div><p>www.amazon.co</p></div>
          </div>
          <div>
            <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/0*C7k3f3kawsSsQCVn)"></div>
          </div>
        </div>
      </a>
    </div></article></body>

香港流行音樂樂譜名單

22/10/2020 Juno, 謝安琪:羅生門 27/10/2020 Supper Moment:幸福之歌 25/8/2021 One Promise:明年見 14/12/2021 MIRROR@姜濤:Dear My Friend 14/12/2021 周國賢:塵世美 14/12/2021 鄭秀文:如何掉眼淚 7/2/2022 C All Star:留下來的人 7/2/2022 MC張天賦:記憶棉 8/2/2022 林家謙:一人之境 11/2/2022 柳應廷:人類群星閃耀時 23/5/2022 周國賢:身後身 23/5/2022 MIRROR@AK: 黑之呼吸 1/6/2022 MIRROR@姜濤:作品的說話 4/6/2022: MIRROR@EdanX邱鋒澤:一表人才 22/6/2022: 葉巧琳:原來我還未夠難

Recommended from ReadMedium