Your interactive trading laboratory!
 • 
8 users online

Plot a Dot after boolean comparison

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

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.

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.

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!

New plot style BooleanDots is now available in Q151!

New plot style <b>BooleanDots</b> is now available in Q151!

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

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

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]

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.

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.

Thanks for the quick fix

Thanks for the quick fix

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.