<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ben Diagi on Medium]]></title>
        <description><![CDATA[Stories by Ben Diagi on Medium]]></description>
        <link>https://medium.com/@ebenezerdiagi?source=rss-ad0f8e632b14------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*4ReY22qb_n76Rewu4pbSWA.jpeg</url>
            <title>Stories by Ben Diagi on Medium</title>
            <link>https://medium.com/@ebenezerdiagi?source=rss-ad0f8e632b14------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 02:55:04 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ebenezerdiagi/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[MoonPay Everyday: From On-Ramp to Everyday Money Layer]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://ebenezerdiagi.medium.com/moonpay-everyday-from-on-ramp-to-everyday-money-layer-ba834474a4f1?source=rss-ad0f8e632b14------2"><img src="https://cdn-images-1.medium.com/max/2600/1*p3zMhVrwAaVlaloDuM2NPw.png" width="5996"></a></p><p class="medium-feed-snippet">Read the interactive case-study here.</p><p class="medium-feed-link"><a href="https://ebenezerdiagi.medium.com/moonpay-everyday-from-on-ramp-to-everyday-money-layer-ba834474a4f1?source=rss-ad0f8e632b14------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://ebenezerdiagi.medium.com/moonpay-everyday-from-on-ramp-to-everyday-money-layer-ba834474a4f1?source=rss-ad0f8e632b14------2</link>
            <guid isPermaLink="false">https://medium.com/p/ba834474a4f1</guid>
            <category><![CDATA[case-study]]></category>
            <category><![CDATA[stable-coin]]></category>
            <category><![CDATA[moonpay]]></category>
            <category><![CDATA[crypto]]></category>
            <category><![CDATA[ux-case-study]]></category>
            <dc:creator><![CDATA[Ben Diagi]]></dc:creator>
            <pubDate>Tue, 28 Oct 2025 08:11:41 GMT</pubDate>
            <atom:updated>2025-10-28T08:11:41.432Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Future of Intent Based Frameworks in DeFi]]></title>
            <link>https://ebenezerdiagi.medium.com/future-of-intent-based-frameworks-in-defi-7ef0374d1fa5?source=rss-ad0f8e632b14------2</link>
            <guid isPermaLink="false">https://medium.com/p/7ef0374d1fa5</guid>
            <category><![CDATA[intent]]></category>
            <category><![CDATA[defi]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Ben Diagi]]></dc:creator>
            <pubDate>Sun, 01 Dec 2024 23:14:38 GMT</pubDate>
            <atom:updated>2024-12-01T23:14:38.166Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/830/1*iGj11qS3fECViDRbTvq11A.jpeg" /></figure><p>The decentralized finance (DeFi) ecosystem continues to evolve rapidly, with innovation at the forefront of its growth. As platforms strive to cater to increasingly complex user demands, it’s clear that a deeper level of personalization and automation is required.</p><p>In this piece, I discuss some ideas that can make transactions smarter, more efficient, and more secure. ultimately enhancing user experience and pushing the boundaries of what is possible in the space.</p><h3><strong>AI-Enhanced Intent Prediction</strong></h3><p>In the future of DeFi, platforms will no longer require users to specify exact execution parameters for their transactions. Instead, they will leverage artificial intelligence (AI) and machine learning (ML) to predict user intent based on historical data, market conditions, and other relevant factors. By training AI models on user behaviour, social trends, and liquidity movements, platforms can automatically recommend the best actions for users, optimising trades and reducing slippage.</p><p>To enhance user interaction, an add-on natural language chatbot could be incorporated, allowing users to input simple commands in plain language.</p><blockquote>For example, a user could say, <em>“</em><strong><em>I would like to swap 5,500 USDC for ETH,</em></strong><em>”</em> and the system would automatically calculate the best trading route, slippage, and liquidity pool based on past behaviour and market data.</blockquote><p>This would create a seamless, personalised experience, enhancing user engagement and reducing friction in the trading process.</p><figure><img alt="AI Enhanced Intent Prediction" src="https://cdn-images-1.medium.com/max/1024/1*hFq6icRrvt5uXkphp6esHw.jpeg" /><figcaption><a href="https://www.figma.com/board/LrODHXo9Wa5FYzv2MqbITR/Future-of-Intent-Based-Frameworks-in%C2%A0DeFi?node-id=1-2&amp;t=hjLrsBhQkw0qeRhb-4">Link to image</a></figcaption></figure><h3><strong>Multi-step Intent Framework</strong></h3><p>A composable and customizable framework where users can define complex DeFi tasks as a series of steps is a game-changer. Similar to the process of setting up workflows in Microsoft Power Automate, imagine a platform where users could automate tasks such as swapping assets, providing liquidity to pools, and staking tokens for yield — all in one go. This multi-step intent framework would appeal to advanced users who regularly execute complex transactions.</p><p>This is becoming increasingly possible with the rise of <a href="https://www.ibm.com/think/topics/ai-agents">Agentic AI</a>; AI Agents that can autonomously handle complex tasks without human intervention.</p><p>Users could specify their intentions in a series of actions, and the platform would automatically handle each step without the need for constant input. Additionally, the ability to save these workflows for future use would streamline the process for frequent traders. For example, users could automate a strategy where assets are swapped, liquidity is provided, and yield is generated, all tailored to their risk tolerance and time horizon. By enabling such flexibility, platforms would attract expert users seeking automated solutions for complex financial tasks.</p><figure><img alt="Multi step intent fraework" src="https://cdn-images-1.medium.com/max/1024/1*vbweh2CgbQgiKkcoBtlScA.jpeg" /><figcaption><a href="https://www.figma.com/board/LrODHXo9Wa5FYzv2MqbITR/Future-of-Intent-Based-Frameworks-in%C2%A0DeFi?node-id=2-100&amp;t=hjLrsBhQkw0qeRhb-4">Link to image</a></figcaption></figure><h3>Cross-Chain Intent Execution</h3><p>One of the most significant challenges in DeFi today is the lack of interoperability between different blockchains. <a href="https://chain.link/education-hub/cross-chain-bridge">Cross-chain bridges</a> are currently limited, often resulting in higher fees and lower liquidity. The ability to define a transaction intent on one blockchain and have it automatically executed across multiple chains would revolutionize the DeFi space.</p><p>This feature would enable users to swap assets on one blockchain, provide liquidity on another, and interact with protocols seamlessly across different networks. By leveraging decentralized oracles and wrapped tokens, platforms could create a truly interconnected ecosystem, reducing gas fees and slippage while providing access to liquidity from various chains. This would not only improve the efficiency of DeFi transactions but also make them more accessible to users across different blockchain ecosystems.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iq2Q87hWhqSiWqouP8FnxA.jpeg" /><figcaption><a href="https://www.figma.com/board/LrODHXo9Wa5FYzv2MqbITR/Future-of-Intent-Based-Frameworks-in%C2%A0DeFi?node-id=4-1249&amp;t=hjLrsBhQkw0qeRhb-4">Link to image</a></figcaption></figure><h3>Decentralized Intent Arbitration</h3><p>To further enhance trust and security in DeFi, decentralized arbitration mechanisms could be employed to verify that user intents are successfully executed before finalizing transactions. Third-party oracles and validators could be used to assess whether the conditions of complex transactions are met, ensuring that all steps are completed successfully. This system would be particularly useful for margin management in lending and complex asset transfers.</p><p>By decentralizing the validation process, platforms would reduce the risk of a single point of failure and increase transparency, building trust with users. This system could be applied in scenarios like managing collateral in DeFi lending, where successful execution of all conditions must be verified before funds are moved. The use of multiple data sources and validators ensures a secure and trustworthy environment, which would be particularly appealing to users concerned with the security of their transactions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s4lTsZ429oVAsncw18mdQw.jpeg" /><figcaption><a href="https://www.figma.com/board/LrODHXo9Wa5FYzv2MqbITR/Future-of-Intent-Based-Frameworks-in%C2%A0DeFi?node-id=6-1724&amp;t=hjLrsBhQkw0qeRhb-4">Link to image</a></figcaption></figure><h3>Intent-Based Lending</h3><p>Lending platforms could be taken to the next level with intent-based flash loans and collateralized loans, allowing users to specify desired outcomes such as arbitrage, liquidation, or leveraged yield farming. The platform would automatically assess the user’s creditworthiness and find the optimal conditions to execute the loan.</p><p>One innovative twist could be the ability for users to collateralize NFT assets, extending the potential of DeFi lending beyond traditional liquidity pools. This feature would create new revenue streams by introducing fee-based services for loan issuance, while also providing users with greater flexibility and access to capital. This opens up opportunities for users to engage in advanced trading strategies without the need for upfront capital, further democratizing access to financial tools.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xGbBzjb5JmQ3CldWH-tKcw.jpeg" /><figcaption><a href="https://www.figma.com/board/LrODHXo9Wa5FYzv2MqbITR/Future-of-Intent-Based-Frameworks-in%C2%A0DeFi?node-id=15-1952&amp;t=hjLrsBhQkw0qeRhb-4">Link to image</a></figcaption></figure><h3>Execution</h3><p>Significant development and integration are required across various layers to make this work:</p><ul><li><strong>AI and Machine Learning Models</strong>: AI models would need to be trained on large datasets to optimize transaction predictions. These models would continuously evolve, adjusting to new market conditions and user behavior.</li><li><strong>Smart Contracts</strong>: New, complex smart contracts would be required to handle multi-step workflows, cross-chain transactions, and decentralized arbitration.</li><li><strong>Cross-Chain Solutions</strong>: Integrating robust cross-chain bridges and oracles to ensure interoperability between different blockchain networks.</li><li><strong>User Interface</strong>: A seamless, intuitive user interface would be crucial. Users should be able to interact with the system through natural language processing, drag-and-drop interfaces, or other simple mechanisms.</li><li><strong>Security</strong>: Given the complexity of these systems, security must be a top priority. Smart contracts and AI models would need to be tested thoroughly, and decentralized oracles must be integrated securely to prevent exploits.</li></ul><h3>Risks and Challenges</h3><p>While the may sound good in theory, there are some risks and challenges to consider:</p><ul><li><strong>Technical Complexity</strong>: Implementing multi-step workflows, cross-chain interactions, and decentralized validation introduces significant technical challenges. Ensuring these features are secure, reliable, and scalable will require substantial development effort.</li><li><strong>Gas Costs</strong>: As these features may involve more complex execution logic, gas fees could increase unless optimized effectively. Solutions such as layer-2 scaling could help mitigate this issue.</li><li><strong>User Education</strong>: Advanced AI and multi-step workflows require user education. Platforms will need to provide tutorials and in-app walkthroughs to help users understand and utilize these features effectively.</li><li><strong>Security Risks</strong>: With the introduction of new features like cross-chain transactions and decentralized arbitration, security vulnerabilities could emerge. Regular audits, bug bounties, and robust risk management strategies will be essential to address these concerns.</li></ul><h3>Conclusion</h3><p>The future of DeFi lies in offering users more sophisticated, efficient, and secure tools to manage their assets and strategies. By exploring these features, platforms can lead the way in providing an improved experience for advanced users.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7ef0374d1fa5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[5 free User Persona Templates in Figma]]></title>
            <link>https://medium.com/design-bootcamp/5-free-user-persona-templates-in-figma-dd849f26bba9?source=rss-ad0f8e632b14------2</link>
            <guid isPermaLink="false">https://medium.com/p/dd849f26bba9</guid>
            <category><![CDATA[user-personas]]></category>
            <category><![CDATA[figma]]></category>
            <category><![CDATA[user-research]]></category>
            <category><![CDATA[product-management]]></category>
            <dc:creator><![CDATA[Ben Diagi]]></dc:creator>
            <pubDate>Mon, 06 Mar 2023 21:17:30 GMT</pubDate>
            <atom:updated>2023-03-07T06:20:15.176Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mIsW8icC5dCxnP_bfpD14Q.png" /></figure><p>I created a few user persona templates in Figma for Product Managers and UX designers/researchers, completely free to use.</p><p>You can find them on <a href="https://www.figma.com/community/file/1214669066039788206">Figma here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nSbwWeEfRI0GZkf8dbbeJA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VrfByUTtXt6xEGoL7t6Frg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tskF-_HCfmIViSdke_ekwg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TrFosGLnb53P1V6hfSz_Zg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kIjG8eIDWLRQjg20TeHacg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dd849f26bba9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/design-bootcamp/5-free-user-persona-templates-in-figma-dd849f26bba9">5 free User Persona Templates in Figma</a> was originally published in <a href="https://medium.com/design-bootcamp">Bootcamp</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Principles & Applications of Flow in Product Management]]></title>
            <link>https://medium.com/design-bootcamp/principles-applications-of-flow-in-product-management-8044877f63f1?source=rss-ad0f8e632b14------2</link>
            <guid isPermaLink="false">https://medium.com/p/8044877f63f1</guid>
            <category><![CDATA[user-experience]]></category>
            <category><![CDATA[product-management]]></category>
            <category><![CDATA[user-engagement]]></category>
            <category><![CDATA[flow]]></category>
            <dc:creator><![CDATA[Ben Diagi]]></dc:creator>
            <pubDate>Mon, 06 Mar 2023 01:48:39 GMT</pubDate>
            <atom:updated>2023-03-13T05:04:01.932Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CzGbL2dSjajRCG1unU2-sA.jpeg" /><figcaption><a href="https://ideas.ted.com/the-key-to-productivity-is-tapping-into-your-flow-state-heres-how/">Flow state</a></figcaption></figure><p>In her 2019 article, <a href="https://medium.com/u/309c6ac91e03">Carrie Winecoff</a> aptly wrote: “The term ‘Engagement’ has been ‘jargonised’ and overused in product management however, <strong><em>genuine, productive engagement can have immense positive impact towards building long term customer loyalty</em></strong>.”</p><p><a href="https://medium.com/u/309c6ac91e03">Carrie</a> further describes Engagement as a ‘series of high-value actions that a user performs to get them closer to a goal or satisfy a need.’</p><p>My submission is that user engagement therefore measures how frequently and for how long users interact with and perform these <strong>high-value actions</strong> on your product.</p><h3><strong>What does engagement look like?</strong></h3><p>Taking a cue from <a href="https://medium.com/u/309c6ac91e03">Carrie Winecoff</a>, here are some examples of engagement in practice:</p><p><strong>Netflix</strong>: Browsing movie categories, viewing recommended titles and watching an episode, all in service of solving the problem of entertainment.</p><p><strong>Amazon</strong>: Searching for items, reading reviews, creating a subscription for monthly repurchases, all in service of solving the problem of convenience.</p><p><strong>Airbnb</strong>: Searching for honeymoon accommodation in a dream location, viewing rental options, reading reviews, communicating with the host and booking a stay.</p><p><strong>Instagram</strong>: Stay up to date with friends, meet new people, find new experiences, save new finds, explore other peoples and cultures, all in the service of solving the problem of boredom and connection.</p><p><strong>Uber</strong>: Entering a destination, viewing the route, searching for rides, scheduling multiple stops, booking a ride and sharing ride information, all in service of solving the problem of convenience and safety.</p><h3><strong>How do we engineer ‘engagement’ to cultivate passion and loyalty in users?</strong></h3><h3><strong>FLOW</strong></h3><p>Flow is a concept developed by Mihaly Csikszentmihalyi.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JKx1W5dk8Y2QPgaiQ_NK3A.jpeg" /><figcaption><a href="https://www.ted.com/talks/mihaly_csikszentmihalyi_flow_the_secret_to_happiness">Watch TED talk</a></figcaption></figure><p>In Csikszentmihalyi’s words, flow is “a state in which people are so involved in an activity that nothing else seems to matter; the experience is so enjoyable that people will continue to do it even at great cost, for the sheer sake of doing it.”</p><p>Flow is the state of being deeply immersed and focused on an activity, it is the feeling of being in the ‘zone’.</p><p>During states of flow, we experience a loss of self &amp; self consciousness, resulting in a heightened level of performance and creativity.</p><blockquote>“The best moments in our lives are not the passive, receptive, relaxing times . . . The best moments usually occur if a person’s body or mind is stretched to its limits in a voluntary effort to accomplish something difficult and worthwhile”</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jUqF9bDJUOF8xcyr1bE8Zg.png" /><figcaption>Flow: where challenge meets skill</figcaption></figure><p>Flow describes those moments when you’re completely absorbed in a challenging but doable task.</p><h3><strong>8 rules of Flow for Product Management</strong></h3><p>Here are 8 Flow principles and their possible applications in Product Management.</p><ol><li><strong>Clear goals and immediate feedback</strong><br><strong>Principle</strong>: For a person to become deeply involved in any activity it is essential that she know precisely what tasks she must accomplish, however, it is difficult for people to stay absorbed unless they get timely information about how well they are doing.<br> <br><strong>Application</strong>: Make it clear (especially to new users) how your product helps to solve their problem or meet their need. Show your users a path to the finish line and let them know how well they are doing along the journey — you can do this covertly or overtly.</li><li><strong>Complete concentration on the task</strong><br><strong>Principle</strong>: As we begin to respond to clear goals and immediate feedback, our sense of involvement deepens and the distinction between self and activity disappears.<br> <br><strong>Application</strong>: Every user journey should have a distinct destination. Clear the user’s journey from distractions. Remove unnecessary elements and any action that doesn’t move the user closer to their goal. Every screen should be scrutinised</li><li><strong>Transformation of time</strong><br><strong>Principle</strong>: One typical element of the flow experience is that time is experienced differently. Time is either experienced as slowing down or speeding up.<br> <br><strong>Application</strong>: Use low-effort, habit-building activities such as infinite scrolling and in-app notifications. Avoid actions that lead the user outside your product, but if the user leaves for any reason, give them an easy way to pick back up and regain flow.</li><li><strong>Intrinsically rewarding experience</strong><br><strong>Principle</strong>: Not only achieving the goal of an activity is rewarding but the activity in itself is fulfilling. Flow is therefore “Immediate Return on Investment”.<br> <br><strong>Application</strong>: Leverage the copy and design to create an experience that makes the user feel like they are making a good decision, getting a great deal.</li><li><strong>Effortlessness and ease</strong><br><strong>Principle</strong>: In Flow, everything works harmoniously and effortlessly. The activity runs smoothly, guided by an inner logic. All necessary decisions arise spontaneously from the demands of the activity without any deliberate reflection.<br> <br><strong>Application</strong>: The best marketing is a product that works. The experience on your product could paint a picture of the competence of your company &amp; team. Work closely with Engineering &amp; QA to ensure your product is seamless.</li><li><strong>Balance between challenge and skills</strong><br><strong>Principle</strong>: It is easier to become completely involved in a task if we believe it is doable. If it appears to be beyond our capacity we tend to respond to it by feeling anxious; if the task is too easy we get bored.<br> <br><strong>Application</strong>: Provide the tools and information your user needs to succeed using your product. Use guided tours if necessary. Create opportunities for small wins especially for new users.</li><li><strong>Loss of self-consciousness</strong><br><strong>Principle</strong>: While immersed in the Flow experience, one tends to forget one’s very self. It is as if awareness of one’s personhood were temporarily suspended. <br> <br><strong>Application</strong>: Put yourself in the user’s shoes and pre-empt their expectation at each step. Make your user feel like an expert by foreseeing their questions and reinforcing actions that lead them to their goal.</li><li><strong>Feeling of control over the task</strong><br><strong>Principle</strong>: When people describe their flow experiences, one of the first things they mention is a strong sense of being in control of the situation.<br> <br><strong>Application</strong>: Leverage copy and design to assure users that they are allowed to make mistakes without repercussion. Give users a wide range of functionality to adjust your features to suit their specific needs, and ensure that you customer support team is readily available.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f2C4v90-rdFRtXU2M7LpzA.png" /><figcaption><a href="https://www.getclockwise.com/blog/flow-state-of-mind">Flow state of mind</a></figcaption></figure><p>This feeling of <em>Flow</em> is not a constant, meaning that if a person’s skill level improves, the challenge of the task needs to increase accordingly to keep the user in <em>Flow.</em></p><p><a href="https://medium.com/u/90493c5d0ec4">Sebastian</a> noted that: “When skill and difficulty do not match up it happens that people end up in a state of boredom (no challenge) or anxiety (too much challenge).”</p><ul><li><em>Flow is the right mix</em> — Difficulty of the task at hand needs to match with the user’s skill level to prevent boredom or frustration.</li><li><em>Flow is temporary</em> — User satisfaction is not a constant. If your user’s skills change over time, so needs your product to prevent boredom</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/1*6hddoRbx_7R7zIREf_QjGw.jpeg" /></figure><h3>Questions to help you get started with Flow in your Product Management</h3><p>Expanding on <a href="https://medium.com/u/90493c5d0ec4">Sebastian</a>’s brilliant work, here are a few things to consider as you get started with Flow:</p><ol><li><strong>What is the experience of new users? </strong><br> New users have low product expertise and low tolerance for product challenges. Are you overwhelming them? Your onboarding process should gracefully guide the user from beginner to expert.</li><li><strong>Will loyal users get bored?</strong><br> Your most valuable customers are the ones that keep coming back. Think about new features and opportunities to keep them engaged and prevent boredom.</li><li><strong>Is my product (too) challenging?</strong><br>Challenges are crucial to attain the Flow state and prevent boredom, however, you should strategically ensure you r product is not too challenging for the average proficiency level.</li></ol><p>I hope this was helpful.</p><p>Let me know if you figure out any other applications of flow in Product Management &amp; Design. I’d love to hear from you!</p><p>References:</p><ol><li><a href="https://www.ted.com/talks/mihaly_csikszentmihalyi_flow_the_secret_to_happiness">https://www.ted.com/talks/mihaly_csikszentmihalyi_flow_the_secret_to_happiness</a></li><li><a href="https://www.flowskills.com/the-8-elements-of-flow.html">https://www.flowskills.com/the-8-elements-of-flow.html</a></li><li><a href="https://flowleadership.org/flow-conditions-csikszentmihalyis-summary/">https://flowleadership.org/flow-conditions-csikszentmihalyis-summary/</a></li><li><a href="https://uxdesign.cc/product-flow-what-product-management-can-learn-from-psychology-c2a00624e010">https://uxdesign.cc/product-flow-what-product-management-can-learn-from-psychology-c2a00624e010</a> (<a href="https://medium.com/u/90493c5d0ec4">Sebastian Lindemann</a>)</li><li><a href="https://medium.com/swlh/rules-of-flow-for-product-management-airbnb-case-study-61ec04342b0d">https://medium.com/swlh/rules-of-flow-for-product-management-airbnb-case-study-61ec04342b0d</a> (<a href="https://medium.com/u/309c6ac91e03">Carrie Winecoff Shevelson</a>)</li><li><a href="https://positivepsychology.com/mihaly-csikszentmihalyi-father-of-flow/">https://positivepsychology.com/mihaly-csikszentmihalyi-father-of-flow/</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8044877f63f1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/design-bootcamp/principles-applications-of-flow-in-product-management-8044877f63f1">Principles &amp; Applications of Flow in Product Management</a> was originally published in <a href="https://medium.com/design-bootcamp">Bootcamp</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Decentralised Finance (DeFi) through the lens of Traditional Finance. ]]></title>
            <link>https://medium.com/coinmonks/decentralised-finance-defi-through-the-lens-of-traditional-finance-2dc91b34ae3c?source=rss-ad0f8e632b14------2</link>
            <guid isPermaLink="false">https://medium.com/p/2dc91b34ae3c</guid>
            <category><![CDATA[defi]]></category>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[nft]]></category>
            <category><![CDATA[decentralized-finance]]></category>
            <category><![CDATA[metaverse]]></category>
            <dc:creator><![CDATA[Ben Diagi]]></dc:creator>
            <pubDate>Sun, 06 Mar 2022 00:58:00 GMT</pubDate>
            <atom:updated>2022-03-08T05:04:01.343Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zAszCNJojTgAGO1fNa5Akw.jpeg" /></figure><p>Recently, there has been a lot of talk about Decentralised Finance (DeFi) as the next big thing that will eat Traditional Finance (TradFi). Although it’s difficult to objectively say whether this is true, I can see why the DeFi community would feel this way.</p><p>I’ve decided to write briefly about DeFi <strong><em>in the language of traditional Finance</em></strong>, to discuss the:</p><ol><li>Meaning and essence of DeFi</li><li>How value is created in DeFi</li><li>Getting started in DeFi</li><li>Exploring DeFi</li></ol><p>Finally, I will end by sharing my thoughts around DeFi and the future of Finance.</p><h3>Meaning and essence of DeFi</h3><p>Decentralised Finance is a collection of Financial products and services built on a system of secure, distributed ledgers, such that it theoretically operates without the need for traditional, centralised intermediaries like banks.<br>DeFi gives individuals access to all the services of Traditional Finance (investing, insurance, exchange, borrowing, and lending), but without the need for financial institutions or intermediaries.</p><p>DeFi is deeply connected with blockchain — the decentralised, immutable, public ledger on which Bitcoin is based — that enables all computers (or nodes) on a network to hold a copy of the history of transactions. The idea is that no single entity has control over, or can alter, that ledger of transactions.</p><p>In any Traditional Financial system, borrowers, lenders, and investors exchange current funds to finance projects, either for consumption or productive investments, and to pursue a return on their financial assets. The financial system also includes sets of rules and practices that borrowers and lenders use to decide which projects get financed, who finances projects, and terms of financial deals. The traditional financial system is full of third parties who facilitate money movement between parties, with each one charging fees for using their services.</p><p>A traditional Finance system requires at least three components to work; <strong>infrastructure</strong> to operate on <em>(central, deposit &amp; investment banks, asset managers)</em>, <strong>institutions</strong> to guide operations &amp; protect participants <em>(governments &amp; regulators)</em>, and a <strong>means of exchange </strong>to measure value <em>(fiat money e.g. USD)</em>.</p><p>Decentralised Finance must possess those three components to work.<br>Now, DeFi has some of these components, but in a significantly different manner than you might imagine.</p><h4>DeFi Infrastructure</h4><p>Most of the financial services that could be defined as DeFi can be found on the Ethereum network, the second-largest cryptocurrency marketplace, which also acts as a platform that allows other blockchain apps to be built on it (Ethereum’s cryptocurrency, Ether, is used to pay transaction costs). By utilizing decentralised apps, or dApps, two or more parties can exchange, lend, borrow, and trade directly using blockchain technology and smart contracts without middlemen’s involvement and costs.</p><p>Ethereum is a platform for writing decentralised programs. Through Ethereum, we’re able to create smart contracts — automated code that can be used to manage financial services. Through smart contracts, you can establish a set of rules for how a financial service will work, and deploy those rules to Ethereum. Once a smart contract has been deployed, it cannot be altered.</p><h4>DeFi Institutions</h4><p>DeFi does not have traditional regulatory institutions or SRO’s (self regulating organizations) like the SEC, IIROC or FCA. Decentralised Finance can not boast of any truly non-partisan, fully independent regulatory institutions.</p><h4>Decentralized Autonomous Organisations (DAO)</h4><p>In DeFi however, there exists the concept of DAO’s (Decentralised Autonomous Organizations). A DAO is a member owned community without a central leadership where like-minded participants can safely collaborate on a shared mission.</p><p>A DAO is like a public limited business that is fully owned and managed by its members. They have built-in treasuries that no one has the authority to access without the approval of the group. Decisions are governed by proposals and voting to ensure everyone in the organization has a voice. Voting is based on ownership of the DAO therefore participants with greater ownership of the DAO have higher voting rights. A DAO is completely online and operates with rules and targets hardcoded into the blockchain code at inception.</p><p>Just like traditional institutions, market participants can seek token-based or shares-based membership in a DAO.<br>Token-based membership is usually fully permissionless and tokens of a DAO can be bought directly from a decentralised exchange or earned through providing liquidity to the DAO. <br>Shares-based membership is usually permissioned, requiring prospective members to submit proposals offering value in terms of money/tokens or work/sweat.</p><p>DAO is the closest construct that DeFi has to a traditional regulatory instritutions. DAO’s can protect the rights and interests of its participants but can not protect the interest of the general market, as with SEC or FCA for example.</p><h3>How value is created in DeFi</h3><p>In the simplest terms, value is created from commissions and interest whivh are determined by demand &amp; suply and powered by means of technological advancement.</p><p>This is a form of the Neoclassical growth theory, first introduced in 1956. The theory states that economic growth is the result of three factors — labor, capital, and technology.<strong><br></strong>Loosely speaking, value creation in DeFi is also influenced by those three factors; labor, capital, and technology, from which commissions and interests are extracted.</p><p><strong>There are two forms of returns in DeFi:</strong></p><ol><li><strong>Capital gains</strong>: this refers to the appreciation of the price of Web3 artifacts such as NFTs, tokens and cryptocurrencies due to increased valuation and market sentiment.</li><li><strong>Staking rewards</strong>: This is the primary selling point for DeFi. Participants can earn staking rewards as compensation for offering their cryptocurrencies &amp; tokens in the liquidity pool for DeFi projects.<br>Just like in a traditional financial system, where a firm issues a bond to raise money to facilitate expansion, fund infrastructure development or to satisfy liquidity needs, then rewards buyers of the bond with coupons as interest payments.<br>In DeFi, you can offer the tokens in your decentralised wallet directly to firms and projects in need of liquidity and earn an APY/APR (annual percentage yield/return) which is determined by prevailing market conditions.<br>The projects generate this return by charging trading commissions through various dEx’s whenever a transaction takes place on that liquidity pool.<br>Staking rewards are offered as DEx (Decentralised exchange) token, project tokens or cryptocurrencies.</li></ol><h4>In Summary</h4><p>Decentralised Finance is a new dispensation of Finance with decentralised infrastructure and greater transparency that empowers participants and reduces third party gate-keeping.</p><p>Any financial system has various players with liquidity needs. Players could be institutions or individuals in need of various financial services such as borrowing (for leverage, project development, capital/infrastructure investment, company expansion), lending, trading or market making.</p><p>In Decentralised Finance, you own your bank, hence, you can provide liquidity directly to those players without the need for a centralized third party. This drastically reduces cost of transactions, eliminates middlemen commissions and promotes transparency.</p><p>One of the drawbacks is that the onus is on each participant to carry out sufficient due diligence on each market participant in order to verify legitimacy.</p><h3>Getting started in Decentralised Finance</h3><p>The first step in getting started in DeFi is getting a good Decentralised wallet. A decentralised wallet gives you access to dApps (decentralised apps) and dEx’s (decentralised exchanges).</p><p>A DeFi wallet must possess these features to be truly decentralised:</p><ul><li><strong>Non-Custodial</strong> — Users can send and transfer funds knowing they are the only one who has access to those funds</li><li><strong>Key-based </strong>— All DeFi wallets have a unique key-pair. This is different from centralized wallets as users are responsible for the safekeeping of their private keys, often introduced through a 12-word seed phrase.</li><li><strong>Accessible</strong> — Virtually all non-custodial wallets can handle a suit of assets, with Ethereum-specific DeFi wallets allowing users to deposit ETH in tandem with stablecoins. A DeFi wallet should provide access to various networks and tokens on the blockchain.</li><li><strong>Compatible</strong> — Virtually all DeFi wallets are accessed by connecting a web3 wallet. Mobile wallets have begun to integrate dApps browsers to make it easy to connect with DeFi applications without having to every leave the app.</li></ul><p><strong>Some solid DeFi wallets are:</strong></p><ol><li><a href="http://metamask.io/"><strong>MetaMask</strong></a> (personal favourite): MetaMask is primarily used as a Chrome web browser extension, thereby making it possible to access practically any dApp &amp; Web3 app without ever leaving the browser. There is also a mobile app with QR code functionality. MetaMask supports multiple wallet accounts, and integrates easily with multiple networks, NFTs and tokens.</li><li><a href="https://www.coinbase.com/wallet"><strong>Coinbase Wallet</strong></a>: Coinbase wallet only has a mobile app version however, it has the full functionality of a DeFi wallet just like MetaMask. It also supports in-app lending via integrating with platforms like <a href="https://compound.finance/">Compound</a> and <a href="https://dydx.exchange/">dy/dx</a>.</li><li><a href="https://www.ledger.com/"><strong>Ledger Nano Wallet</strong></a> (hardware): A hardware wallet is the best way to keep your assets secure. Ledger wallets can be used as a DeFi-wallet via DeFisaver. You can also use a smart combination of Ledger wallet + Metamask to access and use all DeFi applications.</li><li><a href="https://www.argent.xyz/"><strong>Argent</strong></a>: Argent is a mobile wallet that is available for iOS and Android. The beauty of this wallet is, it does not require you to save the private key. It uses a concept called Guardian to secure your wallet.</li></ol><h3>Exploring DeFi</h3><p>Just like traditional finance, DeFi has a similar suite of financial products and services through which value is created and extracted. A DeFi wallet gives you access to the world of Web3. You can provide liquidity to your favourite projects, mint &amp; trade NFTs, buy land &amp; apartments in the MetaVerse, take a leveraged loan, save in stablecoin, or lend your spare funds</p><p>Some broad categories in Web3 &amp; DeFi are:</p><ol><li><strong>Credit (lending &amp; borrowing)</strong>: DeFi provides an opportunity to take out loans in crypto or stable coins, using NFTs and tokens as collateral. You can also offer your spare crypto/tokens as liquidity for lending protocols and earn a lending APY. Some solid lending &amp; borrowing protocols are: <a href="https://aave.com/">AAVE</a>, <a href="https://makerdao.com/">Maker</a>.</li><li><strong>Metaverse, AR/VR</strong>: DeFi wallets provide access to buy, mint and trade NFTs &amp; assets in the Metaverse. Some Metaverse protocols are <a href="https://www.wilderworld.com/">Wilderworld</a>, <a href="https://africarare.io/ubuntuland">Ubuntuland</a>, <a href="https://www.sandbox.game/en/">Sandbox</a>, <a href="https://decentraland.org/">Decentraland</a>, <a href="https://www.ovr.ai/">OVR</a>.</li><li><strong>Web3 infrastructure:</strong> These are the projects &amp; platformsat the forefront of building and developing Web3, the future of the internet. Some interesting projects are <a href="https://polygon.technology/">Polygon</a>, <a href="https://fantom.foundation/">Fantom</a>, <a href="https://www.avax.network/">Avalanche</a>.</li><li><strong>NFTs</strong>: DeFi offers you access to mint and trade your own Non Fungible Tokens as well as the tokens of NFT projects and dEx’s. Some interesting prpjects are <a href="https://looksrare.org/">Looksrare</a>, <a href="https://opensea.io/">OpenSea</a>, <a href="https://www.wilderworld.com/">Wilderworld</a>.</li><li><strong>Finance, asset management &amp; trading</strong>: From asset management to insurance and stablecoins, DeFi gives you access to a collection on Financial services. Some solid projects &amp; platforms are <a href="https://balancer.fi/">Balancer</a>, <a href="https://www.bancor.network/">Bancor</a>, <a href="https://enzyme.finance/">Enzyme</a>, <a href="https://compound.finance/">Compound</a>, <a href="https://www.terra.money/">Terra</a>, <a href="https://www.insurace.io/">Insurace</a>.</li><li><strong>Derivatives &amp; leveraged trading</strong>: Some DeFi projects offering access to margin and leveraged trading are <a href="https://fulcrum.trade/">Fulcrum</a>, <a href="https://dydx.exchange/">dy/dx</a>, <a href="https://synthetix.io/">Synthetix</a>,</li><li><strong>Exchanges</strong>: Decentralised exchanges, also called dEx’s allow you to swap, trade, bridge, pool, farm and earn tokens across the DeFi ecosystem. Some solid dEx’s are <a href="https://app.sushi.com/swap">Sushi</a>, <a href="https://app.uniswap.org/#/swap?chain=mainnet">Uniswap</a>, <a href="https://yearn.finance/#/vaults">Yearn Finance</a>, <a href="https://curve.fi/">Curve</a>, <a href="https://spookyswap.finance/">Spookyswap</a>.</li><li><strong>Play-to-earn games</strong>: A play-to-earn game is any game that harnesses the blockchain to reward players with something that has real-world – as well as virtual-world – value. Rewards given as part of these games tend to be NFTs or project tokens. Some interesting play-to-earn platforms are <a href="https://axieinfinity.com/">AxieInfinity</a>, <a href="https://thetanarena.com/">Thetanarena</a>, <a href="https://splinterlands.com/">Splinterlands</a>, <a href="https://defikingdoms.com/">Defikingdoms</a>.</li></ol><h3>In conclusion</h3><p>While I’m definitely in the traditional Finance camp, being a CFA candidate, and currently working as a Product Manager at a traditional asset management firm, I’m well aware of the value propositions of DeFi and its ability to facilitate rapid scaling of financial services via the blockchain. I am interested in seeing how this develops over the next few years, and more importantly, I am currently exploring ways in which we can leverage the power of the Blockchain, Web3 and DeFi to solve problems in the African context.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2dc91b34ae3c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coinmonks/decentralised-finance-defi-through-the-lens-of-traditional-finance-2dc91b34ae3c">Decentralised Finance (DeFi) through the lens of Traditional Finance. 🔭</a> was originally published in <a href="https://medium.com/coinmonks">Coinmonks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Simplifying Put-Call Parity on Plain Vanilla European Options in Python — Part 1]]></title>
            <link>https://ebenezerdiagi.medium.com/simplifying-put-call-parity-on-plain-vanilla-european-options-in-python-part-1-435b7489fe7?source=rss-ad0f8e632b14------2</link>
            <guid isPermaLink="false">https://medium.com/p/435b7489fe7</guid>
            <category><![CDATA[parity]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[options]]></category>
            <category><![CDATA[derivatives]]></category>
            <category><![CDATA[jupyter]]></category>
            <dc:creator><![CDATA[Ben Diagi]]></dc:creator>
            <pubDate>Mon, 06 Dec 2021 23:28:52 GMT</pubDate>
            <atom:updated>2021-12-06T23:33:09.488Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7y2H1qtNnWAaCwn5TE_SWQ.jpeg" /></figure><h3>Simplifying Put-Call Parity on Plain Vanilla European Options in Python — Part 1</h3><p>In this first article, I will breakdown the concept of Derivatives, Options, and then visualise the payoff and profit on European Call &amp; Put Options in Python.</p><h3><strong>Background:</strong></h3><p><strong>Derivatives</strong>: A derivative is any financial instrument that derives its value from another asset, usually called an <strong>underlying asset</strong>. Derivatives are usually used for either <strong>hedging</strong> or <strong>speculation</strong>.</p><p><strong>Hedging</strong>: Imagine you are a rice farmer, looking to produce 50,000 bags of rice for sale. It will take 5 months to grow, harvest and process that quantity of rice, however the price of rice may rise or fall significantly within that time period. <br>If the market price per bag of rice in 5 months rises above your breakeven price, you would be in a net loss, so it would be great if you could lock-in a desired price today and deliver in 5 months at your locked-in price.<br>In this scenario, it may be desirable for you to create a hedge using a Forwards or Futures contract which ensures that you can sell 50,000 bags of rice in 5 months at your desired price. This arrangement will only benefit you if the price per bag of rice declines below your Forwards/Futures price.</p><p>This type of derivative is called a<strong> Forward Commitment</strong> because you have an obligation to sell the asset at whatever price you initially agreed to, with your counter-party or broker.</p><p><strong>Speculation: </strong>Imagine that a tech company you follow just set a date for a major event at which the CEO will make a series of announcements about upcoming products and services. <br>You believe that the announcements at this event will cause the price of the company’s stock to increase significantly, however you do not want to buy the stocks because they are too expensive.<br>In this scenario, it may be desirable to buy a call option to bet on the direction on the stock’s price. If the price of the stock at expiration is higher than the (strike price + the option premium), you will make a profit. Your profit is unlimited with a call option and your losses are limited to the cost of the premium.</p><p>This type of derivative is called a <strong>Contingent Claim</strong> because the decision for the buyer to exercise or not to exercise is based on the the intrinsic value of the option at expiration.</p><p>The two broad classes of derivatives, as described above are <strong>Forward Commitments</strong> and <strong>Contingent Claims</strong>.</p><p><strong>Options</strong>: An option is an example of a contingent claim. If you buy an option, you have the right but not the obligation to buy the underlying asset (stock, bond, commodity) at a specified price (stirke price) within a specified time period.</p><p><strong>All options have a:</strong><br>1. Strike price<br>2. Expiration date<br>3. Premium<br>4. Underlying asset</p><p>When you decide to buy an option contract, you will select the underlying asset, pay an option premium (to the seller), select a strike price and an expiration date.</p><p>The <strong>strike price</strong> is the the agreed upon price at which you will buy/sell the underlying asset in the future.</p><p>Unlike a futures contract, you must pay a <strong>premium</strong> to buy an option contract.</p><p>All options have a fixed expiration, however, because you have a <em>right</em> not an <em>obligation</em>, you can decide not to exercise your option on expiration. Regardless of your decision, the option premium is non-refundable, so it makes sense to exercise an option only if the benefit of exercising the option is greater than the cost of the premium.</p><p>An in-the-money option is an option that has positive intrinsic value; the benefit of exercising the option outweighs the cost of the option.</p><p>An out-of-the-money has negative intrinsic value. So we will not exercise it. We will simply lose only the premium we paid when we bought the contract.</p><p>With respect to expiration, there are three types of options. <strong>American </strong>options can be exercised on any day before the expiration day, <strong>European</strong> options can be exercised only on the exercise day, and <strong>Bermudan</strong> options can be exercised on predefined days before the expiration date.</p><p><strong>Call option</strong>: A call option gives you the right, but not the obligation to buy an underlying asset <strong>at a given strike price</strong> on a given date in the future. The value of a call option increases when the price of the underlying asset increases, therefore, you will have a positive payoff only if the price of the underlying asset is greater than the strike price.</p><p>Suppose we have an asset with prices ranging from 0 to 100.<br>We have a call option with a strike price of $50; this implies that we have the right (not the obligation) to buy the underlying asset at $50.<br>The option premium is $5.</p><p>Following the principle of “Buy Low, Sell High”, it makes sense to exercise the option only if the asset price is at a price above ($50 + the $5 premium).</p><p>The <em>payoff</em> is the value of the option before premium is deducted: (Asset price - Strike price).</p><p>The <em>profit</em> is the value of the option net of premium: (Asset price - Strike price - Premium)</p><p>If the price of the asset is below $55, we do not need to exercise. We can simply let the option expire out-of-the-money, and our loss will be the $5 premium.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d5d048e2158189234ca705490ca85f2d/href">https://medium.com/media/d5d048e2158189234ca705490ca85f2d/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/534/1*_aG_A0AJhAkjoeqL82PRCw.png" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8c97c9eb2fb7d78cc71aa95faa133df8/href">https://medium.com/media/8c97c9eb2fb7d78cc71aa95faa133df8/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/536/1*sAGQQThRD2p82x16Lelm5Q.png" /></figure><p><strong>Put Option</strong>: A put option gives you the right, but not the obligation to sell an underlying asset <strong>at a given strike price</strong> on a given date in the future. The value of a put option increases when the price of the underlying asset decreases, therefore, you will have a positive payoff only if the price of the underlying asset is less than the strike price.</p><p>Suppose we have an asset with prices ranging from 0 to 100.<br>We have a put option with a strike price of $50; this implies that we have the right (not the obligation) to sell the underlying asset at $50.<br>The option premium is $5.</p><p>Following the principle of “Buy Low, Sell High”, it makes sense to exercise the put option only if the asset price is at a price below ($50 - the $5 premium).</p><p>The <em>payoff</em> is the value of the option before premium is deducted: (Strike price - Asset price).</p><p>The <em>profit</em> is the value of the option net of premium: (Strike price - Asset price - Premium)</p><p>If the price of the asset is above $45, we do not need to exercise. We can simply let the option expire out-of-the-money, and our loss will be the $5 premium.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d296b10ca60e6a33b143fb166a051c87/href">https://medium.com/media/d296b10ca60e6a33b143fb166a051c87/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/578/1*iHKaf3x-wVlgWs13hKi8Wg.png" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2932d53de3ed8ad55024f79656ada07d/href">https://medium.com/media/2932d53de3ed8ad55024f79656ada07d/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/593/1*NVZHAEA5Bxw4u5l-3qg_0g.png" /></figure><p>Thanks for reading.</p><p>In future articles, I will explain and illustrate various types of option trading strategies, and describe the process of engineering various combinations of derivatives, risk free bonds and underlying assets to create perfectly hedged portfolios.</p><p>Cheers</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=435b7489fe7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Measures of downside historical volatility — Visualising portfolio drawdown in Python]]></title>
            <link>https://ebenezerdiagi.medium.com/measures-of-downside-historical-volatility-visualising-portfolio-drawdown-in-python-68398aef782f?source=rss-ad0f8e632b14------2</link>
            <guid isPermaLink="false">https://medium.com/p/68398aef782f</guid>
            <dc:creator><![CDATA[Ben Diagi]]></dc:creator>
            <pubDate>Fri, 04 Jun 2021 23:07:41 GMT</pubDate>
            <atom:updated>2021-06-04T23:11:06.418Z</atom:updated>
            <content:encoded><![CDATA[<h3>Measures of downside historical volatility — Visualising portfolio drawdown in Python</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*sD-lDkJhGR_VKr1EjHSLSw.jpeg" /></figure><h3>Volatility</h3><p>Volatility is a statistical measure of the dispersion of returns for a given security or market index.</p><h3><strong>Implied Volatility vs. Historical Volatility</strong></h3><p><strong>Implied volatility</strong> (IV), also known as projected volatility, is a metric that captures the market’s view of the likelihood of changes in a given security’s price. As the name suggests, it helps us make a determination of just how volatile the market will be going forward.</p><p><strong>Historical volatility</strong> (HV) is a statistical measure of the dispersion of returns for a given security or market index over a given period of time. It gauges the fluctuations of underlying securities by measuring price changes over predetermined periods of time. It is the less prevalent metric compared to implied volatility because it isn’t forward-looking.</p><p>Drawdown is one method of calculating historical volatility.</p><p>Drawdown refers to a peak-to-trough decline during a specific period for an investment, trading account, or fund. A drawdown is usually quoted as the percentage between the peak and the subsequent trough.</p><p>Here, I want to compute and visualize drawdown on the DJIA.</p><ol><li><strong>Import DJIA historical data from yfinance.</strong></li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c1fe4e8a862d6668def0117498a1fd6a/href">https://medium.com/media/c1fe4e8a862d6668def0117498a1fd6a/href</a></iframe><p><strong>2. Create a Drawdown function</strong></p><p>Since drawdown is the peak-to-trough decline, I have to calculate the running peaks and compare that to the index price.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b5a7f08ec950611c9669b13929f1ea3a/href">https://medium.com/media/b5a7f08ec950611c9669b13929f1ea3a/href</a></iframe><p><strong>Visualise DJIA all time price and peaks</strong></p><figure><img alt="DJIA all time price and peaks" src="https://cdn-images-1.medium.com/max/1024/1*k-yI9Eh0l0b8RrTFIcfPOw.png" /></figure><p><strong>Visualise DJIA drawdown</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5q6YdnfKuw3gxdvXfjgPXA.png" /></figure><p><strong>Compute DJIA max drawdown </strong>as the minimum negative value of all time. Max drawdown = <strong>89.18%</strong></p><p><strong>Interpreting Max Drawdown (MDD):</strong></p><p>89.18% is the maximum loss that could be incurred by investor who invested in the DJIA. However, it’s important to note that it only measures the size of the largest loss, without taking into consideration the frequency of large losses. Because it measures only the largest drawdown, MDD does not indicate how long it took an investor to recover from the loss, or if the investment even recovered at all.</p><p>Max drawdown date is July 1932, right after the stock market crash of 1929.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RmY5jr9nV-nOZkOn_J4-kA.png" /></figure><p><strong>Visualise DJIA drawdown during the 1929 stock market crash</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cjDNnObinHjeDs24ysXnTg.png" /></figure><p><strong>Visualise DJIA drawdown during the 2008 stock market crash</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IvjvNxFEvarGPRApYmTMnw.png" /></figure><p><strong>Visualise DJIA drawdown during the 2020 stock market crash</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AfxcJLB7kNkSFP9NlnOUMA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=68398aef782f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Writing a custom indicator in mql4 to normalise market prices into a simple line graph]]></title>
            <link>https://ebenezerdiagi.medium.com/writing-a-custom-indicator-in-mql4-to-normalise-market-prices-into-a-simple-line-graph-8b59204b0515?source=rss-ad0f8e632b14------2</link>
            <guid isPermaLink="false">https://medium.com/p/8b59204b0515</guid>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[expert-advisor-trading]]></category>
            <category><![CDATA[algorithmic-trading]]></category>
            <category><![CDATA[mql4]]></category>
            <category><![CDATA[trading]]></category>
            <dc:creator><![CDATA[Ben Diagi]]></dc:creator>
            <pubDate>Wed, 27 May 2020 14:54:16 GMT</pubDate>
            <atom:updated>2020-05-27T14:54:16.191Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*17vkFbIWNSHbOm3FWc1U-w.png" /></figure><p><strong>Data normalisation<em> </em>means transforming a set of variables to have values within a specified range such as between 0 and 1.</strong></p><p><a href="https://medium.com/u/f01820371bb4">Swetha Lakshmanan</a> in her <a href="https://medium.com/@swethalakshmanan14/how-when-and-why-should-you-normalize-standardize-rescale-your-data-3f083def38ff">article</a> explains when and why people would want to normalise data.</p><p>The goal of normalisation for me today, is to change the values of market prices to a common scale, without distorting differences in the ranges of market prices.</p><p>I am essentially creating a line graph of market price in order to view the real movement of price without the micro distortions caused by volatility.</p><p>Every market has a unique price range; <a href="https://www.dailyfx.com/eur-usd">EurUsd</a> has been ranging between <em>0.8200</em> and <em>1.6000,</em> <a href="https://www.dailyfx.com/nzd-jpy">NzdJpy</a> has been ranging between <em>41.5</em> and <em>97.5. </em>This massive discrepancy in the range of these two pairs would make it practically impossible to compare them algorithmically. Hence the need to normalise the prices.</p><p>Specifically, I have built an indicator for this so that I can further use the normalised data in an expert advisor to trade multiple instruments.</p><p><strong>Firstly</strong>, you should create an indicator using <a href="https://www.metatrader4.com/en/automated-trading/metaeditor">metaeditor</a>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1eeAqXjX0rmi845Da6BzWg.png" /><figcaption>Select ‘Custom Indicator’</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wuyVHNQ72jkg1URNnQPe2w.png" /><figcaption>Name the indicator</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K2LKY02xgine03boJRmbXw.png" /><figcaption>Select ‘OnCalculate’</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zZkJ5IXpwBVmxMgGRmpjTA.png" /><figcaption>Select ‘Indicator in Seperate Window’. Select Minimum as 0 and Maximum as 1. This is the range to which we would be normalising the price values.</figcaption></figure><p>How to normalise:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/394/1*cm-e-y89lOs2WaZdnOHDdA.png" /><figcaption><strong>where 𝑥=(𝑥1,…,𝑥𝑛) and 𝑧𝑖 is now the 𝑖𝑡ℎ normalized data</strong></figcaption></figure><p><strong><em>x</em></strong> is the most recent (close/open)price<strong><em>. min(x)</em></strong><em> is the minimum price value for a period and </em><strong><em>max(x)</em></strong><em> is the maximum price value for the same period, </em><strong><em>p</em></strong><em>.</em></p><p>In order to achieve this, we would need to calculate the minimum and maximum values on a rolling basis considering that we would be working with a constant feed of market prices.</p><p>Assuming a period of 120 (<strong><em>t</em></strong>) where the timeframe, <strong><em>t</em></strong> could be 1hour, 4hours, 1day, our <em>min(x)</em>, would be the low of the lowest candle in that 120(t) period, and our <em>max(x), </em>would be the high of the highest candle in the period.</p><p>However, I will use the open and close prices rather than the low and highs. This is personal preference, as I would like to consider the read bodies of the candles.</p><p>To determine the open/close price of the lowest/highest candle in a period, we use the <a href="https://docs.mql4.com/series/ilowest">iLowest</a> and <a href="https://docs.mql4.com/series/ihighest">iHighest</a> functions. Note that iLowest and iHighest do not return a price, they return the index of the lowest or highest candle, and as such, we use <a href="https://docs.mql4.com/series/ilow">iLow</a> or <a href="https://docs.mql4.com/series/ihigh">iHigh</a> to determine the low or high price for that particular candle.</p><p><strong>Code:</strong></p><pre>int period = 120;<br>double Normalise(<strong>int</strong> pos, <strong>string</strong> pair)<br>{<br><strong>double</strong> x =   <strong>iClose</strong>(pair,0,pos);<br><strong>double</strong> min = <strong>iOpen</strong>(pair,0,<strong>iLowest</strong>(pair,0,MODE_OPEN,period,pos));<br><strong>double</strong> max = <strong>iClose</strong>(pair,0,<strong>iHighest</strong>(pair,0,MODE_CLOSE,period,pos));</pre><pre><strong>double</strong> i = (x-min)/(max-min);<br>return(i);<br>}</pre><p>This is the function that calculates the normalised value and you would want to place it in the global scope.</p><p>Next, we need to write the OnCalculate function that constantly runs the normalise function for every new candle on the timeframe. We would write a for loop that runs through all the bars on the selected chart calculates the <strong><em>i</em></strong><em> </em>value for every candle. Assuming the pair is EurUsd.</p><p><strong>Code:</strong></p><pre><strong>int</strong> uncalculatedBar = rates_total - prev_calculated;<br><strong>for</strong> (<strong>int</strong> i=Bars-1; i&gt;=0; i--)<br>{   <br>   <strong>int</strong> shift = iBarShift(&quot;EURUSD&quot;,0,Time[i]);<br>   <br>   EurUsdBuffer[i] = Normalise(shift ,&quot;EURUSD&quot;);<br>}</pre><p>You should then place this loop into the OnCalculate function, after which your indicator code should look like this:</p><pre>#property copyright &quot;Copyright 2020, MetaQuotes Software Corp.&quot;<br>#property link      &quot;<a href="https://www.mql5.com/">https://www.mql5.com</a>&quot;<br>#property version   &quot;1.00&quot;<br>#property strict<br>#property indicator_separate_window<br>#property indicator_minimum 0<br>#property indicator_maximum 1<br>#property indicator_buffers 1<br>#property indicator_plots   1<br>#property indicator_label1  &quot;EurUsd&quot;<br>#property indicator_type1   DRAW_LINE<br>#property indicator_color1  clrRed<br>#property indicator_style1  STYLE_SOLID<br>#property indicator_width1  1</pre><pre>double         EurUsdBuffer[];<br><br>int OnInit()<br>  {<br>   SetIndexBuffer(0,EurUsdBuffer);<br>   return(INIT_SUCCEEDED);<br>  }</pre><pre>int OnCalculate(const int rates_total,<br>                const int prev_calculated,<br>                const datetime &amp;time[],<br>                const double &amp;open[],<br>                const double &amp;high[],<br>                const double &amp;low[],<br>                const double &amp;close[],<br>                const long &amp;tick_volume[],<br>                const long &amp;volume[],<br>                const int &amp;spread[])<br>  {<br>int uncalculatedBar = rates_total - prev_calculated;<br>for (int i=Bars-1; i&gt;=0; i--)<br>{   <br>int shift = iBarShift(&quot;EURUSD&quot;,0,Time[i]);<br>EurUsdBuffer[i] = Normalise(shift ,&quot;EURUSD&quot;);<br>}<br>return(rates_total);<br>}<br>   <br>int period = 120;<br>double Normalise(int pos, string pair)<br>{<br>double x =   iClose(pair,0,pos);<br>double min = iOpen(pair,0,iLowest(pair,0,MODE_OPEN,period,pos));<br>double max = iClose(pair,0,iHighest(pair,0,MODE_CLOSE,period,pos));<br>double i = (x-min)/(max-min);<br>return(i);<br>}</pre><p>I hope you found this article useful. Happy trading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8b59204b0515" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to write an array in MQL4 to store indicator values and determine the running maximun/minimum]]></title>
            <link>https://ebenezerdiagi.medium.com/how-to-write-an-array-in-mql4-to-store-indicator-values-and-determine-the-running-maximun-minimum-da6e742540f?source=rss-ad0f8e632b14------2</link>
            <guid isPermaLink="false">https://medium.com/p/da6e742540f</guid>
            <category><![CDATA[mql4]]></category>
            <category><![CDATA[algorithmic-trading]]></category>
            <category><![CDATA[mt4]]></category>
            <category><![CDATA[trading]]></category>
            <dc:creator><![CDATA[Ben Diagi]]></dc:creator>
            <pubDate>Sun, 15 Sep 2019 20:58:17 GMT</pubDate>
            <atom:updated>2019-09-16T14:47:12.542Z</atom:updated>
            <content:encoded><![CDATA[<h3>Writing a simple array in MQL4 to store indicator values and determine the running maximun/minimum</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CjkAgf8BK69bEiXA9tlWZA.jpeg" /></figure><p>I had literally spent two nights trying to figure this out because of how little available information there is about arrays and buffers in the <a href="https://docs.mql4.com/">mql4 documentation</a>.</p><p>I hope this can help someone who’s struggled with it as much as I have in the past two days.</p><p><strong>THE CHALLENGE</strong></p><p>I want to calculate the lowest and highest values of a SMA everyday (from the start of day until current time), on every new candle, and compare that value to the closing price of the previous candle(s) (amongst many other things).</p><p>Sadly, one cannot simply do this using the <a href="https://docs.mql4.com/series/ihighest">iHighest</a> or <a href="https://docs.mql4.com/series/ilowest">iLowest</a> functions; as those only work with OHLC values.</p><p>I earlier attempted a workaround; where I tried to first ascertain the lowest and highest candle closes for the day range, and then calculate a moving average based on that candle close. However, that flopped blatantly, for obvious reasons.</p><p><strong>MY SOLUTION</strong></p><p>I’m sure there are a ton of other ways to do this better, but here’s what I did.</p><p>First, I have to create an array. The documentation is <a href="https://book.mql4.com/variables/arrays">here</a>.</p><pre>int <strong>m</strong> = TimeMinute(TimeCurrent());<br>   int <strong>h</strong> = TimeHour(TimeCurrent());<br>   int <strong>bars</strong> = ((h*60)+m)/15;<br>   int <strong>malookback</strong>=bars;     // num. of bars to calc the value ofma<br>   int <strong>madailyPERIOD</strong> = 50;  // moving average period<br>     <br>   double <strong>dllv</strong>;             // variable to store the min. value<br>   double <strong>madaily</strong>[<strong><em>97</em></strong>];      // declare an array</pre><p>I want to figure out how many candles have been formed on the chart from the beginning of the day up till now. We know that the day starts at 00:00, therefore, we can simply subtract 00:00 from the current time to determine how many hours and minutes have been spent in a day.</p><p>I’m working with a 15 min chart here; so I’m adding the current hour to the current minute and dividing that by 15 in order to determine how many candles have passed since 00:00.</p><p>I would be using this value (<strong>malookback</strong>) in a for-loop later in order to quickly fill in the array everytime the function is called.</p><p>I didn’t know this, but apparently, you have to initialise an array after declaring it.</p><p>Initialise the Array:</p><pre>   ArrayInitialize(<strong>madaily</strong>,0);</pre><p>For Loop:</p><pre>   <br>   for(int <strong>i</strong> = 0; <strong>i</strong> &lt; <strong>malookback</strong>; <strong>i</strong>++)<br>   <br>   {<br>      <strong>madaily</strong>[i]= iMA(NULL,PERIOD_M15,madailyPERIOD,0,<br>      MODE_SMA,PRICE_CLOSE,i);<br>      <br>   }</pre><p>With the for loop, I’m filling the array with the indicator values every time the function is called.</p><p>Calculate the minimum using the value gotten from <strong>ArrayMinimum</strong> function(which is an index value).</p><pre>  <strong>dllv</strong> =  iMA(NULL,NULL,50,0,MODE_SMA,PRICE_CLOSE,<br>          <strong>ArrayMinimum</strong>(madaily,WHOLE_ARRAY,0));</pre><p>Remember to reset your for loop every time it runs. I can do that here by writing</p><pre>  if(<strong><em>condition</em></strong>){ return(1);<strong>malookback</strong>=0; }</pre><p>This is what the function should look like</p><pre>int <strong>ArrayCalcMin</strong>()<br>{   <br>   int m = TimeMinute(TimeCurrent());<br>   int h = TimeHour(TimeCurrent());<br>   int bars = ((h*60)+m)/15;<br>   int malookback=bars;<br>   Print(bars);<br>   int madailyPERIOD = 50;<br> <br>   double madaily[97];<br>   ArrayInitialize(madaily,0);<br>   <br>   double dllv;<br>   <br>   for(int i = 0; i &lt; malookback; i++)<br>   <br>   {<br>   <br>   <strong>madaily</strong>[i] = iMA(NULL,PERIOD_M15,madailyPERIOD,0,<br>                MODE_SMA,PRICE_CLOSE,i);<br>      <br>   }</pre><pre>   <strong>dllv</strong> = iMA(NULL,NULL,50,0,MODE_SMA,PRICE_CLOSE,<br>          ArrayMinimum(madaily,WHOLE_ARRAY,0));<br>   <br>   if(<strong><em>condition</em></strong>){return(1);<strong>malookback</strong>=0; }<br>   else {return(0);<strong>malookback</strong>=0;}<br>   <br>}</pre><p>Happy Trading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=da6e742540f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Writing a simple, indicator-based expert advisor for algorithmic trading— 1]]></title>
            <link>https://ebenezerdiagi.medium.com/writing-a-simple-indicator-based-expert-advisor-for-algorithmic-trading-1-f9eb67eb3a50?source=rss-ad0f8e632b14------2</link>
            <guid isPermaLink="false">https://medium.com/p/f9eb67eb3a50</guid>
            <category><![CDATA[trading]]></category>
            <category><![CDATA[forex]]></category>
            <category><![CDATA[algorithmic-trading]]></category>
            <category><![CDATA[expert-advisor]]></category>
            <dc:creator><![CDATA[Ben Diagi]]></dc:creator>
            <pubDate>Sun, 01 Sep 2019 18:47:00 GMT</pubDate>
            <atom:updated>2019-09-01T18:47:00.207Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/730/1*PZEi-nJVbNavl1pV19zDEQ.jpeg" /></figure><p>In my <a href="https://medium.com/@ebenezerdiagi/a-brief-introduction-to-quantitative-algorithmic-trading-for-the-financial-markets-1-d12cca3e1a87"><em>first article</em></a>, I made an introduction to indicator-based algorithmic trading strategies.</p><p>Here’s a recap -</p><blockquote>These are the easiest and simplest strategies to implement through algorithmic trading because these strategies do not involve making any predictions or price forecasts. Indicators are mathematical measurements, represented visually on the charts, which indicate the previous nature of the market. Essentially, indicators just show you what is already visible on the charts, it just helps you visualize them using lines, bars, icons etc. Some examples are: Simple Moving Average, Bollinger Bands, Relative Strength Index. I won’t go into these indicators in detail. With indicator based strategies, the trader would gather historical data as far back as possible, and look for recurring indicator based patterns. For Example, a widely popular and very basic indicator strategy is the MA(Moving Average) crossover. This involves buying the market when the short term MA crosses above the long term MA, and selling when the long term MA crosses below the short term MA. Note that indicators form slowly and are purely descriptive hence this is only a reactive strategy. I spent most of the early part of my quantitative analysis career building over 100 indicator based algorithms. I will talk more about the failures and successes in future posts in this series.</blockquote><p>What I want to do with this article is walk through the process of coding a simple algorithm for a basic indicator-based strategy. It’s going to be pretty slow-paced; because I hope it could be useful to beginners that are absolutely new to these concepts.</p><p>I would be using the popular <strong>Moving Average</strong> as my choice indicator today. 📈📉</p><p><strong>Moving Averages? — </strong>Moving averages calculate the arithmetic mean of the price of a forex pair, index, commodity or stock over a number of time periods and plots it as a line on the chart. It is visually used to smooth out price action, by eliminating the noise caused by short-term price volatility.</p><p>Moving averages are quantified in periods(days) over which they are measured. A 20-day moving average, for example is the average of price action 20 days before the current price point, at every candle(time instant).</p><p>Here’s a screenshot of my H1 EurUsd chart without an MA</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KH2lzKGBVgS-FEqbgkGEqA.png" /><figcaption>EurUsd without MA</figcaption></figure><p>Here’s one with a 20-day (period) moving average</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PXj4N9K9ayssQCrxHoc7JQ.png" /></figure><p>As shown here, the moving average is a lagging indicator and it reacts slowly to price. As a general rule, when price action is trading above the MA, the market is in an uptrend, and when price is trading below the MA, the market is in a downtrend. With higher time frames and higher periods for the MA, you get a more accurate representation of market trends. The longer the time period for the moving average, the greater the lag.</p><p>You can read more on moving averages<strong><em> </em></strong><a href="https://www.investopedia.com/terms/m/movingaverage.asp"><strong><em>here</em></strong></a><strong><em>. </em></strong><em>(Knock yourself out)</em></p><p>The 50-day and 200-day MAs are widely followed by investors and traders, with price breaks above and below these moving averages considered to be important.</p><p>This is a 50-day moving average on my EU(EurUsd) chart:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KwbWjMl8AIjElNAoIFC3Xw.png" /><figcaption>50-day MA represented as a blue line</figcaption></figure><p>Here is a 200-day moving average:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rrqrKVruLEo_2K1eeHxagA.png" /><figcaption>50-day MA represented as a red line</figcaption></figure><p>As we see here, the 50-day moving average reacts quickly to price action, compared to the 200-day moving average which reacts much slower.</p><p>Long term traders sometimes use the 200-day MA, along with other technical analysis methods to determine the direction of market trends.</p><p>Here are some of the ways I’ve used MA’s in my algorithmic trading.</p><ul><li><strong>Support/Resistance</strong>: Moving averages are a self-fulfilling prophecy, and prices always revert to mean. This is why moving averages can sometimes be helpful in finding support/resistance points, and if you look well enough, you would find points at which price seems to bounce off moving averages. I have written an algorithm in the past to identify those key points and place trades depending on a couple of other factors.</li><li><strong>Cross-over</strong>: No, not the church service that holds in most Nigerian churches on the night before January 1st every year. I’m talking about those points at which slow moving averages cross fast moving averages and give us trend signals in the market. I have created tons of algorithms for this; in different forms; and that’s what I’m writing about today.</li></ul><p>Look what happens when you place both the 50-day and 200-day moving averages on the same chart:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dD43wotBdsr8C266wYn6aQ.png" /><figcaption>50-day MA and 200-day MA represented on EurUsd H1</figcaption></figure><p>Notice that; when the fast 50-day MA(blue) crosses above the slow 200-day MA(red), it signifies that a strong <em>move to the upside(</em><strong><em>traders lingo</em></strong><em>) </em>has occurred<em>, </em>and when it crosses below, it signifies that a strong move to the downside has occurred.</p><p>I will go through the process of writing an algorithm that trades only based on this basic strategy, and I will share the results on a $10,000 account, simulated from January 2019 till date.</p><p>I am going to do this using mql4, a programming language built for the Meta Trader 4 platform, which is based off C++.</p><p>First of all, I would create a function that determines when those two MAs cross, but first, I have to get the numerical values of the two MAs.</p><p>Using the <a href="https://docs.mql4.com/basis/types"><em>double</em> datatype</a>, that would be</p><pre><strong>double</strong> 50MA = iMA(Symbol(),60,50,0,MODE_SMA,PRICE_CLOSE,1);</pre><p><strong>Symbol()</strong> — refers to the whatever instrument the chart represents</p><p><strong>60</strong> — is the number of minutes. 1 hour = 60 mins</p><p><strong>50</strong> — is the MA period. 50 day moving average</p><p><strong>0</strong> —this is the MA shift. It’s the amount of offset of the indicator to the chart</p><p><strong>MODE_SMA</strong> — means that this is a Simple Moving Average</p><p><strong>PRICE_CLOSE</strong> — means we will be using the MA formula to calculate MA based on the closing price of all the candles, rather than the open, high or low price. Read more about OHLC <a href="https://frxe.com/ohlc-candlestick-bar-chart-types/">here</a>.</p><p><strong>1</strong> — this is the shift value; which is the number of candles behind the current candle which you want to reference. ‘1’ means that you want to reference the candle just before the candle currently forming.</p><p>Now, we have to do the same thing for the 200 MA</p><pre><strong>double</strong> 50MA = iMA(Symbol(),60,50,0,MODE_SMA,PRICE_CLOSE,1);<br><strong>double</strong> 200MA = iMA(Symbol(),60,200,0,MODE_SMA,PRICE_CLOSE,1);</pre><p>This is going to return the values of the 50 and 200 MA in decimals eg 1.1201</p><p>Now, we’ve gotta figure out a way to determine when 50 MA line crosses the 200 MA line. This basically, is when the 50MA is higher than the 200MA now, but was lower than the 200MA a (minute, hour etc) ago.</p><pre>int CrossUp()<br>{<br>    <strong>double</strong> 50MA = iMA(Symbol(),NULL,50,0,MODE_SMA,PRICE_CLOSE,1);<br>    <strong>double</strong> 200MA = iMA(Symbol(),NULL,200,0,MODE_SMA,PRICE_CLOSE,1);</pre><pre>    <strong>double</strong> 50MAprev = iMA(Symbol(),NULL,50,0,MODE_SMA,PRICE_CLOSE,<strong>2</strong>);<br>    <strong>double</strong> 200MAprev = iMA(Symbol(),NULL,200,0,MODE_SMA,PRICE_CLOSE,<strong>2</strong>); <br>   <br>    if( <strong>50MA</strong>&gt;<strong>200MA</strong> &amp;&amp; <strong>50MAprev</strong>&lt;<strong>200MAprev</strong>) {return(1);}<br>    else {return(0);}<br>}</pre><p>What I’ve done here is simply;</p><p>If 50MA is greater than 200MA now, <strong>and</strong> 50MA was less than 200MA one period ago, then return yes for this CrossUp function.</p><p>I’d pause here. I would continue the development process in the next part of this article. ✌️</p><p>Ben</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f9eb67eb3a50" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>