Custom values on an array
- This topic has 6 replies, 2 voices, and was last updated 3 years ago by .
Viewing 7 posts - 1 through 7 (of 7 total)
Viewing 7 posts - 1 through 7 (of 7 total)
Similar topics:
Forums › ProRealTime English forum › ProBuilder support › Custom values on an array
Hi to all! I use a simple code on an indicator, just to plot some custom values on a subchart below SPX. My code is :
if DATE = 20211028 THEN
MyIndicator = 4440
endif
if DATE = 20211029 THEN
MyIndicator = 4445
endif
Return MyIndicator as “MyIndicator”
Because after the values are now 2-3 years, the whole platform starts to lag a little bit. So, I wonder, can I put my values on arrays, so to have a lighter code?
And if yes, how to transform correct? Any example please????
Did you mean something like this one?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
$MyDate[1] = 20211028 $MyValue[1] = 4440 // $MyDate[2] = 20211029 $MyValue[2] = 4445 // MyIndicator = 0 FOR i = 1 TO 2 IF Date = $MyDate[i] THEN MyIndicator = $MyValue[i] Break ENDIF ENDIF RETURN MyIndicator |
You can add more elements at the beginning of the code, then replace 2 by the number of elements you have used.
Can you make an example?
StartDay = 20211101 then
$MyValue[1] = 4440
$MyValue[2] = 4445
$MyValue[3] = 4550
$MyValue[4] = 4600
$MyValue[5] = 4732
$MyValue[6] = 4660
And then, Return myIndicator from the Startday with values from MyValue[1] to MyValue[6]. Something like this…
Yes, there you go:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
$MyValue[1] = 0 $MyValue[2] = 0 $MyValue[3] = 0 $MyValue[4] = 0 $MyValue[5] = 0 $MyValue[6] = 0 IF Date = 20211101 then $MyValue[1] = 4440 $MyValue[2] = 4445 $MyValue[3] = 4550 $MyValue[4] = 4600 $MyValue[5] = 4732 $MyValue[6] = 4660 ENDIF RETURN $MyValue[1],$MyValue[2],$MyValue[3],$MyValue[4],$MyValue[5],$MyValue[6] |
Thank you again! With this code, I just limit the manual data entry only on 1 value. Have a nice day Roberto
Find exclusive trading pro-tools on