Calculating Slope

Posted By: DonDiego

Calculating Slope - 03/05/23 16:56

Comming from Easylanguage calculating a slope of, ie, a MovingAverage was as simple

MASlope = MA - MA[1];

In C (or lite-C, haven't figured out the difference yet) I tried

vars Prices = series(priceC());
vars MA = series(MovingAverage(Prices,20,MAType_SMA));

vars MASlope = series(MA- MA[1],300)); //300 is the Lookback
or why not MASlope = MA - MA[1]; ?

Appreciate a hint.
Thank you
Posted By: nsg

Re: Calculating Slope - 03/05/23 19:36

Not sure I fully get it, but anyway:
Code
function run()
{
	set(PLOTNOW);

	LookBack = 300;

	vars Prices = series(priceC());
	vars MA = series(SMA(Prices,20));
	vars MASlope = series(MA[0]-MA[1]);

	plot("MA Slope",MASlope,NEW,RED);
}
Posted By: DonDiego

Re: Calculating Slope - 03/05/23 21:58

@nsg, I love you! That worked. Thanks a lot!

Where can I turn to, when I have syntax issues, so that I don't have post ervery tiny problem into the forum?
Posted By: nsg

Re: Calculating Slope - 03/06/23 11:07

It's a pleasure.

I'm afraid, there aren't many options: paid ticket-based support by oP group or trying your luck here on the forum for free. Maybe find yourself a mentor (like me, ha-ha). I'm not aware of any vibrant Zorro communities elsewhere.
Posted By: Grant

Re: Calculating Slope - 03/06/23 12:55

By first reading the manual (code examples!), then the financial hacker website or by searching this forum for keywords.
Posted By: DonDiego

Re: Calculating Slope - 03/06/23 17:11

Originally Posted by Grant
By first reading the manual (code examples!), then the financial hacker website or by searching this forum for keywords.


I read the manual, which is very good btw, and work with it as good as I can.
I'm aware of Financial Hacker website, which is also very interesting but probably not so much of a help as a "junior-Zorro". :-)
Before I post, of course I use the search function.

The thing is, I'm fairly proficient in EasyLanguage and stumbling over the most basic code syntax makes me feel like an idiot, is time consuming and a bit frustrating. But I accept that in order to work with a more flexible and intelligent (or at least different) tool than Tradestation. So I guess I just have to be patient and hang in there...

Anyway, I appreciate the support I get in this Forum - thank you.
Posted By: Grant

Re: Calculating Slope - 03/06/23 19:39

Good to hear that you take those steps. By doing so you will really learn things. Too often I see impatient people over here asking for things that are clearly explained in the manual (oh crap, that includes me during the beginning blush ).

Yeah, EL is completely different. My advice is to start with short and simple code, test it, add/change a few lines, test it again and so on.

Best of luck!
© 2024 lite-C Forums