20 day new high/low  [SOLVED]

Questions about MultiCharts and user contributed studies.
treksis
Posts: 13
Joined: 18 Jul 2014
Has thanked: 4 times

20 day new high/low

Postby treksis » 23 Jul 2014

Hi, I've been searching a way to find the 20 day high/low and I was only partially able to find the one I thought.

The problem here is that if, on the upcoming days the bulls take over and keep breaking new highs, I will have a chain reaction of alerts coming off.

So, in order to prevent that I'd like to put a TIME GAP, between new highs and new lows.
For instance, I want to make the indicator to alert only if 20day high/low is reached AND there was a time gap of AT LEAST 1 month between the previous high/low.
Can someone help me how to put the time gap?
if there are no time gap, is there any other way I can make that happen?

two more questions:
is there a way to exit/close my open positions at a specified time? like at 3pm.
I could only find : setexitonclose.

lastly, is there a way to set a limit order NOT on close,at market, but rather something like previous 20day high/low?



Thanks.


Code: Select all


if high > highest(high, 1560)[20] then buy ....
if low > lowest(lowest, 1560)[20] then short sell...

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: 20 day new high/low

Postby TJ » 24 Jul 2014

What is your chart resolution?

Daily chart?
5 min chart?

treksis
Posts: 13
Joined: 18 Jul 2014
Has thanked: 4 times

Re: 20 day new high/low

Postby treksis » 24 Jul 2014

I use 5min chart the most.

User avatar
furytrader
Posts: 354
Joined: 30 Jul 2010
Location: Chicago, IL
Has thanked: 155 times
Been thanked: 217 times

Re: 20 day new high/low  [SOLVED]

Postby furytrader » 24 Jul 2014

For analyzing the 20-day high, low, etc. your best bet is likely to insert a second instrument on your chart (data2) and make that a daily chart of whatever market you're following. This will make it MUCH easier to calculate highest high, lowest low, etc.

Next, check out the PowerLanguage functions called HIGHESTBAR and LOWESTBAR - this will enable you to determine the number of bars between highest highs or lowest lows.

As for exiting at a specific time, yes, you can do that - just use the TIME function. i.e., IF TIME = 1500 THEN SELL THIS BAR ON CLOSE. Note that if your chart does NOT show a bar with a time of 1500, you will not place an order (I would continue to use the setexitonclose as a protective measure).

As for limits, yes, there is: BUY NEXT BAR AT LOWEST(LOW of data2,20) LIMIT;

... where data2 is your daily data and 20 is your lookback period, for example.

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: 20 day new high/low

Postby TJ » 24 Jul 2014

check out the following functions, they are in your PowerLanguage Editor.

HighD
LowD
HighW
LowW
HighM
LowM

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: 20 day new high/low

Postby JoshM » 27 Jul 2014

The problem here is that if, on the upcoming days the bulls take over and keep breaking new highs, I will have a chain reaction of alerts coming off.
Wiki: Once per bar alert.


Return to “MultiCharts”