Description
Ladies and gentlemen, welcome.
Today I propose as a curiosity an indicator based on two concepts: Mean reversion and time noise filtering.
Designed for TFm1.
Instead of price, the trend lines are calculated from the white line that tries to simulate a renko chart.
I hope you like it and enjoy it.
Dedicated to trading heroes.
Affectionately,
Sergio Raimi
This is how it looks on TFt1. The core.
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
namespace cAlgo
{
[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class MRPLOverlay : Indicator
{
[Output("Result1", LineColor = "lightGreen")]
public IndicatorDataSeries Result1 { get; set; }
[Output("Result2", LineColor = "Red")]
public IndicatorDataSeries Result2 { get; set; }
[Output("Result3", LineColor = "DodgerBlue")]
public IndicatorDataSeries Result3 { get; set; }
[Output("Result4", LineColor = "DodgerBlue")]
public IndicatorDataSeries Result4 { get; set; }
[Output("Result5", LineColor = "DodgerBlue")]
public IndicatorDataSeries Result5 { get; set; }
[Output("Result6", LineColor = "White")]
public IndicatorDataSeries Result6 { get; set; }
private Bars tf;
private int idx;
private int previousIdx;
private int buyPeriod;
private int sellPeriod;
private double buyAverage;
private double sellAverage;
private int savedbp;
private int savedsp;
private double CenterMean, UpperMean, LowerMean;
private double price, previousLevel;
private IndicatorDataSeries level;
protected override void Initialize()
{
tf = MarketData.GetBars(Bars.TimeFrame);
level = CreateDataSeries();
}
public override void Calculate(int index)
{
idx = tf.OpenTimes.GetIndexByTime(Bars.OpenTimes[index]);
if (idx > previousIdx)
{
buyPeriod++;
savedbp = buyPeriod;
sellPeriod++;
savedsp = sellPeriod;
}
if (buyPeriod == 0)
buyPeriod = savedbp;
if (sellPeriod == 0)
sellPeriod = savedsp;
//---------------------------------------------------------------------------------------------------------------------------------------------------------
price = Bars.ClosePrices[index];
level[index] = Math.Round(price, 4);
if (level[index] > previousLevel)
if (price < level[index])
level[index] = level[index] - 0.0001;
if (level[index] < previousLevel)
if (price > level[index])
level[index] = level[index] + 0.0001;
//---------------------------------------------------------------------------------------------------------------------------------------------------------
buyAverage = level.Sum(buyPeriod) / buyPeriod;
sellAverage = level.Sum(sellPeriod) / sellPeriod;
if (level[index] > buyAverage)
{
buyAverage = level[index];
buyPeriod = 0;
}
if (level[index] < sellAverage)
{
sellAverage = level[index];
sellPeriod = 0;
}
CenterMean = (buyAverage + sellAverage) / 2;
UpperMean = (buyAverage + CenterMean) / 2;
LowerMean = (CenterMean + sellAverage) / 2;
Result1[index] = sellAverage;
Result2[index] = buyAverage;
Result3[index] = CenterMean;
Result4[index] = UpperMean;
Result5[index] = LowerMean;
Result6[index] = level[index];
previousIdx = idx;
previousLevel = level[index];
}
}
}
srm_bcn
Joined on 01.09.2019
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: MRPLOverlay.algo
- Rating: 0
- Installs: 1137
- Modified: 13/10/2021 09:54
Note that publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section, please use the Copyright Infringement Notification form to submit a claim.
Comments
Log in to add a comment.
No comments found.