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

Notification

Icon
Error

Options
Go to last post Go to first unread
yachtfund  
#1 Posted : Wednesday, June 28, 2006 9:23:06 AM(UTC)
yachtfund

Rank: Member

Groups ready for retrieval: Registered, Registered Users
Joined: 5/22/2006(UTC)
Posts: 27

Hi All Does anyone have any good previous days high/low breakout for an hourly chart? Or some links? Many Thanks YachtFund
wabbit  
#2 Posted : Wednesday, June 28, 2006 9:38:22 AM(UTC)
wabbit

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/28/2004(UTC)
Posts: 3,111
Location: Perth, Western Australia

Was thanked: 16 time(s) in 16 post(s)
If you are wanting to display daily data on an intraday chart, then check out Roy Larsen's excellent collection of indicatorson his website: http://www.metastocktips.co.nz/ Hope this helps. wabbit :D
yachtfund  
#3 Posted : Wednesday, June 28, 2006 11:32:21 AM(UTC)
yachtfund

Rank: Member

Groups ready for retrieval: Registered, Registered Users
Joined: 5/22/2006(UTC)
Posts: 27

Thats for that Wabbit (great name by the way). I'm really after the code to a back test that would do something like calculate the previous days high and low and buy or sell on breakouts. Within that have some optimisations such as buy/sell at 10 pips above/below the high/low and vary stops etc. And all this on hourly charts. I need to read the manual but I thought someone must have this as I believe its a commone strategy. Cheers YachtFund
yachtfund  
#4 Posted : Wednesday, June 28, 2006 5:13:22 PM(UTC)
yachtfund

Rank: Member

Groups ready for retrieval: Registered, Registered Users
Joined: 5/22/2006(UTC)
Posts: 27

I want to create a variable in my backtest that stores the previous days high, but from an hourly chart. How do I do that? In a daily chart it would be something like this:- yesterdaysHigh:= ref(h,-1); In an hourly chart that wont work.... Thanks All
wmadani  
#5 Posted : Wednesday, June 28, 2006 6:26:48 PM(UTC)
wmadani

Rank: Member

Groups: Registered, Registered Users
Joined: 4/28/2006(UTC)
Posts: 10

the formula Ref(h,-1) refers to yesterday's high if used on a daily chart or data , also it refers to last hour high when used on hourly data . So in brief it always reference to previous bar of the periodcity you are using . Regards
yachtfund  
#6 Posted : Wednesday, June 28, 2006 6:58:58 PM(UTC)
yachtfund

Rank: Member

Groups ready for retrieval: Registered, Registered Users
Joined: 5/22/2006(UTC)
Posts: 27

Hi wmadani Thanks for the reply but thats not quite what I am after. I need to know the previous days high and low but in an hourly chart. Cheers YF
Jose  
#7 Posted : Wednesday, June 28, 2006 8:34:04 PM(UTC)
Jose

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 1/19/2005(UTC)
Posts: 1,065
Location: Koh Pha-Ngan, Earth

