"Cannot call 'ta.rsi' with argument 'length'='lowers'. An argument of 'series float' type was used but a 'simple int' is expected" - indicator

I'm getting this error in pine script
could someone help me to solve this code please
Here is my code
Cannot call 'ta.rsi' with argument 'length'='lowers'. An argument of 'series float' type was used but a 'simple int' is expected
source =(high + low + close)/3
length = input.int(14, minval=1)
Highlight=input.bool(true, title="Highlight Oversold and Overbought")
uppers = math.sum(volume * (ta.change(source) <= 0 ? 0 : source), length)
lowers = math.sum(volume * (ta.change(source) >= 0 ? 0 : source), length)
mfi = ta.rsi(uppers, lowers)
mfp = plot(mfi, color=color.gray, linewidth=1)

Replace mfi = ta.rsi(uppers, lowers) with mfi = 100.0 - (100.0 / (1.0 + uppers / lowers)) to get the calculation that you intend to; ta.rsi() can no longer be used to calculate mfi like that. You can read more about this behavior in the migration guide.

Related

Error when trying to compile code: "C80: Illegal indirection"

Currently, I am working on an ancient project, and I am trying to fix some errors in order to compile it successfully. I have basic knowledge with c but not enough to fully understand every error in it.
My current problem is that I get the error "C80: '*' illegal indirection", but I don't know why.
Here is the code:
/*----------------------------------------------------*/
/* Generating *lpDes("%23,1f")(float)(word/1000) */
/*----------------------------------------------------*/
/* Example: 321 --> 32,1 */
/*----------------------------------------------------*/
void _lWord2Str4f1(LPSTR lpDes, word w)
{
byte b100, b10;
b100 = w/100; w -= 100*b100;
b10 = w/10; w -= 10*b10;
if(b100 > 9) {
*lpDes++ = '*';
*lpDes++ = '*';
*lpDes++ = '*';
*lpDes = '*';
} else {
//Test !!!!!
*lpDes++ = (b100 ? '0' + b100 : ' ');
// *lpDes++ = '0' + b100;
*lpDes++ = '0' + b10;
*lpDes++ = *GetText(TEXT_136); // "Error C80: '*' illegal indirection
*lpDes = '0' + w;
}
}
Definition of LPSTR GetText
/* ------------------------------------------ */
/* Get Text */
/* -------------------------------------------- */
const char far* const far pText_Err = "?";
LPSTR GetText(word wNr)
{
byte bSprache; // Change Language
LPSTR pText;
bSprache = TestVar.bLaendereinstellung; // Test !!! neu 08.03.2002
// bSprache = 0;
pText = (LPSTR)pText_Err; /* Default */
if (wNr < D_MaxText) {
switch(bSprache) {
#if(SPR_EINB_D == TRUE)
case SP_D: pText = (LPSTR)pText_D[wNr]; break;
#endif
#if(SPR_EINB_F == TRUE)
// case SP_F: pText = (LPSTR)pText_F[wNr]; break;
#endif
#if(SPR_EINB_E == TRUE)
case SP_E: pText = (LPSTR)pText_E[wNr]; break;
#endif
default: pText = (LPSTR)pText_D[wNr];
}
}
return (LPSTR)pText;
}
TEXT_136
#define TEXT_136 136
pText_D
const char far* const far pText_D[] =
{
szText000, szText001, szText002, szText003, szText004,
szText005, szText006, szText007, szText008, szText009,
szText010, szText011, szText012, szText013, szText014,
szText015, szText016, szText017, szText018, szText019,
szText020, szText021, szText022, szText023, szText024,
szText025, szText026, szText027, szText028, szText029,
szText030, szText031, szText032, szText033, szText034,
szText035, szText036, szText037, szText038, szText039,
szText040, szText041, szText042, szText043, szText044,
szText045, szText046, szText047, szText048, szText049,
szText050, szText051, szText052, szText053, szText054,
szText055, szText056, szText057, szText058, szText059,
szText060, szText061, szText062, szText063, szText064,
szText065, szText066, szText067, szText068, szText069,
szText070, szText071, szText072, szText073, szText074,
szText075, szText076, szText077, szText078, szText079,
szText080, szText081, szText082, szText083, szText084,
szText085, szText086, szText087, szText088, szText089,
szText090, szText091, szText092, szText093, szText094,
szText095, szText096, szText097, szText098, szText099,
szText100, szText101, szText102, szText103, szText104,
szText105, szText106, szText107, szText108, szText109,
szText110, szText111, szText112, szText113, szText114,
szText115, szText116, szText117, szText118, szText119,
szText120, szText121, szText122, szText123, szText124,
szText125, szText126, szText127, szText128, szText129,
szText130, szText131, szText132, szText133, szText134,
szText135, szText136, szText137, szText138, szText139,
szText140, szText141, szText142, szText143, szText144,
szText145, szText146, szText147, szText148, szText149,
szText150, szText151, szText152, szText153, szText154,
szText155, szText156, szText157, szText158, szText159,
szText160, szText161, szText162, szText163, szText164,
szText165, szText166, szText167, szText168, szText169,
// szText170, szText171, szText172, szText173, szText174,
// szText175, szText176, szText177, szText178, szText179,
};
Defintions
typedef char far* LPSTR;
I have zero clue what this code does as it is part of an ancient operating system for a 16-bit microprocessor.
I've did a bit of research and some suggested changing the error part from *lpDes++ = *GetText(TEXT_136); to lpDes++ = *GetText(TEXT_136); but I don't know if this is possible or a good idea.
How can I change the code without changing its logic?
Looking at the code , this is what I can deduce
There is a function to convert and long integer (also called as a lword) to string.
void _lWord2Str4f1(LPSTR lpDes, word w)
if you input 321 you should store 32,1 //notice ,
You first get teh base 100, base 10 and base 1 (stored in w)
Then just add the ascii value of '0' to b100, b10 and b1 to convert it to a ascii character
so below line should just give yo ascii value of ,
*lpDes++ = *GetText(TEXT_136);
maybe ascii value of 136 is ,.
Update:
Ohh.. The problem seems to be that the assignment discards the "const" qualifier.
This may be okay with some compilers, while some just let go it with a warning.
May be there could some compiler options you can change to get
around. GCC doesn't seem to much care. and gives only a warning if
you assign const pointer to a variable pointer.
Or try adding explicit casting
*(LPSTR)lpDes++ = *(LPSTR)GetText(TEXT_136);
Here's an example to make this clear (this might be still legal and valid under some compilers like gcc)
This can be better explained with an example:
See below,
int * pointer;
int * const const_pointer = &var;
const int * pointer_to_const;
/* a */
pointer = const_pointer; // OK, no cast (same type)
/* b */
pointer_to_const = pointer; // OK, casting 'int*' to 'const int*'
/* c */
pointer = pointer_to_const; // Illegal, casting 'const int*' to 'int*'
I hope you understood.

