Bullish Histobar / Bearish Histobar
Bullish Histobar / Bearish Histobar
05 Aug 2021, 10:10
Hello,
I am new to coding and just doing some simple tweaking but this one really out of my league. I am trying to have DMI / ADX in histogram and wanting to have ADX Green Bar (Bullish bar) when DIplus is above DIminus and Red Bar (Bearish Bar) when DIplus is above DIplus. I know it is pretty simple but I am still noob in indexing. I hope someone can help me so I could learn further. Many thanks.
using System;
using cAlgo.API;
using cAlgo.API.Indicators;
namespace cAlgo.Indicators
{
//[Levels(25, 50, 75)]
[Indicator(IsOverlay = false, AccessRights = AccessRights.None)]
public class DMIHISTOBAR : Indicator
{
[Parameter()]
public DataSeries Source { get; set; }
[Parameter("ADX Period", DefaultValue = 2, MinValue = 1, MaxValue = 60)]
public int ADXPeriod { get; set; }
//[Parameter(DefaultValue = 2)]
//public int interval { get; set; }
[Output("ADX", Color = Colors.Turquoise, PlotType = PlotType.Histogram, Thickness = 4)]
public IndicatorDataSeries adxr { get; set; }
//[Output("DiMinus", Color = Colors.Red)]
public IndicatorDataSeries diminus { get; set; }
//[Output("DiPlus", Color = Colors.Blue)]
public IndicatorDataSeries diplus { get; set; }
private DirectionalMovementSystem adx;
private StaticPosition position;
protected override void Initialize()
{
adx = Indicators.DirectionalMovementSystem(ADXPeriod);
}
public override void Calculate(int index)
{
adxr[index] = (adx.ADX[index]);
// + adx.ADX[index - ADXPeriod]) / 2;
//diminus[index] = adx.DIMinus[index];
// diplus[index] = adx.DIPlus[index];
if (!IsLastBar)
return;
}
}
}
Replies
fxctrader
05 Aug 2021, 10:32
RE:
You are really a master on this craft. I know you want us to continue with trial and error but I think there should be a better way to learn this craft. Any recommendation you could give us besides keep reading the examples on github and indicator posted on forum.
As always, I truly appreciate your help.
amusleh said:
Hi,
Try this:
using cAlgo.API; using cAlgo.API.Indicators; namespace cAlgo.Indicators { [Indicator(IsOverlay = false, AccessRights = AccessRights.None)] public class DMIHISTOBAR : Indicator { private DirectionalMovementSystem _adx; [Parameter("ADX Period", DefaultValue = 2, MinValue = 1, MaxValue = 60)] public int ADXPeriod { get; set; } [Output("Bullish", LineColor = "Blue", PlotType = PlotType.Histogram, Thickness = 4)] public IndicatorDataSeries Bullish { get; set; } [Output("Bearish", LineColor = "Red", PlotType = PlotType.Histogram, Thickness = 4)] public IndicatorDataSeries Bearish { get; set; } protected override void Initialize() { _adx = Indicators.DirectionalMovementSystem(ADXPeriod); } public override void Calculate(int index) { Bullish[index] = double.NaN; Bearish[index] = double.NaN; if (_adx.DIPlus[index] > _adx.DIMinus[index]) { Bullish[index] = _adx.ADX[index]; } else { // Remove the - (minus) if you want to show both outputs in positive above zero line Bearish[index] = -_adx.ADX[index]; } } } }
PanagiotisCharalampous
05 Aug 2021, 10:46
Hi fxctrader,
You are really a master on this craft. I know you want us to continue with trial and error but I think there should be a better way to learn this craft. Any recommendation you could give us besides keep reading the examples on github and indicator posted on forum.
Thanks for your comment. This is really basic programming skills and it is beyond our scope of work to teach programming to people. Our role here is to document the API, explain its uses, reply to questions and provide case specific examples as above. We are doing our best to provide all this information but if you still find it hard to locate it, feel free to ask and we will reply. To master this craft yourself, you need to become a good programmer first. And there is a ton of resources there to help you do so.
Best Regards,
Panagiotis
Join us on Telegram and Facebook
@PanagiotisCharalampous
fxctrader
05 Aug 2021, 10:58
RE:
Appreciate your input, Yes I do believe that is the right step, to be familiar with C# first before jumping myself deeply into unknown. What you are doing right now is really to elevate retail trading into new level and for that kudos to you, Ahmed and others who day in, day out are there ever willing to help to noobs likes me.
I wish you more success and better, brighter future for cTrader community.
Thank you.
PanagiotisCharalampous said:
Hi fxctrader,
You are really a master on this craft. I know you want us to continue with trial and error but I think there should be a better way to learn this craft. Any recommendation you could give us besides keep reading the examples on github and indicator posted on forum.
Thanks for your comment. This is really basic programming skills and it is beyond our scope of work to teach programming to people. Our role here is to document the API, explain its uses, reply to questions and provide case specific examples as above. We are doing our best to provide all this information but if you still find it hard to locate it, feel free to ask and we will reply. To master this craft yourself, you need to become a good programmer first. And there is a ton of resources there to help you do so.
Best Regards,
Panagiotis
Join us on Telegram and Facebook
amusleh
05 Aug 2021, 10:24
Hi,
Try this:
@amusleh