logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
marco1971  
#1 Posted : 9 years ago
marco1971

Rank: Newbie

Groups: Registered Users, Subscribers
Joined: 3/15/2016(UTC)
Posts: 1

Hi,

I'd like to test a system where a buy or sell order is given by a custom indicator. I need this one is below or above zero for "at least" a certain number of bars. How can I do this with the barssince function?

Let's name A my indicator, is it correct, for example: barssince(A<0)>"number of bars"? And can I optimize the variable "numer of bars.

Thank you

Regards

Marco1971

MS Support  
#2 Posted : 9 years ago
MS Support

Rank: Advanced Member

Groups: Moderators, Registered, Registered Users, Subscribers
Joined: 10/8/2010(UTC)
Posts: 1,974

Thanks: 95 times
Was thanked: 158 time(s) in 153 post(s)

Should work to use the opposite condition, you may also want to use 'or equal to' to rule out if the value is exactly 0:

BarsSince(A<=0)>=3

Another option might be to Sum the condition over a number of periods, i.e.:

Sum(A>0,3)>=3

Whenever a condition is true, it would return a value of 1, so summing a true over 3 periods should equal 3 if true for 3 periods in a row. This may be more reliable in some cases where there might not be a perfect opposite condition to consider. You can Optimize numerical values in the system tester by using OPT1, OPT2, etc. and then defining the range of numbers you want to test between within the Optimizations tab.

As in the example above:

BarsSince(A<=0)>=OPT1

or in my example:

Sum(A>0,OPT1)>=OPT1

Edited by user 9 years ago  | Reason: Not specified

Users browsing this topic
Guest (Hidden)
Similar Topics
Barssince Stoch Osc (Basic Coding Techniques)
by sevenvironment 2 years ago
barssince() has problems when the condition never happened (MetaStock)
by yonyon191719 6 years ago
Moving Average and Barssince (Basic Coding Techniques)
by JayB 8 years ago
BarsSince and Cross (Formula Assistance)
by stinkray 9 years ago
BarsSince sintax (Formula Assistance)
by Leverage 10 years ago
How can i find barssince of event cross(macd(),0) by nth=2 (Formula Assistance)
by atitats 10 years ago
Fun with BarsSince event (Advanced Coding Techniques)
by Lloyd_au 11 years ago
BarsSince event (Formula Assistance)
by Gherkin 11 years ago
How can i omit the current bar in a BARSSINCE function? (MetaStock)
by xrousaios 11 years ago
barssince() (MetaStock)
by Flexi 13 years ago
StockRSI Modify (BarsSince) (Formula Assistance)
by GameTime 14 years ago
BarsSince() help (Formula Assistance)
by v.trader 15 years ago
question of Barssince and Sum function (Formula Assistance)
by metaken 16 years ago
Barssince, Max% DD question (Basic Coding Techniques)
by zigzag 16 years ago
Basic Barssince Question (Formula Assistance)
by AMSH 16 years ago
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

information You have 1 unread message(s) in your Inbox.