avatarJ. Angelo Racoma N2RAC/DU2XXR

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

7423

Abstract

o lower. One should always remember that this indicator is very lagging and therefore has to be used with extreme caution.</p><p id="a101">Since it has been created by Wilder Wiles, also the creator of the Relative Strength Index, it uses Wilder’s own type of moving average, the smoothed kind. To simplify things, the smoothed moving average can be found through a simple transformation of the exponential moving average.</p><figure id="ef99"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/0*kcMsTOLJ3uJyUeN_.png"><figcaption></figcaption></figure><p id="485e">The above formula means that a 100 smoothed moving average is the same thing as (100 x 2) -1 = 199 exponential moving average. While we are on that, we can code the exponential moving average using this function:</p><div id="b794"><pre><span class="hljs-keyword">def</span> <span class="hljs-title function_">ma</span>(<span class="hljs-params">Data, lookback, what, where</span>):

<span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-built_in">len</span>(Data)):
  <span class="hljs-keyword">try</span>:
    Data[i, where] = (Data[i - lookback + <span class="hljs-number">1</span>:i + <span class="hljs-number">1</span>, what].mean())
    
        <span class="hljs-keyword">except</span> IndexError:
            <span class="hljs-keyword">pass</span>
<span class="hljs-keyword">return</span> Data</pre></div><div id="7a41"><pre>def ema(Data, alpha, lookback, what, <span class="hljs-built_in">where</span>):

<span class="hljs-comment"># alpha is the smoothing factor</span>
<span class="hljs-comment"># window is the lookback period</span>
<span class="hljs-comment"># what is the column that needs to have its average calculated</span>
<span class="hljs-comment"># where is where to put the exponential moving average</span>

alpha = alpha / (lookback + 1.0)
beta  = 1 - alpha

<span class="hljs-comment"># First value is a simple SMA</span>
Data = ma(Data, lookback, what, <span class="hljs-built_in">where</span>)

<span class="hljs-comment"># Calculating first EMA</span>
Data[lookback + 1, <span class="hljs-built_in">where</span>] = (Data[lookback + 1, what] * alpha) + (Data[lookback, <span class="hljs-built_in">where</span>] * beta)</pre></div><div id="3da7"><pre><span class="hljs-comment"># Calculating the rest of EMA</span>
<span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(lookback + <span class="hljs-number">2</span>, <span class="hljs-built_in">len</span>(Data)):
        <span class="hljs-keyword">try</span>:
            Data[i, where] = (Data[i, what] * alpha) + (Data[i - <span class="hljs-number">1</span>, where] * beta)
    
        <span class="hljs-keyword">except</span> IndexError:
            <span class="hljs-keyword">pass</span>
<span class="hljs-keyword">return</span> Data</pre></div><p id="8783">Below is the function code that calculates the ATR.</p><div id="b80a"><pre>def atr(<span class="hljs-keyword">data</span>, lookback, high, low, close, <span class="hljs-keyword">where</span>):

<span class="hljs-keyword">data</span> = adder(<span class="hljs-keyword">data</span>, <span class="hljs-number">1</span>)
  
<span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> range(len(<span class="hljs-keyword">data</span>)):
    
    <span class="hljs-keyword">try</span>:
        
        <span class="hljs-keyword">data</span>[i, <span class="hljs-keyword">where</span>] = max(<span class="hljs-keyword">data</span>[i, high] - <span class="hljs-keyword">data</span>[i, low], abs(<span class="hljs-keyword">data</span>[i, high] - <span class="hljs-keyword">data</span>[i - <span class="hljs-number">1</span>, close]), abs(<span class="hljs-keyword">data</span>[i, low]  - <span class="hljs-keyword">data</span>[i - <span class="hljs-number">1</span>, close]))
        
    except ValueError:
        
        pass
    
<span class="hljs-keyword">data</span>[<span class="hljs-number">0</span>, <span class="hljs-keyword">where</span>] = <span class="hljs-number">0</span>   
  
<span class="hljs-keyword">data</span> = ema(<span class="hljs-keyword">data</span>, <span class="hljs-number">2</span>, (lookback * <span class="hljs-number">2</span>) - <span class="hljs-number">1</span>, <span class="hljs-keyword">where</span>, <span class="hljs-keyword">where</span> + <span class="hljs-number">1</span>)</pre></div><div id="e149"><pre><span class="hljs-keyword">data</span> = deleter(<span class="hljs-keyword">data</span>, <span class="hljs-keyword">where</span>, <span class="hljs-number">1</span>)