MVS JES2 purge job with IEFSSREQ macro

I want to purge/cancel/spin a job by requesting the action to JES2 with the IEFSSREQ macro. Everything seems to work well but no job is affected by the request. I thought it was a filter problem in the SSJM structure but when I specify nothing in the filters I have no error (I should have one according to the documentation) and no job is affected as well.
Here is my code:
char *pcJobId = "JOB03101";
int iRc;
char * __ptr32 pworkArea = __malloc31(60);
memset(pworkArea, 0, 60);
struct ssib * __ptr32 pSSIB = __malloc31(sizeof(struct ssib));
struct ssob * __ptr32 pSSOB = __malloc31(sizeof(struct ssob));
struct ssjm * __ptr32 pSSJM = __malloc31(sizeof(struct ssjm));
memset(pSSIB, 0, sizeof(struct ssib));
memcpy(pSSIB->ssibid, "SSIB", 4);
pSSIB->ssiblen = SSIBSIZE;
memcpy(pSSIB->ssibssnm, "JES2", 4);
memset(pSSJM, 0, sizeof(struct ssjm));
memcpy(pSSJM->ssjmeye, "SSJMPL ", 8);
pSSJM->ssjmlen = SSJMSIZE;
pSSJM->ssjmvrm = SSJMVRM1;
pSSJM->ssjmopt1 = SSJMPSYN;
pSSJM->ssjmreqp._ssjmtype = SSJMPRG;
pSSJM->ssjmsel1 = SSJMSOJI;
memcpy(pSSJM->ssjmojbi, pcJobId, 8);
memset(pSSOB, 0, sizeof(struct ssob));
memcpy(pSSOB->ssobid, "SSOB", 4);
pSSOB->ssoblen = SSOBHSIZ;
pSSOB->ssobfunc = (short int)85;
pSSOB->ssobssib = pSSIB;
pSSOB->ssobindv = (int)pSSJM;
void * __ptr32 * pParmList = __malloc31(4);
*pParmList = (void * __ptr32) ((int32_t)pSSOB | (int32_t)0x80000000); // the high-order bit must be on
iRc = 0;
__asm(" SAM31\n"
" SYSSTATE AMODE64=NO\n"
" IEFSSREQ\n"
" SYSSTATE AMODE64=YES\n"
" SAM64\n"
: "=XL:NR:r15"(iRc)
: "XL:NR:r1"(pParmList), "XL:NR:r13"(pworkArea)
: "r0", "r1", "r13", "r14", "r15");
printf("IEFSSREQ rc=%d\n", iRc);
printf("ssobretn=%d\n", pSSOB->ssobretn);
printf("ssjmretn=%d\n", pSSJM->ssjmretn);
printf("ssjmret2=%d\n", pSSJM->ssjmret2);
printf("ssjmnsjf=%d\n", pSSJM->ssjmnsjf);
printf("ssjmsjf8=%p\n", pSSJM->ssjmsjf8);
free(pworkArea);
free(pSSOB);
free(pParmList);
free(pSSJM);
According to the documentation I get feedback for every jobs affected by the request in the SSJMSJF8 pointer and the SSJMNSJF should be the number of feedbacks I get, which is also the number of jobs affected by the request.
My code print this:
IEFSSREQ rc=0
ssobretn=0
ssjmretn=0
ssjmret2=0
ssjmnsjf=0
ssjmsjf8=0
Here is a link to the documentation I talked about. I'm using the Modify Job Function Call (number 85) and this is page 460.
https://www-304.ibm.com/servers/resourcelink/svc00100.nsf/pages/zOSV2R3SA380679/$file/ieaf200_v2r3.pdf
I could not see something obvious. I tried to get your code working on our system, but I'm not good enough in C, unfortunately to complete what is not shown above.
Alternatively, I tried to get it running in plain assembler. I'm getting same results as you. I tried PURGE and CANCEL requests. All don't seem to do anything. However, when specifying an invalid jobid, IEFSSREQ complains with corresponding return codes, so I know the IEFSSREQ is being invoked correctly. Must be something stupid.
Sorry I can't be of more help so far

