how to return NumericRef in EL  [SOLVED]

Questions about MultiCharts and user contributed studies.
martingale
Posts: 79
Joined: 10 Dec 2010
Has thanked: 2 times
Been thanked: 1 time

how to return NumericRef in EL

Postby martingale » 12 Aug 2012

I'm trying to create a function that construct another NumericRef in PLE along with the main price series.

here is my sample code which calls this function

Code: Select all

myFunc( N, outputValue ) ;     //outputValue is a numericRef datatype


and inside myFunc, I'm looking back every 3 bars and calculate the high of the 3 bars and put it in the outputValue, so every 3 member in outputValue has the same value.
how can i do this?

i'm using something like

Code: Select all

for i =  0 to 3
outputValue[i] = highOf3Bar;     //highOf3Bar is the high in the last 3 bars

but it tells me

Cannot be assigned to the previous value.

so how to achieve this in multicharts? is there a way we can pass back a reference or edit the reference passed into the function?

User avatar
TJ
Posts: 6551
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 966 times
Been thanked: 1892 times

Re: how to return NumericRef in EL

Postby TJ » 13 Aug 2012

An array will do the trick.

martingale
Posts: 79
Joined: 10 Dec 2010
Has thanked: 2 times
Been thanked: 1 time

Re: how to return NumericRef in EL

Postby martingale » 13 Aug 2012

TJ wrote:An array will do the trick.


Hi TJ

the way I'm coding is using array right? passing an NumericRef is pass an ref to array to function.
if not, what is the way to create an array?

thank you

User avatar
TJ
Posts: 6551
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 966 times
Been thanked: 1892 times

Re: how to return NumericRef in EL

Postby TJ » 13 Aug 2012

martingale wrote:
TJ wrote:An array will do the trick.


Hi TJ

the way I'm coding is using array right? passing an NumericRef is pass an ref to array to function.
if not, what is the way to create an array?

thank you


Regarding how to code it, I can't tell with the limited information you have provided.

My comment on the array, I should have been more precise: It refers to the fact that you cannot reassign a value to a past variable. The only way to store a series of changeable variables is with an array.
These users thanked the author TJ for the post:
JoshM

martingale
Posts: 79
Joined: 10 Dec 2010
Has thanked: 2 times
Been thanked: 1 time

Re: how to return NumericRef in EL

Postby martingale » 13 Aug 2012

TJ wrote:Regarding how to code it, I can't tell with the limited information you have provided.

My comment on the array, I should have been more precise: It refers to the fact that you cannot reassign a value to a past variable. The only way to store a series of changeable variables is with an array.



TJ, I put my code here for your reference.
myFunc receives an NumericRef called oHigh which is the output array, and assign the highest in the last 3 bar to the last 3 member in oHigh.

thank you


//myFunc

Code: Select all

inputs:
   oHigh( NumericRef );

variables:
   BarNumber( 0 ),
   count( 0 ),
   tempHigh( 0 );
   
if time < time[1] then
begin
   BarNumber = 1;
end
else
begin
   BarNumber = BarNumber + 1;
   
   if Mod( BarNumber, 3 ) = 0 then
   begin
      for count = 0 to 2
      begin
         tempHigh = maxlist( High[ count ], tempHigh );
      end;
      
      for count = 0 to 2
      begin   
         oHigh[count] = tempHigh;
      end;
        end;
end;

User avatar
TJ
Posts: 6551
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 966 times
Been thanked: 1892 times

Re: how to return NumericRef in EL

Postby TJ » 13 Aug 2012

Can't tell much from what you have.
You will need to design the architecture from the ground up.

Are you trying to create a Renko/Heiken Ashi type of chart database where you can find the High or Low of X block prior?

martingale
Posts: 79
Joined: 10 Dec 2010
Has thanked: 2 times
Been thanked: 1 time

Re: how to return NumericRef in EL

Postby martingale » 13 Aug 2012

TJ wrote:Can't tell much from what you have.
You will need to design the architecture from the ground up.

Are you trying to create a Renko chart database where you can find the High or Low of X block prior?


no, just high of the 3 bars. is the array you refer to same as NumericRef?

User avatar
TJ
Posts: 6551
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 966 times
Been thanked: 1892 times

Re: how to return NumericRef in EL

Postby TJ » 13 Aug 2012

martingale wrote:no, just high of the 3 bars. is the array you refer to same as NumericRef?


Ok, I have re-read your 1st post again.
If you are only looking to make a printout of the Highest High of the previous 3 bars,
there is no need to re-assign the variable, because the latest "Highest-High" is always the highest high. So you can simply print the that number 3 times. ie. no array is needed, no retro-referencing is needed.

If my understanding is incorrect, a diagram would help further discussion.

martingale
Posts: 79
Joined: 10 Dec 2010
Has thanked: 2 times
Been thanked: 1 time

Re: how to return NumericRef in EL

Postby martingale » 13 Aug 2012

TJ wrote:
martingale wrote:no, just high of the 3 bars. is the array you refer to same as NumericRef?


Ok, I have re-read your 1st post again.
If you are only looking to make a printout of the Highest High of the previous 3 bars,
there is no need to re-assign the variable, because the latest "Highest-High" is always the highest high. So you can simply print the that number 3 times. ie. no array is needed, no retro-referencing is needed.

If my understanding is incorrect, a diagram would help further discussion.


i think it's easier to go with an example.

let's say we are at bar with time 10:03, and the high of bar end in 10:01 , 10:02, 10:03 are 1431,1429,1432. then my oHigh referencing the 3 bars should be all equal to 1432; but we can only know this at end of 10:03, which means I need to modify oHigh at 10:01 and 10:02 at 10:03.
i have a question regarding array.
does an array has to be sync with bar or it can be of any size.

User avatar
TJ
Posts: 6551
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 966 times
Been thanked: 1892 times

Re: how to return NumericRef in EL

Postby TJ » 13 Aug 2012

martingale wrote:i think it's easier to go with an example.

let's say we are at bar with time 10:03, and the high of bar end in 10:01 , 10:02, 10:03 are 1431,1429,1432. then my oHigh referencing the 3 bars should be all equal to 1432; but we can only know this at end of 10:03, which means I need to modify oHigh at 10:01 and 10:02 at 10:03.
i have a question regarding array.
does an array has to be sync with bar or it can be of any size.


You are only giving a partial example:

I am not sure if I understand your intent:
What are you doing with the 10:01's oHigh when you are at 10:03?
Are you plotting 10:01 again?
Are you using the value in another operation?

None of the above requires a re-assignment of a prior variable.

User avatar
TJ
Posts: 6551
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 966 times
Been thanked: 1892 times

Re: how to return NumericRef in EL  [SOLVED]

Postby TJ » 13 Aug 2012

martingale wrote:...
i have a question regarding array.
does an array has to be sync with bar or it can be of any size.


An array does not have to sync with a bar. It is a database where you can store data (value, true/false, or character) in one, two or multiple dimensions.


Return to “MultiCharts”