Description
This indicator allows you to choose the number of stochastics you want to analyze and recalculates the stochastic of the obtained oscillation.
Have fun, and for any collaboration, contact me !!!
On telegram : https://t.me/nimi012 (direct messaging)
using System;
using cAlgo.API;
using System.Linq;
using System.Collections.Generic;
using cAlgo.API.Indicators;
namespace cAlgo
{
[Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class RSIALLINONELoadCount : Indicator
{
[Parameter("Nbrs Rsi Load ", DefaultValue = 6, Group = " Ribbon/BarsColors Setting")]
public int NbrsRsiLoad { get; set; }
[Parameter("RSI Periods", DefaultValue = 55, Group = " RSI Setting")]
public int PeriodsRSI { get; set; }
[Parameter("Periods RSI Multi ", DefaultValue = 1.618, Group = " RSI Setting")]
public double PeriodsMultiRSI { get; set; }
[Output("Result Count", PlotType = PlotType.Line, LineColor = "DeepSkyBlue", Thickness = 1)]
public IndicatorDataSeries ResultCount { get; set; }
private RelativeStrengthIndex[] rsi;
private IndicatorDataSeries[] res;
private int[] periodsRSI;
public IndicatorDataSeries totalLoad;
private double resIndicator;
private double barsCount;
private double indicatorsLoad;
private double indicatorsNeedLoad;
protected override void Initialize()
{
res = new IndicatorDataSeries[NbrsRsiLoad];
rsi = new RelativeStrengthIndex[NbrsRsiLoad];
periodsRSI = new int[NbrsRsiLoad];
totalLoad = CreateDataSeries();
barsCount = Bars.Count;
indicatorsLoad = 0;
indicatorsNeedLoad = 0;
resIndicator = 0.00;
for (int i = 0; i < res.Length; i++)
{
periodsRSI[i] = (int)(Math.Round(Math.Pow(PeriodsMultiRSI, i) * PeriodsRSI));
res[i] = CreateDataSeries();
rsi[i] = Indicators.RelativeStrengthIndex(Bars.ClosePrices, periodsRSI[i]);
}
}
public override void Calculate(int index)
{
resIndicator = 0.00;
barsCount = Bars.Count;
int rsiUpTotal = 0;
for (int i = 0; i < res.Length; i++)
{
res[i][index] = rsi[i].Result[index] > 50 ? 1 : rsi[i].Result[index] < 50 ? -1 : 0;
resIndicator += res[i][index];
rsiUpTotal += GetRsiUp(i, index);
if (barsCount > periodsRSI[i])
indicatorsLoad = i + 1;
}
indicatorsNeedLoad = NbrsRsiLoad - indicatorsLoad;
totalLoad[index] = indicatorsLoad;
var up = (200.0 * rsiUpTotal / (rsi.Length * (rsi.Length - 1.0)));
var resOne = ((resIndicator / (NbrsRsiLoad)) * NbrsRsiLoad) / (NbrsRsiLoad) * 100;
var resTwo = (up - 50) * 2;
//ResultCount[index] = ((resthree / (NbrsRsiLoad ) *100) + resOne) /2;
ResultCount[index] = (resTwo + resOne) / 2;
//ResultCount[index] = resOne;
// Comment for Botting
/* if (indicatorsNeedLoad != 0)
Chart.DrawStaticText("Indicators", indicatorsLoad + "/" + NbrsRsiLoad + " Indicators are Load (" + (indicatorsLoad / NbrsRsiLoad * 100).ToString("F0") + "%)" + "\nScroll and Load more Bars for " + indicatorsNeedLoad + " Indicators (100%)", VerticalAlignment.Bottom, HorizontalAlignment.Right, Color.Red);
else
Chart.RemoveObject("Indicators");
if (ResultCount[index] >= 83.33)
Chart.SetBarColor(index, "White");
else if (ResultCount[index] < 83.33 && ResultCount[index] >= 66.66)
Chart.SetBarColor(index, "Yellow");
else if (ResultCount[index] < 66.66 && ResultCount[index] >= 50)
Chart.SetBarColor(index, "FF01FF01");
else if (ResultCount[index] < 50 && ResultCount[index] >= 33.33)
Chart.SetBarColor(index, "FF00BF00");
else if (ResultCount[index] < 33.33 && ResultCount[index] >= 16.67)
Chart.SetBarColor(index, "FF00843B");
else if (ResultCount[index] < 16.67 && ResultCount[index] >= -16.67)
Chart.SetBarColor(index, "FF262626");
else if (ResultCount[index] < -16.67 && ResultCount[index] >= -33.33)
Chart.SetBarColor(index, "FF5B0003");
else if (ResultCount[index] < -33.33 && ResultCount[index] >= -50)
Chart.SetBarColor(index, "FF890002");
else if (ResultCount[index] < -50 && ResultCount[index] >= -66.66)
Chart.SetBarColor(index, "FFFE0000");
else if (ResultCount[index] < -66.66 && ResultCount[index] > -83.33)
Chart.SetBarColor(index, "Orange");
else if (ResultCount[index] <= -83.33)
Chart.SetBarColor(index, "FFFF00C5");
else
Chart.SetBarColor(index, "FF262626");*/
//End Comment
}
private int GetRsiUp(int reference, int index)
{
int count = 0;
for (int i = reference + 1; i < rsi.Length; i++)
{
if (rsi[i].Result[index] < rsi[reference].Result[index])
count++;
}
return count;
}
}
}
YE
YesOrNot
Joined on 10.10.2022 Blocked
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: [B] STOCH OF ALL IN ONE STOCH.algo
- Rating: 0
- Installs: 381
- Modified: 10/12/2023 20:24
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.