While loop not working with bool statements in C (beginner!)

I'm learning the basics right now and am making a simple game using a basic graphics library provided by my uni.
There is a projectile thrown (the path of which is drawn)
an obstacle (a wall) - which the projectile can't pass through so must go over
and a target (must also appear solid so line stops being drawn when it is hit)
Right now my projectile is being thrown right through the wall
The issue is with the while loop
Any conditions I add (after (y_displacement < FLOOR_HEIGHT)) have had no effect
(This projectile on its own stops drawing when y_displacement => FLOOR_HEIGHT (Y-Axis is inverted), but any addition of bool statements or attempts at using bool (after #including too) to stop the projectile line being drawn don't make any changes.
TRIED BOOL FOR WALL (doesn't change anything):
bool hit_wall = false;
while ((y_displacement < FLOOR_HEIGHT) && (hit_wall == false))
{
time = (x_displacement - X_HAND) / x_velocity; //speed = distance/time
y_displacement = (Y_HAND - y_velocity * time) - (GRAVITY * pow(time, 2)/2);
GFX_DrawLineTo(x_displacement, y_displacement, 3);
x_displacement += 1;
if ((x_displacement == (X_MAX/2.5)) && ((y_displacement > (Y_MAX/2))))
{
hit_wall = true;
}
}
}
If I can manage to sort this out then I should be able to do the same for my target..
Is there something wrong with what I'm doing?
BACKGROUND:
The full function is this:
void throwBall(int(x_position), int(y_position))
{
GFX_SetColour(YELLOW);
int x_mouse;
int y_mouse;
int x_distance;
int y_distance;
double angle;
float initial_velocity;
float x_velocity;
float y_velocity;
float time;
GFX_MoveTo(X_HAND, Y_HAND);
GFX_GetMouseCoordinates(&x_mouse, &y_mouse);
x_distance = x_mouse - X_HAND;
y_distance = y_mouse - Y_HAND;
angle = getAngle(x_distance, y_distance);
initial_velocity = sqrt(pow(x_distance, 2) + pow(y_distance, 2));
//these have been divided by 5 as the magnitude was too large for the window
y_velocity = (initial_velocity * sin (angle) - GRAVITY * time)/(X_MAX/256);
x_velocity = (initial_velocity * cos (angle))/(X_MAX/256);
float y_displacement;
float x_displacement;
x_displacement = X_HAND;
y_displacement = Y_HAND;
bool hit_wall = false;
while ((y_displacement < FLOOR_HEIGHT) && (hit_wall == false))
{
time = (x_displacement - X_HAND) / x_velocity; //speed = distance/time
y_displacement = (Y_HAND - y_velocity * time) - (GRAVITY * pow(time, 2)/2);
GFX_DrawLineTo(x_displacement, y_displacement, 3);
x_displacement += 1;
if ((x_displacement == (X_MAX/2.5)) && ((y_displacement > (Y_MAX/2))))
{
hit_wall = true;
}
}
}
if ((x_displacement == (X_MAX/2.5)) && ((y_displacement > (Y_MAX/2))))
{
hit_wall = true;
}
you use flaot values, and due to some reasons (values are aprroximatelly) you almost never get in this if.
you should use >, >=, < , <= poerators, but it also will not help you in 100% of cases.
best choice will be to use epsilon (Observational error, Neighbourhood)
like
float eps = 0,0000001f;
if ( abs(x_displacement - (X_MAX/2.5) ) < eps
&& y_displacement > ( (Y_MAX/2) - eps ) )
{
hit_wall = true;
}
expanding on previous answers regarding floating point equivalence and round off error, another way to do it is multiply your float or double value by some factor of 10 to move the decimal point to the right, then cast it to an int or long it. Then you can do a boolean comparison which will be on integers which will work reliably. I mention this because it can sometimes be easier to code and also read easier than doing the epilson method (which you would also have to do an absolute value on) described in the other answer .
The big thing to recognize is the factor of 10 by which you multiply with or set epsilon to.
Do not go crazy and multiply by something like 1e9 or set epsilon = 1e-9 when you don't need to because that can re-introduce the same problem.
For example if your variables for distance are in meters then you need to recognize you do not need resolution greater than ???. Let's use 1/100 of a millimeter as an example... as far as you are concerned 1.230012345mm == 1.230456789mm. So then multiply by 1e5 then cast to int or do epsilon=1e-5;. Same principle applies for units of inches, you typically do not need resolution greater than 0.0001" for anything so multiply by 1e4 or epsilon = 1e-4.
/* example */
# define D2I 1e2 /* dbl to int factor, 0.01mm resolution */
double x_displacement; /* units of millimeters for this example*/
double y_displacement; /* units of millimeters for this example*/
/* whatever previous calculations result in...
x_displacement having value of 3.00000249687738566
y_displacement having value of 120.00000085639820699
out past 6 or so decimal places a float or double will have arbitrary numbers, so don't multiply by some huge 1e12 number
*/
if ( ( (int)(x_displacement * D2I) == (int)((X_MAX / 2.5) * D2I ) ) &&
( (int)(y_displacement * D2I ) > (int)((Y_MAX / 2 ) * D2I ) )
)
{
hit_wall = true;
}

Why this error " pngrutil.c:27:error: expected ‘;’, ‘,’ or ‘)’ before ‘=’ token" in the following function?

double shrDelta(int iCounterID = 0){ //this is the 27 the line
double DeltaT;
static struct timeval _NewTime;
static struct timeval _OldTime[3];
gettimeofday(&_NewTime, NULL);
if (iCounterID >= 0 && iCounterID <= 2)
{
DeltaT = ((double)_NewTime.tv_sec + 1.0e-6 * (double)_NewTime.tv_usec) - ((double)_OldTime[iCounterID].tv_sec + 1.0e-6 * (double)_OldTime[iCounterID].tv_usec);
_OldTime[iCounterID].tv_sec = _NewTime.tv_sec;
_OldTime[iCounterID].tv_usec = _NewTime.tv_usec;
}
else
{
DeltaT = -9999.0;
}
return DeltaT;
}
The function is supposed to return the time elapsed between last two calls.
C does not support defaulting of function parameters (or function overloading for that matter).
You need to write
double shrDelta(int iCounterID)
instead and always call the function with the parameter value explicitly given.
C standard doesnt support default values. what you used is a C++ concept. you can read this related question

Not a pointer, Cannot dereference

Iam writing a code in C where structure is being passed by reference and is used in another function
Following is the called function declaration:
float Compute(float input, struct constraints* limits_record, struct constraints* state_record);
Where limits_record and state_records both are structure declared as below:
struct constraints
{
float lower_limit;
float upper_limit;
};
The above function is being called from another function(not from main) as follows:
autotrim_out=Compute(inp, &limit, &state);
Following code details about the Compute function:
float Compute(float input, struct constraints* limits_record, struct constraints* state_record)
{
float tmp_lim;
float tmp_intgr;
tmp_intgr = coefficient * (input + state_record->lower_limit) + state_record->upper_limit;
if (tmp_intgr < limits_record->lower_limit)
tmp_lim = limits_record->lower_limit ;
else if(tmp_intgr > limits_record->upper_limit)
tmp_lim = limits_record->upper_limit;
else
tmp_lim = tmp_intgr;
state_record->upper_limit = tmp_lim;
state_record->lower_limit = input ;
return(tmp_lim) ;
}
On compiling the above code is giving error "Not a pointer, cannot deference" on the line
tmp_intgr = coefficient * (input + state_record->lower_limit) + state_record->upper_limit;
Can someone please help me regarding this...
Thanks in advance
Look for something in you code like:
#define coefficient
and change it to:
#define coefficient .42

Resources