Instruction used for building conditionnal statement.
Syntax:
1 |
IF |
Example:
1 2 3 4 5 6 7 8 9 |
a = 10 b = 20 //conditionnal statement for building "c" variable IF (a < b) THEN c = a + b ENDIF RETURN c |
Hello Nicolas, please could you explain the difference between the codes:
if a and b and c and d then
result=1
else
result=-1
endif
and with the concatenated conditions:
if a then
if b then
if c then
if d then
result=1
else
result=-1
endif
endif
endif
endif
thanks so much
Max
In your second code example, result=-1 only if a, b and c are true, but not d. While in your first example, all these 4 variables must be false to get result=-1.
thanx Nicolas, so in the second exampe, always only the last variable of the series must be false to get a result=-1? and to get a result=+1?
I ask you because I get confused with the example of the guide and with your video tutorial (with the supertrend and the channel of the moving average):
(sorry but i can’t add the PRT code, it doesn’t work).
if (average[12](close)-average[20](close)>0) then
if exponentialaverage[12](close)-exponentialaverage[20](close)>0 then
result=+1
else
result=-1
endif
endif
RETURN result
The result +1 i have is when
SMA12-SMA20 >0, EMA12-EMA20>0
SMA12-SMA20 0 ***
SMA12-SMA20 <0 , EMA12-EMA200 , EMA12-EMA20<0
SMA12-SMA20 0 ***
SMA12-SMA20 <0 , EMA12-EMA200), then result=+1 if also the second is true (EMA12-EMA20>0), but that would be equal to write if
first condition AND the second condition are both true.
Max
My message has been messed up, I don’t know why…..my results has been with the following multiple cases:
result +1= SMA12-SMA20>0 and EMA12-EMA20>0; SMA12-SMA200; SMA12-SMA20<0 and EMA12-EMA200 and EMA12-EMA20<0; SMA12-SMA200; SMA12-SMA20<0 and EMA12-EMA20<0;
I hope it will get pubblished as I've written now.
Bonjour,
Je ne peux pas mettre un return dans un if.
Je suppose que cela est normal afin de toujours avoir un return qui se run mais je mets un premier return dans un if et le deuxième dans un else :
HULL=HullAverage[PeriodeHull](close)
LSMA=EndPointAverage[PeriodeLSMA](close)
If PeriodeLSMA>PeriodeHull THEN
RETURN HULL-LSMA
ELSE
Return LSMA-HULL
ENDIF
Merci de votre aide