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?
$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.
Thank you very much for your help! I am just thinking, if there is a way to not use the $MyDate, but to use only one time a StartDate value. Is this possible???? Appreciate any help
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:
$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