Was thanked: 2 time(s) in 2 post(s)
Try this intraday chart indicator from MetaStockTools.com: [code:1:8a5f3ebe66] ========== Daily OHLC ========== ---8<--------------------------- { Daily Open/High/Low/Close v3.0 For intraday charts. ©Copyright 2002~2006 Jose Silva. The grant of this license is for personal use only - no resale or repackaging allowed. All code remains the property of Jose Silva. http://www.metastocktools.com } { User inputs } pds:=Input("Day's OHLC: [1]Current (dynamic), [2]Previous",1,2,2); plotOp:=Input("plot daily Open? [1]Yes, [0]No",0,1,1); plotHi:=Input("plot daily High? [1]Yes, [0]No",0,1,1); plotLo:=Input("plot daily Low? [1]Yes, [0]No",0,1,1); { Day's Start } SOD:=DayOfMonth()<>Ref(DayOfMonth(),-1) OR Cum(1)=2; { Day's Open } dOp:=ValueWhen(pds,SOD,O); dOp:=ValueWhen(1,dOp>0,dOp); { Day's High } Hi:=HighestSince(1,SOD,H); dHi:=If(pds=1,Hi,ValueWhen(1,SOD,Ref(Hi,-1))); dHi:=ValueWhen(1,dHi>0,dHi); { Day's Low } Lo:=LowestSince(1,SOD,L); dLo:=If(pds=1,Lo,ValueWhen(1,SOD,Ref(Lo,-1))); dLo:=ValueWhen(1,dLo>0,dLo); { Day's Close } dCl:=If(pds=1,C, ValueWhen(1,SOD,Ref(C,-1))*(Cum(SOD)>1)); dCl:=ValueWhen(1,dCl>0,dCl); { Hide OHL price plots } dOp:=If(plotOp,dOp,dCl); dHi:=If(plotHi,dHi,dCl); dLo:=If(plotLo,dLo,dCl); { Plot on price chart } dOp; { <- Open: Violet} dHi; { <- High: Blue } dLo; { <- Low: Red } dCl; { <- Close: Green } ---8<--------------------------- [/code:1:8a5f3ebe66] jose '-)
yachtfund  
#8 Posted : Thursday, June 29, 2006 9:51:12 AM(UTC)
yachtfund

Rank: Member

Groups ready for retrieval: Registered, Registered Users
Joined: 5/22/2006(UTC)
Posts: 27

Many thanks Jose.
yachtfund  
#9 Posted : Thursday, June 29, 2006 1:01:16 PM(UTC)
yachtfund

Rank: Member

Groups ready for retrieval: Registered, Registered Users
Joined: 5/22/2006(UTC)
Posts: 27

Hi I dont understand why this works and what it does:- SOD:=DayOfMonth()<>Ref(DayOfMonth(),-1) OR Cum(1)=2; Is it an if statement? Thanks YF
wabbit  
#10 Posted : Thursday, June 29, 2006 1:39:49 PM(UTC)
wabbit

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/28/2004(UTC)
Posts: 3,111
Location: Perth, Western Australia

Was thanked: 16 time(s) in 16 post(s)
SYNTAX dayofmonth() FUNCTION Plots the day of the month. If today was July 15th, "15" would be plotted. So if DoM on this bar is not the same as the DoM on the previous bar = = its a new day. Cum(1)=2 is the second bar on the chart.... SOD will be given the value 1 (TRUE) if its a new day or the second bar on the chart. The second bar is being used to align with the fact that a comparison is being made in the DoM with the DoM on th eprevious bar i.e Cum(1)=1. Hope this helps. wabbit :D
yachtfund  
#11 Posted : Thursday, June 29, 2006 3:15:02 PM(UTC)
yachtfund

Rank: Member

Groups ready for retrieval: Registered, Registered Users
Joined: 5/22/2006(UTC)
Posts: 27

Thanks wabbit. So if this plots yesterdays high:- SOD:=DayOfMonth()<>Ref(DayOfMonth(),-1) OR Cum(1)=2; { Day's High } Hi:=HighestSince(1,SOD,H); dHi:=ValueWhen(1,SOD,Ref(Hi,-1)); dHi:=ValueWhen(1,dHi>0,dHi); dHi; { <- High: Blue } How do I get it to ignore weekends? I shall read the manual a bit more.
jssuccess  
#12 Posted : Sunday, April 19, 2009 2:03:42 AM(UTC)
jssuccess

Rank: Member

Groups: Registered, Registered Users
Joined: 4/15/2009(UTC)
Posts: 14

Dear all,

Would I get the same result if I set SOD:=DayOfMonth()<>ref(DayOfMonth(),-1) ?

Can I ignore cum(1)=2 in the SOD formula ?

wabbit  
#13 Posted : Sunday, April 19, 2009 2:34:18 AM(UTC)
wabbit

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/28/2004(UTC)
Posts: 3,111
Location: Perth, Western Australia

Was thanked: 16 time(s) in 16 post(s)
You can if you know what it does and you don't want it.

With the fourm.dll, you can also get rid of the first N/A bar and move the initialisation back to the first bar of the chart:

Code:

SOD:=DayOfMonth()<>ref(DayOfMonth(),-1);
SOD:=extfml("forum.sum",SOD,1) or Cum(1)=1;



wabbit [:D]

jssuccess  
#14 Posted : Sunday, April 19, 2009 3:15:19 AM(UTC)
jssuccess

Rank: Member

Groups: Registered, Registered Users
Joined: 4/15/2009(UTC)
Posts: 14

Wabbit,

What is the purpose of putting cum(1)=2 into the SOD formula ?

Many tks

wabbit  
#15 Posted : Sunday, April 19, 2009 5:36:32 AM(UTC)
wabbit

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/28/2004(UTC)
Posts: 3,111
Location: Perth, Western Australia

Was thanked: 16 time(s) in 16 post(s)
It's a long story about how the Ref() function will return N/A on the first bar of the chart, but the Cum(1)=2 will return true on the second bar of the chart: This initialises the SOD variable so it returns true to include all the data since the beginning of the chart and before the first time the DayOfMonth() changes.


wabbit [:D]

jssuccess  
#16 Posted : Sunday, April 19, 2009 5:48:39 AM(UTC)
jssuccess

Rank: Member

Groups: Registered, Registered Users
Joined: 4/15/2009(UTC)
Posts: 14

Wabbit,

I got it.

Cheers

ROMEO TRADER  
#17 Posted : Friday, August 16, 2013 4:50:34 AM(UTC)
ROMEO TRADER

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 8/16/2013(UTC)
Posts: 5

Hi All,

I'm looking for a N-day breakout expert that would give a buy signal when the close rises above the highest high value over the last N bars and would similarly give a sell signal when the close drops below the lowest low value over the last N bars.
this could be formulated as:
C > HHV(H, N) for a buy signal
and
C < LLV(L,N) for a sell signal
where N can be any normal, arbitrarily chosen, constant lookback period.

my problem is: what if I wanted the lookback period to change depending on changes in volatility?
for example by setting that N = 14* (Long term volatility / Short term volatility)

I thought I could do with:
N:=Int(14 * ( ATR(20) / ATR(10) ));
C > HHV(H,-N)

but I get an error message saying that "This variable or expression must contain only constant data".

I a true beginner, so I would appreciate any help with this.

thanks in advance for any response.
cheers.
Romeo Trader ;-)
Users browsing this topic
Guest (Hidden)
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.