Your interactive trading laboratory!
 • 
2 users online

Plot a Dot after boolean comparison
Q Merlin wrote on 10/31/2018, and edited on 10/31/2018 ...

In a c# Indicator, how can i plot a dot into the chart (price panel) after a boolean comparison?

public override PlotStyles DefaultPlotStyle => PlotStyles.Dots;

public override void Populate()
{
    BarHistory bars = Parameters[0].AsBarHistory;
    Int32 emaPeriod = Parameters[1].AsInt;
    Int32 atrPeriod = Parameters[2].AsInt;

    DateTimes = bars.DateTimes;

    if (bars.Count < atrPeriod + 1)
        return;
                
    EMA ema = new EMA(bars.Close, emaPeriod);
    ATR atr = new ATR(bars, atrPeriod);

    for (int bar = 1; bar < bars.Count; bar++)
    {
        bool myBoolean = (bars.Low[bar - 1] < bars.Low[bar - 2] && bars.Open[bar] < ema[bar] && bars.Close[bar] - bars.Low[bar] > (atr[bar] * 0.5)) ? true : false;

        if (myBoolean == true)
        {
            Values[bar] = 1;
        }
    }
}

Thanks...

Attachment

Cancel

Responses
Q Glitch posted on 10/31/2018

There's no easy way to do this from within an indicator, at least for now. I'm going to introduce a new PlotStyle called BooleanDots that will perform this kind of rendering. In your custom indicator code you'd then just override the DefaultPlotStyle property:

        //default plot style
        public override PlotStyles DefaultPlotStyle
        {
            get
            {
                return PlotStyles.BooleanDots;
            }
        }

This will go into Q151, hopefully for release by tomorrow. I will update this post when it's ready.

There's no easy way to do this from within an indicator, at least for now. I'm going to introduce a new PlotStyle called **BooleanDots** that will perform this kind of rendering. In your custom indicator code you'd then just override the DefaultPlotStyle property: [CODE] //default plot style public override PlotStyles DefaultPlotStyle { get { return PlotStyles.BooleanDots; } } [/CODE] This will go into Q151, hopefully for release by tomorrow. I will update this post when it's ready.
Q Merlin posted on 10/31/2018, and edited on 10/31/2018

Hi Glitch,

Something like an ArrowDown/ArrowUp in the Price Panel would also be useful. Based on my experience, this will have a much better visualization effect.

Hi Glitch, Something like an ArrowDown/ArrowUp in the Price Panel would also be useful. Based on my experience, this will have a much better visualization effect.

Q Glitch posted on 11/1/2018

The arrows are typically used in Quantacula to signify trades. The BooleanDots style is finished for now and will be in the next release, hope it helps!

The arrows are typically used in Quantacula to signify trades. The BooleanDots style is finished for now and will be in the next release, hope it helps!
Q Glitch posted on 11/2/2018, and edited on 11/2/2018

New plot style BooleanDots is now available in Q151!

New plot style <b>BooleanDots</b> is now available in Q151!
Q Merlin posted on 11/2/2018

Thanks. You have a little sample how to use it?

Thanks. You have a little sample how to use it?
Q Glitch posted on 11/2/2018

If it is within a custom indicator class, just use this code:

        //default plot style
        public override PlotStyles DefaultPlotStyle
        {
            get
            {
                return PlotStyles.BooleanDots;
            }
        }
If it is within a custom indicator class, just use this code: [CODE] //default plot style public override PlotStyles DefaultPlotStyle { get { return PlotStyles.BooleanDots; } } [/CODE]
Q Merlin posted on 11/11/2018

Just realized that using the PlotStyles.BooleanDots getter in a price tag distorts the bars scaling in the chart. Her's a sample with BIDU which had pretty big swings in the past. Left side is without any indicator, right side has an indicator on his price tag.

Just realized that using the PlotStyles.BooleanDots getter in a price tag distorts the bars scaling in the chart. Her's a sample with BIDU which had pretty big swings in the past. Left side is without any indicator, right side has an indicator on his price tag.

Q Glitch posted on 11/11/2018

Very true, just fixed this for the Q152 release, should go out tomorrow! Here's an example of MACD plotted now as BooleanDots, it automatically plots in the price pane when this plot style is selected, and no longer distorts the scale.

Very true, just fixed this for the Q152 release, should go out tomorrow! Here's an example of MACD plotted now as BooleanDots, it automatically plots in the price pane when this plot style is selected, and no longer distorts the scale.

Q Merlin posted on 11/11/2018

Thanks for the quick fix

Thanks for the quick fix
Q Glitch posted on 11/11/2018

No problem, Q152 now available.

No problem, Q152 now available.
Forum Tips

Please sign in if you want to participate in our forum.

Our forum uses Markdown syntax to format posts.

To embed code snippets, enclose them in [CODE][/CODE] tags.