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

Notification

Icon
Error

Options
Go to last post Go to first unread
Gregor  
#1 Posted : Sunday, November 7, 2010 11:25:20 AM(UTC)
Gregor

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 6/12/2007(UTC)
Posts: 32

I have a formula for plotting envolpes on a chart which is as follows

{Envlopes}
x:=Input("Short Term Moving Average",7,14,7);
y:=Input("Upper Band",1.01,1.99,1.05);
z:=Input("Lower Band",0.01,0.99,0.95);
a:=x*5;
Mov(C,x,E);
Mov(C,x,S)*y;
Mov(C,x,S)*z;
Mov(C,a,S);

I want to have only one input varaible that applys to both upper and lower bands of the envolpe (that is to lose one of the x or y input varaibles). My attempt aren't working and need help. The coding I've tried is below

{Envlopes}
x:=Input("Short Term Moving Average",7,14,7);
y:=Input("Envelopes Percentage varation",1,99,5);
a:=x*5;

Mov(C,x,E);
Mov(C,x,S)*(y/100);
Mov(C,x,S)*((y/100)*1);
Mov(C,a,E);

wabbit  
#2 Posted : Sunday, November 7, 2010 4:59:16 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)
Code:

{Envelopes}
x:=Input("Short Term Moving Average",7,14,7);
y:=Input("Envelopes Percentage variation",1,99,5)/100;
a:=x*5;

Mov(C,x,E);
Mov(C,x,S)*(1+y);
Mov(C,x,S)*(1-y);
Mov(C,a,E);


Have you mixed up the moving average types on purpose?


wabbit [:D]

blashablinc  
#3 Posted : Sunday, November 7, 2010 6:29:57 PM(UTC)
blashablinc

Rank: Newbie

Groups: Registered, Registered Users
Joined: 10/6/2010(UTC)
Posts: 9

I have bands I really like and I used atr(13) and added it to a double smooth ma (a moving avg of a moving avg) for the top and subtracted it for the bottom ... like this...

x:=Input("Number ATR Periods", 1,500,13);
y:=Input("Number of MA Periods",1,50,7);
z:=Input("Number of inner MA Periods",1,50,3);

MovTypPrice:=Mov(Typical(),z,E);
MovMovTP:=Mov(MovTypPrice,y,E);
atrplot:=ATR(x);
MovMovTP+(2*atrplot);
MovMovTP+atrplot;
MovMovTP;
MovMovTP-atrplot;
MovMovTP-(2*atrplot);

Maybe you could try something like this[:D]??? Or consider it food for thought. I also have used it with weighted ma (w) and volumeadjusted (vol).
Ron

Gregor  
#4 Posted : Tuesday, November 9, 2010 9:03:45 AM(UTC)
Gregor

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 6/12/2007(UTC)
Posts: 32

Thanks wabbit

Your formula has answers my question. Yes I'm using different moving averages on puropose, the long and short moving average are expedentional as I want weight to be on most current data, this isn't so important with the bands.

Thanks again

Gregor

Gregor  
#5 Posted : Tuesday, November 9, 2010 9:07:44 AM(UTC)
Gregor

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 6/12/2007(UTC)
Posts: 32

Thanks blashablinc

I haven't hear on using band in that way and its certainly food for thought. Will have a look at it.

Gregor

Gregor  
#6 Posted : Tuesday, November 9, 2010 4:44:23 PM(UTC)
Gregor

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 6/12/2007(UTC)
Posts: 32

Wabbit

I have applied your formula for envelopes to my custom indicator used for identifying trading setups. I've found that when setting the input variable above the defualt values the indicator is removed from the chart's inner window. Can you see why this happening and is there a solution?

There is in the formula a market switch (35day simple moving average) that enable me to identify both long and short setups. I've found reducing this moving average seem to make the problem worse.

Setup custom Indicator

x:=Input("Short Term Moving Average",7,14,7);
y:=Input("Envelopes Percentage variation",1,99,5)/100;

EMA:=Mov(C,x,E);
UB:=Mov(C,x,S)*(1+y);
LB:=Mov(C,x,S)*(1-y);

B1:= H>UB AND H<=UB+(0.75*Abs(EMA-UB)) AND ValueWhen(1, H>UB, UB>Ref(UB,-1) );
B2:= L>EMA AND H<UB;

abort:=(Sum(ub>Ref(ub,-1),3)=3 AND Sum(B2,2) = 2 AND Ref(B1, -2) AND Ref(L<EMA,-3)) OR
(H>UB+(0.75*Abs(EMA-UB)));
bdown:= L<=LB;
bup:= BarsSince(C<EMA) < BarsSince(abort) AND H>UB;

notrade:= If(Abort, 1, If(Bdown OR Bup, 0, PREV));

B12:= (B1 OR B2) AND Mov(C,35,S)>Ref(Mov(C,35,S),-1) AND notrade=0;


B3:= L<LB AND L>=LB-(0.75*Abs(EMA-LB))AND ValueWhen(1, L<LB, LB<Ref(LB,-1) );
B4:= EMA>H AND L>LB;

AbortS:=(Sum(LB<Ref(LB,-1),3)=3 AND Sum(B4,2)=2 AND Ref(B3,-2) AND Ref(H>EMA,-3)) OR
(L<LB-(0.75*Abs(EMA-LB)));
BdownS:= H>=UB;
BupS:= BarsSince(C>EMA) > BarsSince(AbortS) AND L<LB;

notradeS:=If(AbortS, 1, If(BdownS OR BupS, 0, PREV));

B34:= (B3 OR B4) AND Mov(C,35,S)<Ref(Mov(C,35,S),-1) AND notradeS=0;

If(B12, 2, If(B34, 1, 0));

wabbit  
#7 Posted : Tuesday, November 9, 2010 5:12:50 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)
Gregor wrote:
I have applied your formula for envelopes to my custom indicator used for identifying trading setups. I've found that when setting the input variable above the defualt values the indicator is removed from the chart's inner window. Can you see why this happening and is there a solution?


My bands code works fine for me...
Gregor  
#8 Posted : Wednesday, November 10, 2010 8:22:15 AM(UTC)
Gregor

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 6/12/2007(UTC)
Posts: 32

Wabbit

The code for the bands do work fine, its when I've merge this code with my formula for a custom indcator identifying setups, I am having the problem. At any short term moving average setting with a envelope pecentage varation of 6 or above and the indicator is removed from the inner window of the chart.

If there was no setup signals I would have expected to see a straight line at zero, but there is none. I wonder if the 35day simple moving average I am using to switch between long and short side setups does not having enough price data to work. But I don't see how that could be the case as these are the same moving averages applied on the main price chart along with your bands code and both work without any problems.

Why when the envelope pecentage varation is 6 or above does the this custom indicator disappear from the inner chart window?

Gregor

wabbit  
#9 Posted : Wednesday, November 10, 2010 5:07:39 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)
If you're using a 35 period MA then MS returns N/A for the first 34 bars. Your code also uses ValueWhen() and BarsSince(); if the events being looked for have not yet occurred then those functions return N/A. The entire indicator will return N/A until at least one condition is met on every line of code.

Add more data to the chart in the hope the indicator will intialise when it sees more history (and therfore a higher chance of all of the required events triggering), or use some of the other "tricks" to deal with N/A bars -- much has been written already on the forum.



wabbit [:D]

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.