Converting Metastock formula to SS

StrataSearch has many powerful features, with many techniques and approaches to explore. Here we discuss the things we've done, and the things we'd like to do.

Converting Metastock formula to SS

Postby rjay » Mon Jul 27, 2015 6:44 am

I want to try using Darry Guppy's Countback line as a trailing stop in my AutoSearches and managed to find the Metastock code below.

I've never tried to use a MS formula in SS, but for starters I presume that I replace any instance of 'LLV' with 'Low'. And that just looks like commenting in the curly brackets so I should remove that.

I'm not sure what the 3,55,13 refers to in the LowDays line - I'd hardcode LowDays = 10 anyway. Or is that just something to do with positioning the Input box ?

And this would have to be coded as a Custom Formula, right ?

CBL shows a lot of promise although is a bit tighter than I would normally use.

Code: Select all

LowDays := Input("Enter # days to cover last LOW for CBL calc'n:", 3, 55, 13);

If(LOW > LLV(LOW, LowDays), {then ...} PREV, {previous CBLlo, else...} If(Ref(H,-2) > Ref(H,-1) AND Ref(H,-2) > H AND Ref(H,-1) > H, {then ...} Ref(H,-2), {2nd day back high,else...} If((Ref(H,-3)> Ref(H,-2) AND Ref(H,-3) > Ref(H,-1) AND Ref(H,-3) > H) AND (Ref(H,-2)> H OR Ref(H,-1) > H), {then ... } Ref(H,-3), {3rd day back high,else...} If((Ref(H,-4)> Ref(H,-3) AND Ref(H,-4) > Ref(H,-2) AND Ref(H,-4) > Ref(H,-1) AND Ref(H,-4) > H) AND (Ref(H,-3)> H OR Ref(H,-2) > H OR Ref(H,-1) > H), {then... } Ref(H,-4), {4th day back high,else...} If((Ref(H,-5)> Ref(H,-4) AND Ref(H,-5) > Ref(H,-3) AND Ref(H,-5) > Ref(H,-2) AND Ref(H,-5) > Ref(H,-1) AND Ref(H,-5) > H) AND (Ref(H,-4)> H OR Ref(H,-3) > H OR Ref(H,-2) > H OR Ref(H,-1) > H), {then ...} Ref(H,-5), {5th day back high,else...} PREV ))))) 
Posts: 116
Joined: Wed Jul 26, 2006 6:51 am

Re: Converting Metastock formula to SS

Postby Overload » Mon Jul 27, 2015 11:46 am

There's no guarantee that all MetaStock code can convert exactly to StrataSearch, and I'm not an expert on MetaStock code. But I can at least offer some tips.

* The LLV() in MetaStock converts to the Low() in StrataSearch.

* Yes, I'm pretty sure the curly brackets are comments.

* The Input() formula in MetaStock works as a parameter that I think might also contain a high/low range. But in a StrataSearch custom formula, you would use the parameter() formula to identify an input variable.

* MetaStock uses a unique PREV macro to identify the prior bar's value for a variable. It's this function that might be the most difficult to replicate in StrataSearch (or most other technical analysis programs since it is unique to MetaStock). However, StrataSearch contains a $PREV macro that is able to simulate it in many cases.

Apart from the above, MetaStock code and StrataSearch code are pretty similar, so the conversion shouldn't be too difficult.

Posts: 2248
Joined: Wed Nov 30, 2005 12:14 pm

Return to General Discussion