Login Page - Create Account

Support Board


Date/Time: Tue, 30 Apr 2024 05:37:59 +0000



[Programming Help] - Determining slope of three EMA's

View Count: 855

[2020-03-03 23:31:37]
tommartin321 - Posts: 74
Hello,

I have three EMA's I need to determine the slope for. Right now I have each in a separate column(X,Y,Z). Is this the most efficient way? Is it possible to combine all three into one?

=IF(OR(ID11.SG1@3>ID11.SG1@4,AND(ID11.SG1@5>=ID11.SG1@4,ID11.SG1@3>ID11.SG1@4)),1,IF(OR(ID11.SG1@3<ID11.SG1@4,AND(ID11.SG1@5<=ID11.SG1@4,ID11.SG1@3<ID11.SG1@4)),-1,X4))
=IF(OR(ID15.SG1@3>ID15.SG1@4,AND(ID15.SG1@5>=ID15.SG1@4,ID15.SG1@3>ID15.SG1@4)),1,IF(OR(ID15.SG1@3<ID15.SG1@4,AND(ID15.SG1@5<=ID15.SG1@4,ID15.SG1@3<ID15.SG1@4)),-1,Y4))
=IF(OR(ID12.SG1@3>ID12.SG1@4,AND(ID12.SG1@5>=ID12.SG1@4,ID12.SG1@3>ID12.SG1@4)),1,IF(OR(ID12.SG1@3<ID12.SG1@4,AND(ID12.SG1@5<=ID12.SG1@4,ID12.SG1@3<ID12.SG1@4)),-1,Z4))

Thanks,
Tom
[2020-03-04 04:14:22]
Sawtooth - Posts: 3985
Is this the most efficient way?
It's the most accurate way to find the slope direction, and I know of now other way.

Is it possible to combine all three into one?
Each MA has its own slope, so how would they be combined?
I suppose you could average them and find the slope direction of it.
[2020-03-04 15:13:17]
tommartin321 - Posts: 74
My apologies Tom, I think I forgot to add one important point.

I'm only interested in reading the slope when all three are sloping in the same direction. Therefore, I thought I might be able put them all in one column using an AND function.
[2020-03-04 15:26:10]
Sawtooth - Posts: 3985
I'm only interested in reading the slope when all three are sloping in the same direction.
You could combine them with the AND function but the formula would be very long.

If you have a spare Formula Column, you could use a 4th Formula Column to combine them, but you'll need a third condition when not all are sloped the same:
=IF(AND(O3=1,P3=1,Q3=1),1,IF(AND(O3=-1,P3=-1,Q3=-1),-1,IF(OR(SUM(O3,P3,Q3)<>3,SUM(O3,P3,Q3)<>-3),0,R4)))
This example goes in cell R3.

If you want the slope in degrees, use the Study Angle study.
Study Angle
Date Time Of Last Edit: 2020-03-07 04:45:31
[2020-03-04 15:35:13]
tommartin321 - Posts: 74
If you have a spare Formula Column, you could use a 4th Formula Column to combine them:
=IF(AND(O3=1,P3=1,Q3=1),1,IF(AND(O3=-1,P3=-1,Q3=-1),-1,R4))

Fantastic, thanks tom.
[2020-03-07 04:46:11]
Sawtooth - Posts: 3985
The formula in post #4 has been corrected.

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account