How to move up or down Moving Average?
How to move up or down Moving Average?
20 Sep 2013, 12:15
Hi
How to move up or down Moving Average?
How to move the moving average as shown in the picture below
Maybe someone has a similar indicator?
Or how to draw poly line like this from moving average (bold red one but not use sma function)?
Thanks and best regards
Replies
breakermind
23 Sep 2013, 16:27
( Updated at: 21 Dec 2023, 09:20 )
RE: RE:
Hi and thanks,
I have one question:
how to disable the display calibration(scale) graph chart:
graph without indicator
graph with indicator
how to make that second graph looks the same as the first when the indicator is on ???
and here the code:
using cAlgo.API; using cAlgo.API.Indicators; namespace cAlgo.Indicators { [Indicator(IsOverlay = true)] public class EnvelopeChannels : Indicator { private int Period = 10; private MovingAverage expo; [Parameter(DefaultValue = 0)] public bool Set100Levels { get; set; } [Parameter(DefaultValue = 0)] public bool RainbowSet { get; set; } [Parameter(DefaultValue = 20)] public int EnvelopePeriod { get; set; } [Parameter(DefaultValue = 0.8)] public double BandDistance { get; set; } [Parameter(DefaultValue = 1.7)] public double BandDistance1 { get; set; } [Output("Main")] public IndicatorDataSeries EnvelopeMain { get; set; } [Output("ChannelUp", Color = Colors.Red)] public IndicatorDataSeries ChannelUp { get; set; } [Output("ChannelUp1", Color = Colors.Red)] public IndicatorDataSeries ChannelUp1 { get; set; } [Output("ChannelLow", Color = Colors.Blue)] public IndicatorDataSeries ChannelLow { get; set; } [Output("ChannelLow1", Color = Colors.Blue)] public IndicatorDataSeries ChannelLow1 { get; set; } [Parameter("MAType")] public MovingAverageType matype { get; set; } protected override void Initialize() { expo = Indicators.MovingAverage(MarketSeries.Close, EnvelopePeriod, matype); } public override void Calculate(int index) { if (RainbowSet) { EnvelopeMain[index] = expo.Result[index]; ChannelUp1[index] = expo.Result[index] + (expo.Result[index] * BandDistance1) / 100; ChannelUp[index] = expo.Result[index] + (expo.Result[index] * BandDistance) / 100; ChannelLow[index] = expo.Result[index] - (expo.Result[index] * BandDistance) / 100; ChannelLow1[index] = expo.Result[index] - (expo.Result[index] * BandDistance1) / 100; } if (Set100Levels) { for (int i = 1; i < 200; i++) { ChartObjects.DrawHorizontalLine("Dayline" + i, i * 100 * Symbol.PipSize, Colors.Gray, 2); } } } } }
Thanks and bye
@breakermind
Spotware
23 Sep 2013, 16:52
You can set the AutoRescale property to false.
[Indicator(IsOverlay = true, AutoRescale = false)] public class EnvelopeChannels : Indicator
/api/indicatorattribute/autorescale
@Spotware
breakermind
23 Sep 2013, 19:53
RE:
Spotware said:
You can set the AutoRescale property to false.
[Indicator(IsOverlay = true, AutoRescale = false)] public class EnvelopeChannels : Indicator
Hi and thanks,
and the next question is how to do select box to select a color?
and something like select fields for the thickness of the line?
I want to set the field thicknes and the color of the line for the horizontal lines
Thanks again ...
@breakermind
Spotware
24 Sep 2013, 10:30
If you are referring to lines created using ChartObjects such as ChartObjects.DrawHorizontalLine then this cannot be changed at the moment. You can only set the color thickness and line style from the code.
If you are referring to the horizontal lines added on the chart manually from the toolbox, then you can right click on the line and a settings window will pop up to allow you to make modifications to the line appearance.
@Spotware
breakermind
24 Sep 2013, 11:32
RE:
Spotware said:
If you are referring to lines created using ChartObjects such as ChartObjects.DrawHorizontalLine then this cannot be changed at the moment. You can only set the color thickness and line style from the code.
If you are referring to the horizontal lines added on the chart manually from the toolbox, then you can right click on the line and a settings window will pop up to allow you to make modifications to the line appearance.
Hi
is something like select field (numeric / text) or enum ("text1", "text2"))?
Thanks
@breakermind
Kate
24 Sep 2013, 11:37
Here is a workaround for colors: /algos/indicators/show/289
You can use something similar for other things.
I hope cAlgo team will implement native support for this in future.
@Kate
breakermind
24 Sep 2013, 13:02
( Updated at: 21 Dec 2023, 09:20 )
RE:
Hi and Thanks
Indicator code:
//================================================ // breakermind-rainbow = //================================================ using cAlgo.API; using cAlgo.API.Indicators; namespace cAlgo.Indicators { [Indicator(IsOverlay = true, AutoRescale = false)] public class EnvelopeChannels : Indicator { public int LineBold; public Colors LineColor; private int Period = 20; private MovingAverage expo; [Parameter(DefaultValue = 1)] public bool RainbowSet { get; set; } [Parameter(DefaultValue = 400)] public int EnvelopePeriod { get; set; } [Parameter(DefaultValue = 0.25)] public double BandDistance1 { get; set; } [Parameter(DefaultValue = 0.45)] public double BandDistance2 { get; set; } [Parameter(DefaultValue = 0.6)] public double BandDistance3 { get; set; } [Parameter(DefaultValue = 0.8)] public double BandDistance4 { get; set; } [Parameter(DefaultValue = 1.0)] public double BandDistance5 { get; set; } [Parameter(DefaultValue = 1.7)] public double BandDistance6 { get; set; } [Output("Main")] public IndicatorDataSeries EnvelopeMain { get; set; } [Output("ChannelUp1", Color = Colors.Aqua)] public IndicatorDataSeries ChannelUp1 { get; set; } [Output("ChannelUp2", Color = Colors.Teal)] public IndicatorDataSeries ChannelUp2 { get; set; } [Output("ChannelUp3", Color = Colors.Yellow)] public IndicatorDataSeries ChannelUp3 { get; set; } [Output("ChannelUp4", Color = Colors.OrangeRed)] public IndicatorDataSeries ChannelUp4 { get; set; } [Output("ChannelUp5", Color = Colors.Red)] public IndicatorDataSeries ChannelUp5 { get; set; } [Output("ChannelUp6", Color = Colors.Red)] public IndicatorDataSeries ChannelUp6 { get; set; } [Output("ChannelLow1", Color = Colors.Aqua)] public IndicatorDataSeries ChannelLow1 { get; set; } [Output("ChannelLow2", Color = Colors.Teal)] public IndicatorDataSeries ChannelLow2 { get; set; } [Output("ChannelLow3", Color = Colors.Yellow)] public IndicatorDataSeries ChannelLow3 { get; set; } [Output("ChannelLow4", Color = Colors.OrangeRed)] public IndicatorDataSeries ChannelLow4 { get; set; } [Output("ChannelLow5", Color = Colors.Red)] public IndicatorDataSeries ChannelLow5 { get; set; } [Output("ChannelLow6", Color = Colors.Red)] public IndicatorDataSeries ChannelLow6 { get; set; } [Parameter("MAType", DefaultValue = 5)] public MovingAverageType matype { get; set; } [Parameter(DefaultValue = 0)] public bool Set100Levels { get; set; } // line bold [Parameter(DefaultValue = 1)] public bool L1 { get; set; } [Parameter(DefaultValue = 0)] public bool L2 { get; set; } [Parameter(DefaultValue = 0)] public bool L3 { get; set; } [Parameter(DefaultValue = 0)] public bool L4 { get; set; } // ===== linr color [Parameter(DefaultValue = 1)] public bool SetRed { get; set; } [Parameter(DefaultValue = 0)] public bool SetWhite { get; set; } [Parameter(DefaultValue = 0)] public bool SetBlack { get; set; } [Parameter(DefaultValue = 0)] public bool SetGreen { get; set; } protected override void Initialize() { expo = Indicators.MovingAverage(MarketSeries.Close, EnvelopePeriod, matype); } public override void Calculate(int index) { if (RainbowSet) { EnvelopeMain[index] = expo.Result[index]; ChannelUp1[index] = expo.Result[index] + (expo.Result[index] * BandDistance1) / 100; ChannelUp2[index] = expo.Result[index] + (expo.Result[index] * BandDistance2) / 100; ChannelUp3[index] = expo.Result[index] + (expo.Result[index] * BandDistance3) / 100; ChannelUp4[index] = expo.Result[index] + (expo.Result[index] * BandDistance4) / 100; ChannelUp5[index] = expo.Result[index] + (expo.Result[index] * BandDistance5) / 100; ChannelUp6[index] = expo.Result[index] + (expo.Result[index] * BandDistance6) / 100; ChannelLow1[index] = expo.Result[index] - (expo.Result[index] * BandDistance1) / 100; ChannelLow2[index] = expo.Result[index] - (expo.Result[index] * BandDistance2) / 100; ChannelLow3[index] = expo.Result[index] - (expo.Result[index] * BandDistance3) / 100; ChannelLow4[index] = expo.Result[index] - (expo.Result[index] * BandDistance4) / 100; ChannelLow5[index] = expo.Result[index] - (expo.Result[index] * BandDistance5) / 100; ChannelLow6[index] = expo.Result[index] - (expo.Result[index] * BandDistance6) / 100; } if (L1) { LineBold = 1; } if (L2) { LineBold = 2; } if (L3) { LineBold = 3; } if (L4) { LineBold = 4; } if (SetRed) { LineColor = Colors.Red; } if (SetWhite) { LineColor = Colors.White; } if (SetBlack) { LineColor = Colors.Black; } if (SetGreen) { LineColor = Colors.YellowGreen; } if (Set100Levels) { for (int i = 1; i < 200; i++) { ChartObjects.DrawHorizontalLine("Dayline" + i, i * 100 * Symbol.PipSize, LineColor, LineBold); } } } } }
Image:
and Bye ...
@breakermind
Cerunnos
20 Sep 2013, 14:50 ( Updated at: 21 Dec 2023, 09:20 )
RE:
breakermind said:
You could adapt the indicator Envelopes: /algos/indicators/show/281
@Cerunnos