Angle of tangent line to SMA

Created at 05 Mar 2014, 14:45
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
OL

Old Account

Joined 14.10.2013

Angle of tangent line to SMA
05 Mar 2014, 14:45


Hi

I'm trying to find out how to get the angel of the SMA slope, but my problem is that it's hard to find what the x-coordinate should be because they don't have a pip value like the y-coordinate does . Any suggestions on how I can do this 

 

Her is the code i have tried:

protected override void OnStart()
   {
       double y = 1;//SMA LastValue difference to last bar.

       double x = 1;// Don't know :/

       var rad = Math.Atan(y / x);

       var deg = rad * 180 / Math.PI;

       Print(deg);
   }

 


@Old Account
Replies

Spotware
05 Mar 2014, 15:20

Please stop posting duplicating themes. You need to wait until somebody will answer to your question.


@Spotware

Old Account
05 Mar 2014, 19:42

Sorry, I posted it in Indicator Development Support by mistake and i wasn't able to delete it.


@Old Account

Spotware
06 Mar 2014, 09:51

Probably for Y difference you need to take SMA.Result.Last(0) - SMA.Result.Last(1), and X difference equals to 1, because X is index.


@Spotware

Old Account
08 Mar 2014, 17:30

I think if I were to calculate the angle like the Ray chart tool I will need to know the scale to see the distanse in pips one hour is equal to.

Are there any ways to do that ?


@Old Account

Spotware
10 Mar 2014, 08:54

You are right. In order to calculate an angle you need to obtain the chart scale. There is no way to get chart scale at the moment.


@Spotware