Passing values from a function  [SOLVED]

Questions about MultiCharts and user contributed studies.
tryingitout
Posts: 11
Joined: 26 Feb 2014
Has thanked: 5 times

Passing values from a function

Postby tryingitout » 14 Nov 2014

I want to be able to pass my numeric simple function value called BottomLive and ALSO be able to SetPlotWidth to large values like 40? I am trying to shade a rectangle area vertically & horizonatally from a high value MC1H down to a low value MC1L .

How can I use SetPlotWidth inside a numeric simple function please?

I cannot figure out the code to set the plot correctly please?

Code: Select all


SetPlotWidth(1, 40);

BottomLive = MINLIST ( MC1H,MC1L) ;

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Passing values from a function

Postby TJ » 15 Nov 2014

I want to be able to pass my numeric simple function value called BottomLive and ALSO be able to SetPlotWidth to large values like 40? I am trying to shade a rectangle area vertically & horizonatally from a high value MC1H down to a low value MC1L .
How can I use SetPlotWidth inside a numeric simple function please?
I cannot figure out the code to set the plot correctly please?

Code: Select all

SetPlotWidth(1, 40);
BottomLive = MINLIST ( MC1H,MC1L) ;
EasyLanguage Essentials
Programmers Guide

Creating Functions ................................................................................106
Function Input Parameters........................................................................... 107
Parameter Subtypes ..................................................................................... 107
Function Input/Output Parameters .............................................................. 108


You can google for a copy of this ebook

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Passing values from a function

Postby TJ » 15 Nov 2014

I have never tried a SetPlotWidth inside a function...

tryingitout
Posts: 11
Joined: 26 Feb 2014
Has thanked: 5 times

Re: Passing values from a function

Postby tryingitout » 15 Nov 2014

I have never tried a SetPlotWidth inside a function...
Yes to plot a function with a SetPlotWidth is difficult to understand ...even with the ebook on those pages...but thanks.

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Passing values from a function

Postby JoshM » 15 Nov 2014

There's a wiki article about Passing values to and from a function, in case that might be helpful.

tryingitout
Posts: 11
Joined: 26 Feb 2014
Has thanked: 5 times

Re: Passing values from a function

Postby tryingitout » 15 Nov 2014

There's a wiki article about Passing values to and from a function, in case that might be helpful.
Thx JoshM

I already read that one...the EasyLanguage Essentials
Programmers Guide pg. 108 seems to suggest creating an indicator
setting plots there for the function to be called later...tried...but it is
above my pay grade to create.

Appreciated!

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Passing values from a function

Postby JoshM » 15 Nov 2014

I want to be able to pass my numeric simple function value called BottomLive and ALSO be able to SetPlotWidth to large values like 40?
Did you knew that SetPlotWidth only allows for values up to 14? I'm just saying before you think your code is wrong because the width didn't become 40.

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Passing values from a function

Postby JoshM » 15 Nov 2014

I want to be able to pass my numeric simple function value called BottomLive and ALSO be able to SetPlotWidth to large values like 40?

Code: Select all

SetPlotWidth(1, 40);

BottomLive = MINLIST ( MC1H,MC1L) ;
I tried this indicator:

Code: Select all

Variables:
bottomLiveValue(0);

Plot1(Close);
bottomLiveValue = Snippet_Function;

Print("bottomLiveValue = ", bottomLiveValue);
With this function:

Code: Select all

SetPlotWidth(1, 10);

Snippet_Function = MinList(Close, Close[1]);
But I got the error:
------ Compiled with error(s): ------
setplotwidth is not applicable to this type of study
line 0, column 0
Keyword "Plot**" can't been used in this type of study
line 0, column 0
So it looks like the SetPlotWidth cannot be used in a function. But looking at your goal (shading a rectangular area), wouldn't a couple of trendlines work? Or perhaps a text box, or would that not give the behaviour you're after?

tryingitout
Posts: 11
Joined: 26 Feb 2014
Has thanked: 5 times

Re: Passing values from a function

Postby tryingitout » 15 Nov 2014

Thks JoshM,

The SetPlotWidth works (as I already use it in indicators, not functions tho) for values >20 successfully.

Your idea of using trendlines, may work (have never used b4) but I have made a study that will ONLY use functions to plot.

Perhaps creating a function using trend lines as u suggest...

I am trying to plot an area shaded in, as a color for distinction...sounds simple right. :)

I will have to maybe see if I can do it this way u suggest...thx for suggesting, appreciated!

User avatar
bensat
Posts: 331
Joined: 04 Oct 2014
Has thanked: 46 times
Been thanked: 104 times

Re: Passing values from a function

Postby bensat » 15 Nov 2014

I'm little bit confused about an advantage to work with any "plotwidth" in a function ? Or was the mix up between function and indicator the issue here ?

Regards.

Ben

tryingitout
Posts: 11
Joined: 26 Feb 2014
Has thanked: 5 times

Re: Passing values from a function

Postby tryingitout » 15 Nov 2014

Hey bensat,

Thx for weighin in.

Yep...originally was tryin to determine how to use SetPlotWidth in a function...can't.

So. Why?

I am tryin to shade an area...like say between middle to the top of the bollinger band for example.

So I was using SetPlotWidth very wide and it works in an indicator, but I need it to work in a function so I can call up that function in a piece of purchased software. I suppose if I got ADE to work I could create my own...but....it is for plotting the shading of the bollinger band from a 100,000 volume on a 10,000 volume chart for example.

Not working...

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Passing values from a function  [SOLVED]

Postby Henry MultiСharts » 21 Nov 2014

Yep...originally was tryin to determine how to use SetPlotWidth in a function...can't. So. Why?
As JoshM has correctly stated above - SetPlotWidth cannot be used in a function. The plot is declared in an indicator. So the function has no idea regarding the plots that you will have or won't have in an indicator, and therefore you cannot set a width for them.


Return to “MultiCharts”