[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Shiting an MA into the future...



PureBytes Links

Trading Reference Links

Hello,


Try the "Mov Avg - Displaced" I think it is a stock TS
indicator.
It has inputs for:
Price,Legnth and Displace.

If you dont have it I will send you the .ela

Alan


{
*******************************************************************
   
	Study		: Mov Avg Displaced
	
	Last Edit	: 1/19/96

	Provided By	: Omega Research, Inc. (c) Copyright 1996

********************************************************************}
Input : Price(Close), Length(6), Displace(4);
Vars : AvgValue(0), LongTermTrend(0),
ShortTermTrend(0), nocommentary(TRUE), AbsDisplace(0),
String1("");

if Displace >= 0 and currentbar > Displace 
then begin
	AvgValue = Average(Price,Length)[Displace];
	plot1(AvgValue,"AvgDisplace");

	#BeginCmtryOrAlert
		if Average(Price,Length)[Displace] >=
Average(Price,Length)[Displace + 1] and Price >=
Average(Price,Length)[Displace] then 
			LongTermTrend = 1;
		if Average(Price,Length)[Displace] <
Average(Price,Length)[Displace + 1] and Price <
Average(Price,Length)[Displace] then 
			LongTermTrend = -1;

		if AtCommentaryBar or CheckAlert
		then begin   
			String1="";
			String1=String1+"Conventional Interpretation: ";  
{ Conventional Interpretation }
			nocommentary = TRUE;
			if Price >= plot1 
			then begin
				String1=String1+"Price is above the moving average
so the trend is up. ";
				nocommentary = FALSE;
			end;
			if Price < plot1 
			then begin
				String1=String1+"Price is below the moving average
so the trend is down. ";
				nocommentary = FALSE;
			end;
			if nocommentary then 
				String1=String1+"The displaced moving average is
inconclusive on this bar. ";
			String1=String1+NewLine;
			String1=String1+NewLine;
			{ end of Conventional Interpretation }

			String1=String1+"Additional Analysis: ";
			if LongTermTrend = 1 
			then begin
				ShortTermTrend = 1; { initialize variable every
bar to Up }
				if LongTermTrend[1] <> 1 
				then begin
					String1=String1+"CAUTION: The market trend has
changed direction. ";
					String1=String1+"Now the trend is UP! ";
					alert = TRUE;
				end
				else
					String1=String1+"Market trend is UP. ";
				if Price < plot1 and plot1 >= plot1[1] 
				then begin
					String1=String1+"Even though the moving average
is in an upward slope from the previous ";
					String1=String1+"bar, the prices are trading
below the moving average line. "; 
					String1=String1+"if prices trade above the moving
average then the trend will be ";
					String1=String1+"clearly established as up. For
the time being, ";
					String1=String1+"we'll continue to call the
market trend UP. ";
					String1=String1+"if your other indicators are
\hbbullish\he, this may be a good buying opportuni";
					String1=String1+"ty. ";
					alert = TRUE;
				end;
				if Price > plot1 and plot1 < plot1[1] 
				then begin
					String1=String1+"Even though prices are trading
above the moving average, the ";
					String1=String1+"moving average slope is down
from the previous bar. if price continues upwards,";
					String1=String1+" the moving average will
eventually follow and then the up trend will be ";
					String1=String1+"more clearly established. For
the time being, we'll continue to call the market";
					String1=String1+" trend UP. ";
				end;
			end; { if LongTermTrend = 1 }
			if LongTermTrend = -1 
			then begin
				ShortTermTrend = -1; { initialize variable every
bar to Up }
				if LongTermTrend[1] <> -1 
				then begin
					String1=String1+"CAUTION: The market trend has
changed direction. ";
					String1=String1+"Now the market trend is DOWN! ";
					alert = TRUE;
				end
				else
					String1=String1+"The market trend is DOWN. ";
				if Price < plot1 and plot1 >= plot1[1] 
				then begin
					String1=String1+"Even though prices are trading
below the moving average, the ";
					String1=String1+"moving average slope is up from
the previous bar. if price continues downwards,";
					String1=String1+" the moving average will
eventually follow and then the down trend will be ";
					String1=String1+"more clearly established. For
the time being, we'll continue to call the market";
					String1=String1+" trend DOWN. ";
				end;
				if Price > plot1 and plot1 < plot1[1] 
				then begin
					String1=String1+"Even though the moving average
is in an downward slope from the previous ";
					String1=String1+"bar, the prices are trading
above the moving average line. "; 
					String1=String1+"if prices trade below the moving
average then the trend will be more ";
					String1=String1+"clearly established as down. For
the time being, ";
					String1=String1+"we'll continue to call the
market trend DOWN. ";
					String1=String1+"if your other indicators are
\hbbearish\he, this may be a good ";
					String1=String1+"\hbshort\he selling opportunity.
";
					alert = TRUE;
				end;
			end;
			commentary(String1);
		End;
	#End;
end; { if Displace >= 0 }
	
if Displace < 0 and CurrentBar > AbsValue(Displace) 
then begin
	AvgValue = Average(Price,Length);
	plot1[AbsValue(Displace)](AvgValue,"AvgDisplace");
	
	#BeginCmtryOrAlert
		AbsDisplace = AbsValue(Displace);

		if Average(Price,Length) >= Average(Price,Length)[1]
and 
			Price[AbsDisplace] >= Average(Price,Length) then
LongTermTrend = 1;
		if Average(Price,Length) < Average(Price,Length)[1]
and 
			Price[AbsDisplace] < Average(Price,Length) then
LongTermTrend = -1;
	
		if AtCommentaryBar
		then begin   
			String1=String1+"Note: Because of the setting you
have chosen for the displacement, ";
			String1=String1+"this indicator is always
"+NumToStr(AbsDisplace,0)+" bars behind the market. ";
			String1=String1+"Therefore all commentary will be
for "+NumToStr(AbsDisplace,0)+ " bars ago. ";
			String1=String1+NewLine;
			String1=String1+NewLine;
			String1=String1+"Conventional Interpretation: ";  
{ Conventional Interpretation }
			nocommentary = TRUE;
			if Price[AbsDisplace] >= plot1[AbsDisplace] 
			then begin
				String1=String1+"Price is above the moving average
so the trend is up. ";
				nocommentary = FALSE;
			end;
			if Price[AbsDisplace] < plot1[AbsDisplace] 
			then begin
				String1=String1+"Price is below the moving average
so the trend is down. ";
				nocommentary = FALSE;
			end;
			if nocommentary then 
				String1=String1+"The displaced moving average is
inconclusive on this bar. ";
	
			String1=String1+"Additional Analysis: ";
			if LongTermTrend = 1 
			then begin
				ShortTermTrend = 1; { initialize variable every
bar to Up }
				if LongTermTrend[1] <> 1 
				then begin
					String1=String1+"CAUTION: The market trend has
changed direction. ";
					String1=String1+"Now the trend is UP! ";
					alert = TRUE;
				end
				else
					String1=String1+"The market trend is UP. ";
	
				if Price[AbsDisplace] < plot1[AbsDisplace] and
plot1[AbsDisplace] >= plot1[AbsDisplace + 1] 
				then begin
					String1=String1+"Even though the moving average
is in an upward slope from the previous ";
					String1=String1+"bar, the prices are trading
below the moving average line. "; 
					String1=String1+"if prices trade above the moving
average then the trend will be ";
					String1=String1+"clearly established as up. For
the time being, ";
					String1=String1+"we'll continue to call the
market trend UP. ";
					String1=String1+"if your other indicators are
\hbbullish\he, this may be a good buying opportuni";
					String1=String1+"ty. ";
					alert = TRUE;
				end;
				if Price[AbsDisplace] > plot1[AbsDisplace] and
plot1[AbsDisplace] < plot1[AbsDisplace + 1] 
				then begin
					String1=String1+"Even though prices are trading
above the moving average, the ";
					String1=String1+"moving average slope is down
from the previous bar. if price continues upwards,";
					String1=String1+" the moving average will
eventually follow and then the up trend will be ";
					String1=String1+"more clearly established. For
the time being, we'll continue to call the market";
					String1=String1+" trend UP. ";
				end;
			end; { if LongTermTrend = 1 }
	  
			if LongTermTrend = -1 
			then begin
				ShortTermTrend = -1; { initialize variable every
bar to Up }
				if LongTermTrend[1] <> -1 
				then begin
					String1=String1+"CAUTION: The market trend has
changed direction. ";
					String1=String1+"Now the market trend is DOWN! ";
					alert = TRUE;
				end
				else
					String1=String1+"Market trend is DOWN. ";
			  
				if Price[AbsDisplace ] < plot1[AbsDisplace] and
plot1[AbsDisplace] >= plot1[AbsDisplace + 1] 
				then begin
					String1=String1+"Even though prices are trading
below the moving average, the ";
					String1=String1+"moving average slope is up from
the previous bar. if price continues downwards,";
					String1=String1+" the moving average will
eventually follow and then the down trend will be ";
					String1=String1+"more clearly established. For
the time being, we'll continue to call the market";
					String1=String1+" trend DOWN. ";
				end;
				if Price[AbsDisplace] > plot1[AbsDisplace] and
plot1[AbsDisplace] < plot1[AbsDisplace + 1] 
				then begin
					String1=String1+"Even though the moving average
is in an downward slope from the previous ";
					String1=String1+"bar, the prices are trading
above the moving average line. "; 
					String1=String1+"if prices trade below the moving
average then the trend will be more ";
					String1=String1+"clearly established as down. For
the time being, ";
					String1=String1+"we'll continue to call the
market trend DOWN. ";
					String1=String1+"if your other indicators are
\hbbearish\he, this may be a good ";
					String1=String1+"\hbshort\he selling opportunity.
";
					alert = TRUE;
				end;
			end;
			commentary(String1);
		End;
	#End;
end;




--- Brian <blink64@xxxxxxxx> wrote:
> 
> What's the technique for shiting a MA into the
> future in TS?  So say you
> have 10 period MA and you want to shift it 15
> periods into the future.  How
> would you do that?
> 
> Thanks.
>