two indicators with same zero line

Custom indicators, trading strategies, data export and recording and more...
mdtrader
Posts: 39
Joined: Sat Oct 27, 2018 4:05 pm
Location: germany
Has thanked: 12 times
Been thanked: 41 times

two indicators with same zero line

Post by mdtrader » Fri Nov 23, 2018 4:10 pm

I tried to plot a zero line into the bottom part but it seemed that each indicator has it's own scale.
Is it possible to use two indicators with the same scaling and maybe add a third one as zero line?

Thanks

Svyatoslav
Site Admin
Posts: 278
Joined: Mon Jun 11, 2018 11:44 am
Has thanked: 2 times
Been thanked: 31 times

Re: two indicators with same zero line

Post by Svyatoslav » Fri Nov 23, 2018 4:16 pm

You can apply same scale to multiple indicators by adding those to same AxisGroup object (just create an object and add both indicators to it).

mdtrader
Posts: 39
Joined: Sat Oct 27, 2018 4:05 pm
Location: germany
Has thanked: 12 times
Been thanked: 41 times

Re: two indicators with same zero line

Post by mdtrader » Sat Nov 24, 2018 4:41 pm

and it works... very helpfull

Thanks

SuperDriveGuy
Posts: 67
Joined: Thu Nov 01, 2018 1:50 pm
Has thanked: 38 times
Been thanked: 9 times

Re: two indicators with same zero line

Post by SuperDriveGuy » Fri Dec 07, 2018 8:34 am

Hi mdtrader,
Please can you post some sample code to draw the zero line in the same scale as the Indicator

Basically, on the QuotesDelta indicator I want to draw a LOWER and UPPER line(as on a oscillator like RSI, MACD etc) and also a zero line. Maybe in the future, also create an alert when the indicator crosses above the UPPER line(or belowthe LOWER line).

TIA

Regards,

SDG

mdtrader
Posts: 39
Joined: Sat Oct 27, 2018 4:05 pm
Location: germany
Has thanked: 12 times
Been thanked: 41 times

Re: two indicators with same zero line

Post by mdtrader » Mon Dec 10, 2018 5:35 pm

sorry for the delay... here's my solution:

Code: Select all

    protected Indicator indicator1;
    protected Indicator indicator2;
    protected Indicator zero;

    AxisGroup grpAxis;
    AxisRules rulesAxisRules;

// when within the initialize method:
        grpAxis = new AxisGroup();
        grpAxis.add(indicator1);
        grpAxis.add(indicator2);
        grpAxis.add(zero);
        
        rulesAxisRules= new AxisRules();
        rulesAxisRules.setForcedMax(250);
        rulesAxisRules.setForcedMin(-250);
        rulesAxisRules.setSymmetrical(true);
        grpAxis.setAxisRules(rulesAxisRules); 

// for the zero line within the onInterval method:
	zero.addPoint(0);


Post Reply