Discussions
»
Product and Service Development
»
Formula Assistance
»
Help me develop my Formula ( related with Inside bar)
Rank: Member
Groups: Registered, Registered Users Joined: 8/5/2012(UTC) Posts: 16
|
Hi, I want to write a formula in explorer of Metastock. My key requirements are: 1. 5 day before range of the stock ( open-close or close-open) should be greater than or equal to average of last 20 day range( each day range is calculated by open-close or close-open ) 2. after that stock should move inside of the Big day ( in this case 5 day before) ( inside ) 3. and break above or below the Big day ( which came 5 day before) should be buy or sell with stop as other high or low.
please help me to write this simple exploration formula and also plz tell how will I write this in expert system.
Thanks Ankur
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 5/13/2005(UTC) Posts: 715 Location: Midwest, USA
Was thanked: 1 time(s) in 1 post(s)
|
Item 1 sounds like you're looking for the short-term range expansion to be equal to or greater than the long-term -- your "Big Day" condition.
Item 2 you're going to need to explain more clearly. How does the "stock" move "inside"?
|
|
|
|
Rank: Member
Groups: Registered, Registered Users Joined: 8/5/2012(UTC) Posts: 16
|
let me give u an example.... say the average range of the stock is 3 points ( open-close or close - open , avg taken for last 20 days) 5 days before, that stock abc range becomes 5 points ( so this stock can be considered ) then after this BIG candle rest 4 days are inside the big candle( i.e. open and close are inside high and low of BIG candle for each of the last 4 days) any breakout( on closing basis) above or below the high/low of the big candle is a buy or sell signal. hope this clears my point.
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 5/13/2005(UTC) Posts: 715 Location: Midwest, USA
Was thanked: 1 time(s) in 1 post(s)
|
Give this a try:
Code:{ DEFINE }Range:=Abs(O-C);Range05:=Mov(Range,5,S);Range20:=Mov(Range,20,S);
{ CONDITIONS }RangeExpand:=Range05>=Range20;BigCandle:=Range>=5 AND RangeExpand;BigCandleValue:=ValueWhen(1,BigCandle,Range);Last4:={BarsSince(BigCandle)>=5 AND}Sum(Range<BigCandleValue,4)=0 ANDRangeExpand;
Entry:=CLOSE>ValueWhen(1,Last4,HIGH) AND RangeExpand;Exit:=CLOSE<ValueWhen(1,Last4,LOW) AND RangeExpand;
{ REMOVE EXTRA SIGNALS, +1=Buy -1=Sell }Init:=Cum(IsDefined(entry+exit))=1; { Flag=enough data }Same:=Entry AND Exit; { Same Bar }Signal:=ValueWhen(1,Entry-Exit<>0 OR Init,Entry); { Current Entry }Entry:=If(Same,Entry*(Signal=0),Entry); { Valid }Exit:=If(Same,Exit*Signal,Exit); { Valid }Signal:=ValueWhen(1,Entry-Exit<>0 OR Init,Entry); { Valid Current Entry }Entry:=Signal*(Alert(Signal=0,2) OR Entry*Cum(Entry)=1); { Current or 1st }Exit:=(Signal=0)*(Alert(Signal,2) OR Exit*Cum(Exit)=1); { Current or 1st }Signal:=Entry-Exit; { Filtered }Season:=ValueWhen(1,Signal<>0,Entry)*2-1; { Signal active }
{ DISPLAY }Signal;
|
|
|
|
Rank: Member
Groups: Registered, Registered Users Joined: 8/5/2012(UTC) Posts: 16
|
many thanks Jistein.
[edited by wabbit -- problem already posted in many other threads!]
|
|
|
|
Users browsing this topic |
Guest (Hidden)
|
Discussions
»
Product and Service Development
»
Formula Assistance
»
Help me develop my Formula ( related with Inside bar)
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.