<span class="hljs-keyword">data</span> = jump(<span class="hljs-keyword">data</span>, lookback)

<span class="hljs-keyword">return</span> <span class="hljs-keyword">data</span></pre></div><p id="3950">Let us try applying the code on OHLC data and see the plot of a 14-period Average True Range:</p><div id="da61"><pre><span class="hljs-attr">my_data</span> = atr(my_data, <span class="hljs-number">14</span>, <span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>)</pre></div><figure id="8f6c"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/0*AI40oZyZ11lSAGcg.png"><figcaption><b>EURUSD daily values in the first panel with the 14-period Average True Range in the second panel.</b></figcaption></figure><p id="0934">Now we are ready to continue with the choppiness index. Let us consider that we will calculate a 20-period Average True Range on our OHLC historical data:</p><div id="0afd"><pre><span class="hljs-comment"># Adding a few columns</span>

<span class="hljs-attr">my_data</span> = adder(my_data, <span class="hljs-number">10</span>)</pre></div><div id="4e56"><pre><span class="hljs-comment"># Calculating a 20-period ATR</span> <span class="hljs-attr">my_data</span> = atr(my_data, <span class="hljs-number">20</span>, <span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>)</pre></div><p id="fe8e">Now, the first step into the indicator is, to sum up, the values of the ATR together. This intuition can be coded in the following manner (Full function code provided below):</p><div id="d525"><pre><span class="hljs-comment"># Calculating the Sum of ATR's (atr_col is the index where the ATR is stored, in our example, it is 4)</span> <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-built_in">len</span>(my_data)):</pre></div><div id="8d39"><pre>my_data[i, <span class="hljs-built_in">where</span>] = my_data[i - lookback + 1:i + 1, atr_col].<span class="hljs-built_in">sum</span>()</pre></div><p id="f3d8">Now, we have to calculate the range from the highest to lowest using the max() and min() built-in functions. The code should resemble the following:</p><div id="4e6e"><pre><span class="hljs-comment"># Calculating the range</span> <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> <span class="hljs-built_in">ran

Options

ge</span>(<span class="hljs-built_in">len</span>(my_data)): <span class="hljs-keyword">try</span>: my_data[i, <span class="hljs-number">5</span>] = <span class="hljs-built_in">max</span>(my_data[i - lookback + <span class="hljs-number">1</span>:i + <span class="hljs-number">1</span>, <span class="hljs-number">1</span>] - <span class="hljs-built_in">min</span>(my_data[i - lookback + <span class="hljs-number">1</span>:i + <span class="hljs-number">1</span>, <span class="hljs-number">2</span>])) <span class="hljs-keyword">except</span>: <span class="hljs-keyword">pass</span></pre></div><p id="8dd6">Next, we calculate the ratio between the two measures we have just derived. The code can be as simple as:</p><div id="6fde"><pre><span class="hljs-comment"># Calculating the Ratio</span> <span class="hljs-section">my_data[:, 6] = my_data[:, 4] / my_data[:, 5]</span></pre></div><p id="90b7">And finally, we simply apply the function as presented above, using this code:</p><div id="2f0c"><pre># <span class="hljs-function">Calculate the Choppiness Index <span class="hljs-keyword">for</span> i in <span class="hljs-title">range</span><span class="hljs-params">(len(Data))</span>:

Data[i, <span class="hljs-number">7</span>] =</span> <span class="hljs-number">100</span> * np.<span class="hljs-built_in">log</span>(Data[i, <span class="hljs-number">6</span>]) * (<span class="hljs-number">1</span> / np.<span class="hljs-built_in">log</span>(<span class="hljs-number">20</span>))</pre></div><figure id="84eb"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/0*Pdavt5otr708my32.png"><figcaption><b>EURUSD in the first panel with the 20-period Choppiness Index in the second panel.</b></figcaption></figure><div id="a88b"><pre><span class="hljs-keyword">def</span> <span class="hljs-title function_">choppiness_index</span>(<span class="hljs-params">Data, lookback, high, low, where</span>):

<span class="hljs-comment"># Calculating the Sum of ATR's</span>
<span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-built_in">len</span>(Data)):
    Data[i, where] = Data[i - lookback + <span class="hljs-number">1</span>:i + <span class="hljs-number">1</span>, <span class="hljs-number">4</span>].<span class="hljs-built_in">sum</span>()    

