Simple Range Breakout indicator

Questions about MultiCharts and user contributed studies.
Micardo
Posts: 7
Joined: 26 Feb 2011

Simple Range Breakout indicator

Postby Micardo » 26 Feb 2011

Hi,

I am attempting to learn easylanguage and have been working through the document trying the exercises etc.

I am struggling with my own attempt at a strategy and was wondering if someone could give me a pointer as to what I am doing wrong.

Below is the code, I am only trying to get the vuys working at this moment hence not much there, but when I add the signal to my charts I don't see any buy orders opened.

Code: Select all

value1 = Highest(High, 20);
condition1 = value1 < Close;

if condition1 then buy next bar at market;


Please let me know what I am doing wrong.

Thank you

User avatar
TJ
Posts: 6551
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 966 times
Been thanked: 1892 times

Re: Simple Range Breakout indicator

Postby TJ » 26 Feb 2011

Micardo wrote:Hi,

I am attempting to learn easylanguage and have been working through the document trying the exercises etc.

I am struggling with my own attempt at a strategy and was wondering if someone could give me a pointer as to what I am doing wrong.

Below is the code, I am only trying to get the vuys working at this moment hence not much there, but when I add the signal to my charts I don't see any buy orders opened.

Code: Select all

value1 = Highest(High, 20);
condition1 = value1 < Close;

if condition1 then buy next bar at market;


Please let me know what I am doing wrong.

Thank you

I always suggest to people...

DO NOT jump into strategies.

Start with an indicator....

use the plot statement to plot a line or a dot of your variables,
so that you can see how they interact with one another.

eg:

Code: Select all

plot100( value1 , "Highest High");
plot200( close , "close");



...you will soon find your answer.

janus
Posts: 747
Joined: 25 May 2009
Has thanked: 41 times
Been thanked: 83 times

Re: Simple Range Breakout indicator

Postby janus » 27 Feb 2011

The highest high of the last 20 bars has to be at least as high as the current high. So, it's impossible for it to be lower than the current close. Perhaps you meant to find the highest high of the last 20 bars excluding the current bar. Then it's possible to have a current close above all the previous 19 highs for a break-out. As far as I know there's no built-in function to compute such a highest high so you need to write your own.

Addendum:
However, TJ's suggestion is still worth your while if you are young at programming in any language. I tend to check my logic first then if all else fails to explain why something is not behaving as I expected, then I plot an indicator (or several indicators) as a useful debugging aid.

User avatar
virginiatrader
Posts: 79
Joined: 05 May 2007
Location: Virginia
Has thanked: 5 times
Been thanked: 5 times

Re: Simple Range Breakout indicator

Postby virginiatrader » 28 Feb 2011

Micardo:

I use something in a similar fashion...as a breakout over the highest HIGH or lowest LOW of the past N-days; however, I do not reference the CLOSE as being less than a HIGH or LOW...

if CLOSE > highest(HIGH,20) [1]
then buy one contract next bar at open:

if CLOSE < lowest(LOW,20) [1]
then sellshort one contract next bar at open;

The square brackets "[1]" reference the previous bar, since a current CLOSE cannot be higher or lower than the CURRENT BAR HIGH or CURRENT BAR LOW.

This may start you in the right direction.

virginiatrader

Micardo
Posts: 7
Joined: 26 Feb 2011

Re: Simple Range Breakout indicator

Postby Micardo » 01 Mar 2011

Hi Everyone,

Thanks for your input. I managed to work it out in the end but thank you all for your help and efforts.

User avatar
TJ
Posts: 6551
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 966 times
Been thanked: 1892 times

Re: Simple Range Breakout indicator

Postby TJ » 01 Mar 2011

Micardo wrote:Hi Everyone,

Thanks for your input. I managed to work it out in the end but thank you all for your help and efforts.

as a courtesy to the community, you should post your solution.

Micardo
Posts: 7
Joined: 26 Feb 2011

Re: Simple Range Breakout indicator

Postby Micardo » 01 Mar 2011

Hi,

Sorry I didn't realise that was the etiquette.

Here it is

Code: Select all

value99 = Highest(High[1], 20);
condition1 = Close > value99;

if condition1 then buy("20 Day Long") next bar at market;

value98 = Lowest(Low[1], 10);
condition2 = Close < value98;

if condition2 then sell("Close 20 Day Long") next bar at market;


value97 = Lowest(Low[1], 20);
condition3 = Close < value97;

if condition3 then sellshort("20 Day Short") next bar at market;

value96 = Highest(High[1], 10);
condition4 = Close > value96;

if condition4 then buytocover("Close 20 Day Short") next bar at market;


Return to “MultiCharts”