Don't know if this will work to just post the text of the file in the description box here. Copy all code below here for indicator or text file attached. Pictures should explain. Indicator works fine.
////////////////////////////////
// Displaced Moving Average with Projection
//
inputs:
ShowProjection(True),
ST_upcol(blue),
ST_dncol(red),
LT_upcol(darkgreen),
LT_dncol(magenta),
Price( Close ),
FastLength( 9 ),
SlowLength( 18 ),
Displace( 0 ) ;
variables:
avg_st( 0 ),
avg_Lt( 0 ) ,
st_diff(0),
lt_diff(0),
st_color(0),
lt_color(0);
avg_st = AverageFC( Price, FastLength ) ;
avg_Lt = AverageFC( Price, SlowLength ) ;
condition1 = Displace >= 0 or CurrentBar > AbsValue( Displace ) ;
if condition1 then
begin
if avg_st > avg_st[1] then st_color = st_upcol
else st_color = st_dncol;
if avg_lt > avg_lt[1] then lt_color = lt_upcol
else lt_color = lt_dncol;
Plot1[Displace]( avg_st, "FastAvg", st_color ) ;
Plot2[Displace]( avg_Lt, "SlowAvg", lt_color ) ;
if Displace <= 0 then
begin
condition1 = avg_st crosses over avg_Lt ;
if condition1 then
Alert( "Bullish alert" )
else
begin
condition1 = avg_st crosses under avg_Lt ;
if condition1 then
Alert( "Bearish alert" ) ;
end ;
end;
end ;
if ShowProjection and Displace > 0 then
begin
st_diff = avg_st - avg_st[1];
lt_diff = avg_lt - avg_lt[1];
for value1 = 1 to Displace
begin
plot1[Displace - value1](avg_st + st_diff* value1 ,"s", black);
plot2[Displace - value1](avg_lt + lt_diff* value1 ,"l", black);
end;
end;
Category MultiCharts
|
|
|