<span class="hljs-comment"># Calculating the range</span>
<span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-built_in">len</span>(Data)):
    <span class="hljs-keyword">try</span>:
        Data[i, where + <span class="hljs-number">1</span>] = <span class="hljs-built_in">max</span>(Data[i - lookback + <span class="hljs-number">1</span>:i + <span class="hljs-number">1</span>, <span class="hljs-number">1</span>] - <span class="hljs-built_in">min</span>(Data[i - lookback + <span class="hljs-number">1</span>:i + <span class="hljs-number">1</span>, <span class="hljs-number">2</span>]))
    <span class="hljs-keyword">except</span>:
        <span class="hljs-keyword">pass</span></pre></div><div id="26e1"><pre><span class="hljs-comment"># Calculating the Ratio</span>
Data[:, <span class="hljs-built_in">where</span> + 2] = Data[:, <span class="hljs-built_in">where</span>] / Data[:, <span class="hljs-built_in">where</span> + 1]

<span class="hljs-comment"># Calculate the Choppiness Index</span>
<span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> range(len(Data)):
    
    Data[i, <span class="hljs-built_in">where</span> + 3] = 100 * np.log(Data[i, <span class="hljs-built_in">where</span> + 2]) * (1 / np.log(lookback))</pre></div><div id="afbd"><pre><span class="hljs-comment"># Cleaning</span>
Data = deleter(Data, 5, 3)

<span class="hljs-built_in">return</span> Data</pre></div><figure id="0506"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/0*Pus4gyPeLlz_vLbr.png"><figcaption><b>USDCHF in the first panel with the 20-period Choppiness Index in the second panel.</b></figcaption></figure><p id="a466">The choppiness index function can therefore be called using the following code:</p><div id="c8a9"><pre><span class="hljs-attr">my_data</span> = choppiness_index(my_data, <span class="hljs-number">20</span>, <span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">4</span>)</pre></div><figure id="4ed9"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/0*_oe4B9oeIE-hr1Yz.png"><figcaption><b>GBPUSD in the first panel with the 20-period Choppiness Index in the second panel.</b></figcaption></figure><h1 id="f15a">Using the Choppiness Index</h1><p id="549d">The way to use the choppiness index is to place the barriers by default at 38.2% and 61.8%, then we interpret the readings as follow:</p><ul><li><b>Readings above 61.8% indicate a choppy market that is bound to breakout. We should be ready for some directional.</b></li><li><b>Readings below 38.2% indicate a strong trending market that is bound to stabilize. Hence, it may not be the best idea to follow the trend at the moment.</b></li></ul><figure id="7bc6"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/0*MA4E4UosNty1IRHD.png"><figcaption><b>EURCAD in the first panel with the 20-period Choppiness Index in the second panel.</b></figcaption></figure><p id="3618">If you want to see how to create all sorts of algorithms yourself, feel free to check out Lumiwealth. From algorithmic trading to blockchain and machine learning, they have <i>hands-on</i> 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="5d41">I recommend you always follow the the below steps whenever you come across a trading technique or strategy:</p><ul><li><i>Have a critical mindset and get rid of any emotions.</i></li><li><i>Back-test it using real life simulation and conditions.</i></li><li><i>If you find potential, try optimizing it and running a forward test.</i></li><li><i>Always include transaction costs and any slippage simulation in your tests.</i></li><li><i>Always include risk management and position sizing in your tests.</i></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></article></body>

Writing | Freelancing | Success Stories

How I Earned $1,000+ Per Article Every Week for a Year

The build-up to one of my most profitable writing engagements

Photo by Daria Nepriakhina on Unsplash

Many of the popular articles here on Medium are quite meta.

Authors share and discuss their writing journey toward successfully breaking into curation, getting accepted into the bigger publications, and earning from the platform. Some also share tips and advice on how to optimize the writing workflow for success.

I thought to share a story of my own, in which articles I wrote earned at least $1,000 each in a week’s time for at least a year.

A caveat, though: This does not necessarily involve the Medium platform, although I can say that being on Medium did somehow help. Sorry — I hope my title was not misleading.

Another caveat: Due to NDAs, I cannot disclose details that will violate those agreements.

Working for an enterprise audience

In the mid-2010s, I did freelance work with a boutique PR firm that had a major technology company as a client. We did enterprise case studies, as well as other marketing assets.

Being enterprise-driven, the client could afford to pay a lot of money for the campaigns. That meant that for each case study, I got paid anywhere from $600 to $1,000 depending on the coverage and the other marketing assets included.

