Coder Social home page Coder Social logo

mql5-supertrend's Introduction

Super Trend Indicator

SuperTrend is an indicator that is used to determine the direction of the market. It uses the ATR and its multiplier to be able to plot bends below for a bullish market and above for a bearish makert the candle sticks.

Understanding the ATR (Average True Range)

This is lagging indicator used to calculate the volatility of the market and it is not a directional indicator.

Before being able to calculate the Average True Range we need to be able to calculate a True Range.

True Range (TR)

A true range is calculated using the following standard formula.

MAX = [{ High - Low}, {High - p.Close}, {p.Close - Low}]

High = Current High
Low = Current Low
p.Close = Previous Close

MAX = Maximum Values

Average True Range (ATR)

I am not going to specifically calculate the True Range and the Average True Range since we have it built for us MQL Docs In order to obtain the ATR from TR we need to smooth the TR for an example using a Simple Moving Average, we can use any other moving average since there are no fundamentals rules into smoothing the TR

After being able to obtain the ATR we need to start with execution in order to start executing consider the below cases

Understanding the implementation

In order to be able to start drawing the SuperTrend bands we need to be able to calculate the bands positions below and above the candle sticks.

Bands drawing

To calculate the position of the upper band and lower band the following calculations are needed.


Upperband = HLA + [Multiplier * ATR 10]
Lowerband = HLA - [Multiplier * ATR 10]

  1. HLA - High Low Average is calculated as [(High + Low)/2]
  2. Multiplier - Is usually 3. Not sure why however you can change it to what suit your needs.
  3. ATR 10 - Is an Average True Range with a lookback period of 10

That's it after doing the above calculation in relation with the bands it is then you can start coding you MQL5 indicator!

mql5-supertrend's People

Contributors

gmakhobe avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.