Plotting Spread-Diff as a bar/candle  [SOLVED]

Questions about MultiCharts and user contributed studies.
synonym
Posts: 70
Joined: 20 Feb 2009
Has thanked: 10 times
Been thanked: 3 times

Plotting Spread-Diff as a bar/candle

Postby synonym » 21 Jun 2018

Hi
Has anyone been able to plot Spread-Diff as a candle rather than a Line on close? The line an close is good, but i'd like to be able to plot the O,H,L,C for the spread. I know it's likely to be through the use of Plotpaintbar, but being rubbish as coding I can't get it to work.

The following complies, but just plots the o,h,l,c of Data1. I clearly am missing something fundamental!

Code: Select all

inputs: DataSeries1( Close of data1 ), DataSeries2( Close of data2 );

Var: Spread1(0);

Spread1 = (DataSeries1 - DataSeries2);

Plotpaintbar(High[0],Low[0],Open[0],Close[0], "Spread1", black ,Default , 3);
I'd really appreciate a little push from someone who knows.
Thanks
Syn

synonym
Posts: 70
Joined: 20 Feb 2009
Has thanked: 10 times
Been thanked: 3 times

Re: Plotting Spread-Diff as a bar/candle

Postby synonym » 21 Jun 2018

Just realised a key issue - the only inputs are closes! So i need to put the o,h,l in there. The only way i can think of doing that would be to create a dataseries for the o,h,l of data1 & 2. Then i need to somehow code the following:
(O Data1 - O Data2) and do the same for the h and l. Trouble is i don't know if this is right or how i'd get it to plot correctly.

synonym
Posts: 70
Joined: 20 Feb 2009
Has thanked: 10 times
Been thanked: 3 times

Re: Plotting Spread-Diff as a bar/candle

Postby synonym » 22 Jun 2018

I've made a little progress i think, but despite all the changes it still plots exactly the same as it did, i.e. plotting data1 as all black candles. Not sure why this is.

Code: Select all

inputs: DataSeries1( High of data1 ), DataSeries2( High of data2 ),
DataSeries3( Low of data1 ), DataSeries4( Low of data2 ),
DataSeries5( Open of data1 ), DataSeries6( Open of data2 ),
DataSeries7( Close of data1 ), DataSeries8( Close of data2 );


Var: SprdH(0), SprdL(0), SprdO(0), SprdC(0);

SprdH = (DataSeries1 - DataSeries2);
SprdL = (DataSeries3 - DataSeries4);
SprdO = (DataSeries5 - DataSeries6);
SprdC = (DataSeries7 - DataSeries8);

If SprdC > SprdC[1] then SetPlotColor (3,Green)
else SetPlotColor(3,Red);
Plotpaintbar(SprdH[0],SprdL[0],SprdO[0],SprdC[0], "Spread1");
Anyone got any ideas?

synonym
Posts: 70
Joined: 20 Feb 2009
Has thanked: 10 times
Been thanked: 3 times

Re: Plotting Spread-Diff as a bar/candle

Postby synonym » 22 Jun 2018

Found this. Don't suppose anyone has managed to download this have they? It looks perfect.
https://TS.tradingappstore.co ... preadChart

synonym
Posts: 70
Joined: 20 Feb 2009
Has thanked: 10 times
Been thanked: 3 times

Re: Plotting Spread-Diff as a bar/candle

Postby synonym » 22 Jun 2018

Correction. The code i posted before works fine! I'd not inserted the correct version into a chart. It plots as candles and plots the spread exactly...now i have a different issue. When i turn data1 and data2 invisible (to make the Spread alone on the main chart), then the Spread plot changes from candles to bars. Anyone got any ideas why this would be?

User avatar
Anna MultiCharts
Posts: 451
Joined: 14 Jul 2017
Has thanked: 31 times
Been thanked: 111 times

Re: Plotting Spread-Diff as a bar/candle

Postby Anna MultiCharts » 22 Jun 2018

Hello, synonym!

As indicators using Plotpaintbar pick up the style settings from regular chart style settings, try leaving the style of Data1 and Data2 as Candlesticks and Hide them instead of making invisible (Format -> Instrument -> Settings -> Subchart section -> Hide).

synonym
Posts: 70
Joined: 20 Feb 2009
Has thanked: 10 times
Been thanked: 3 times

Re: Plotting Spread-Diff as a bar/candle  [SOLVED]

Postby synonym » 22 Jun 2018

Thanks very much Anna. I didn't know that existed, i thought invisible bars would be the only option.
Cheers
Syn


Return to “MultiCharts”