That’s it. That’s the short answer to how I ended up commanding at least $1,000 per article: Get a big client that pays well.

However, the story does not end there, and it certainly is not that simple.

Photo by Jeremy Enns on Unsplash

The buildup

I have been writing professionally since 2002, and I started freelancing in 2006. Back then, I accepted writing jobs that paid $2 to $5 per short article. That was hardly enough to make ends meet, but I relied on volume to thrive.

You can expect that quality suffered due to volume and cost, but that was during the time content farms were starting to flood the web with SEO-targeted articles. I thrived for a while, but that business model soon fizzled out. Even content-driven startups with billion-dollar valuations went out of business.

But I got the writing experience and exposure. With some connections, I was also sought out to launch and manage a digital magazine focusing on tech. This got me introduced to technology publications online.

I also became a paid contributor to an enterprise-focused technology publication.

In 2012, I joined the Medium platform when it was first launched. I was even able to import years of archives from WordPress (dating back to 2004), and I still have a couple of domains running under the now-grandfathered Medium hosting platform.

It was also in 2012 when I was hired full-time as a country editor for a technology startup platform. That got me into contact with startup founders, investors, development teams, media practitioners, and other professionals in the industry.

It was due to some of these connections that I then got referrals for the PR copywriting gig that paid a thousand bucks per article.

$1,000 Per article can be hard work

Here on Medium, there is a science and art to the thousand-dollar article. It’s a combination of topic, quality, style, audience, and marketing — some of it can be attributed to timing and even luck.

Some authors will admit to having articles written in half-hour as being their most popular and profitable pieces. For some, it will take much more effort.

For me, the thousand-dollar article involved a lot of work, but it also came with benefits.

Writing enterprise case studies took a few steps:

  • The account manager scheduled a teleconference with C-suite executives.
  • I researched the company and prepared targeted questions to bring out a good narrative.
  • I met or teleconferenced with these CEOs, CTOs, CMOs, corporate vice presidents, etc., for a one-hour interview.
  • I transcribed recordings and highlighted the best quotes and stories.
  • I wrote the case study driven by narrative, metrics, and impact.
  • Depending on the client requirements, I also produced other assets including executive summaries, tweets, and text for social shares. There were times I had to produce or edit scripts for a video case study.

Client work involved deadlines, so there was time pressure to consider. I had to balance this with other clients that also needed attention. So, it was on wash, rinse, repeat cycle. But that also meant money rolling in on a predictable basis.

The benefit here was that I got some exposure with these enterprise executives. I was able to gain a lot of insights into how their teams and companies worked and how their culture made an impact on their product. This has influenced my writing style to date.

There’s a lesson here somewhere

There are three things I learned from this experience.

1. Always have multiple income streams

The PR gig lasted for a year or so, but as such projects go, it had to wind down at some point. During that time, I also had other clients and projects (paying at least $150 per article — perhaps another story).

To date, I still have writing projects, and I have writing assistants to help me with some of the nitty-gritty. Having multiple projects enables me to experiment, tweak, and optimize for best results.

2. Accomplishment does not come in an instant

I can attribute my relatively high-paying copywriting work to a build-up of experience, contacts, and serendipity. You don’t gain a prospective client’s trust if you don’t have already have a body of work to show and a few great testimonials from common contacts.

I can say that my years of learning and experience paid off. My published articles became my writing portfolio.

Familiarity with the enterprise market and to tech startups also meant I had built up knowledge about the industry. It’s not easy to write when you do not have in-depth experience or at least some exposure.

I am still learning a lot, especially with reader-based monetization. I am currently exploring the Medium Partner Program. While I have not met with success yet (eight years on the platform and none of my articles have ever been curated), I am hoping to get there.

3. Keep in contact

Most of my colleagues also moved on to other projects after our PR engagement. Some who stayed on still sent me some occasional work for smaller clients. Some who worked with other publications became good referrals for other client and contract work.

This is a creative industry, and even when some aspects of writing and production now involve AI, people still matter in this business.

The takeaway

There are different paths to success. While you may not necessarily succeed in one thing, the buildup can lead to other opportunities. Be open to these opportunities. Be mindful of the lessons you learn along the way. Keep connected to the people you meet along the way.

As a publishing and monetization platform, Medium is certainly a different monster compared to an enterprise or tech startup audience. I am hopeful and confident that I can apply the lessons I learned along the way in also achieving some success here.

Writing
Writing Tips
Freelancing
Business
Illumination
Recommended from ReadMedium