Afl required

#1
Help needed for coding

MACD>SIGNAL AND RSI>70
Results required as dots above the price and red in color.

MACD<SIGNAL AND RSI<30
Results required as dots below the price and blue in color.

(similar to sell and buy arrows)

Thanks in advance:)
 
#3
Help needed for coding

MACD>SIGNAL AND RSI>70
Results required as dots above the price and red in color.

MACD<SIGNAL AND RSI<30
Results required as dots below the price and blue in color.

(similar to sell and buy arrows)

Thanks in advance:)
Hello,

You can use PlotShapes function in which you can plot dots, circles and many other predefined shapes. You can write this in many ways but one sample code is given below for your understanding.

Buy = // your buy rule goes here
Sell = // Your sell rule goes here
PlotShapes( IIF( Buy, shapeSmallCircle + shapePositionAbove, shapeNone ), colorGreen );
PlotShapes( IIF( Sell, shapeSmallCircle + shapePositionAbove, shapeNone ), colorRed );

I hope this helps.

Best regards,

AmiBroker-India
 
#4
Reg: VIDYA(variable index dynamic average) by Tushar Chande and Kroll

Mr.Tushar Chande and Kroll has Written a book "The New Technical trader" which is available in ebook form at www.snips.com. In this book Mr. Tushar Chande has introduced a New indicator to capture the market trend in advance for future market i.e. tommorrow's trend. This is mentioned VIDYA(variable index dynamic average) which captures the turning point or reversal in trend more fast than EMA or any other indicator. If anyone write this VIDYA AFL for amibroker it will be very useful for amibroker user to get the signal fast. VIDYA also can be used as trailing stop loss untill the signal changes and it gives very dynamic and amazing results prior to any other indicator.


Subhas Chand Mishra
 
#5
//VIDYA is an acronym of Variable Index DYnamic Average. The VIDYA is an exponential moving average that automatically adjusts the smoothing weight based on the volatility of the data series. The more volatile the data is, the more weight is given to the more recent values. The VIDYA solves a problem with most moving averages. In times of low volatility, such as when the price is trending, the moving average time period should be shorter to be sensitive to the inevitable break in the trend. Whereas, in more volatile non-trending times, the moving average time period should be longer to filter out the choppiness.
//The VIDYA is also known as the Variable Moving Average.
function fVidya(prd,mp)
{
sfac=2/(mp+1);

V1=StDev(C,prd);
V2=HHV(V1,prd);
V3=LLV(V1,prd);

V4=(V1-V3)/(V2-V3);

for(i=0;i<=prd;i++) {
Vidya=C;
}

for(i=prd+1;i<BarCount;i++) {
Vidya=sfac*V4*C+(1-sfac*V4)*Vidya[i-1];
}
return Vidya;
}

prd=Param("Periods", 20, 1, 100 );
mp=Param("ToEMA",9,1,100);

Plot( fVidya(prd,mp),
_DEFAULT_NAME(),
ParamColor("Color", ColorCycle ) );
 
#8
Hello,

I have copied code AFL in Amibroker and it gives the following error me:

"Error 31, Syntax error, expecting IDENTIFIER"

in forward edge:
"function fVidya(prd,Mp)"

As I can correct it. Thank you very much.

Greetings,

The copied code is the following one:

//The VIDYA is also known as the Variable Moving Average.
function fVidya(prd,Mp)
{
sfac=2/(Mp+1);

V1=StDev(C,prd);
V2=HHV(V1,prd);
V3=LLV(V1,prd);

V4=(V1-V3)/(V2-V3);

for(i=0;i<=prd;i++) {
Vidya=C;
}

for(i=prd+1;i<BarCount;i++) {
Vidya=sfac*V4*C+(1-sfac*V4)*Vidya[i-1];
}
return Vidya;
}

prd=Param("Periods", 20, 1, 100 );
Mp=Param("ToEMA",9,1,100);

Plot( fVidya(prd,Mp),
_DEFAULT_NAME(),
ParamColor("Color", ColorCycle ) );
 
#9
hi friends

I want change one formula. These is buy sell formula for amibroker i want to change color cod when buy signal bar color is green and sell bar color is red.
pls help me.

_SECTION_BEGIN("Ensign Volatility Stop");

// Ensign Volatility Stop
// get the multiple of 9 period EMA of ATR_Ensign
k=Param("multiplication factor", 1,0.5,5,0.1);

period=k*9;
VS_raw = 2.5 * EMA(ATR(1), period);

// for longs, VS line is below price
loline = VS_below_price = HHV(Close, period) - VS_raw;

// for shorts, VS line is above price
hiline = VS_above_price = LLV(Close, period) + VS_raw;
between = IIf (C < hiline AND C > loline, 1, 0);
up = IIf(C > hiline OR (H > Ref(H, -1) AND H > hiline), 1, 0);
dn = IIf(C < loline OR (L < Ref(L, -1) AND L < loline), 1, 0);
upcond = IIf(between AND BarsSince(up) < BarsSince(dn) , 1, 0);
dncond = IIf(between AND BarsSince(dn) < BarsSince(up) , 1, 0);
upline = IIf(up OR upcond, loline, Null);
dnline = IIf(dn OR dncond, hiline, Null);

Plot(C, "", colorLightGrey, styleBar);
Plot(upline, "", colorBlack, styleStaircase) ;
Plot(dnline, "", colorBlack, styleStaircase) ;

Buy=upline;
Sell=dnline;
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);

PlotShapes(Buy*shapeUpArrow,colorGreen);
PlotShapes(Sell*shapeDownArrow,colorRed);
 

hitesh

Active Member
#10
hi friends

I want change one formula. These is buy sell formula for amibroker i want to change color cod when buy signal bar color is green and sell bar color is red.
pls help me.

_SECTION_BEGIN("Ensign Volatility Stop");

// Ensign Volatility Stop
// get the multiple of 9 period EMA of ATR_Ensign
k=Param("multiplication factor", 1,0.5,5,0.1);

period=k*9;
VS_raw = 2.5 * EMA(ATR(1), period);

// for longs, VS line is below price
loline = VS_below_price = HHV(Close, period) - VS_raw;

// for shorts, VS line is above price
hiline = VS_above_price = LLV(Close, period) + VS_raw;
between = IIf (C < hiline AND C > loline, 1, 0);
up = IIf(C > hiline OR (H > Ref(H, -1) AND H > hiline), 1, 0);
dn = IIf(C < loline OR (L < Ref(L, -1) AND L < loline), 1, 0);
upcond = IIf(between AND BarsSince(up) < BarsSince(dn) , 1, 0);
dncond = IIf(between AND BarsSince(dn) < BarsSince(up) , 1, 0);
upline = IIf(up OR upcond, loline, Null);
dnline = IIf(dn OR dncond, hiline, Null);

Plot(C, "", colorLightGrey, styleBar);
Plot(upline, "", colorBlack, styleStaircase) ;
Plot(dnline, "", colorBlack, styleStaircase) ;

Buy=upline;
Sell=dnline;
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);

PlotShapes(Buy*shapeUpArrow,colorGreen);
PlotShapes(Sell*shapeDownArrow,colorRed);

_SECTION_BEGIN("Ensign Volatility Stop");

// Ensign Volatility Stop
// get the multiple of 9 period EMA of ATR_Ensign
k=Param("multiplication factor", 1,0.5,5,0.1);

period=k*9;
VS_raw = 2.5 * EMA(ATR(1), period);

// for longs, VS line is below price
loline = VS_below_price = HHV(Close, period) - VS_raw;

// for shorts, VS line is above price
hiline = VS_above_price = LLV(Close, period) + VS_raw;
between = IIf (C < hiline AND C > loline, 1, 0);
up = IIf(C > hiline OR (H > Ref(H, -1) AND H > hiline), 1, 0);
dn = IIf(C < loline OR (L < Ref(L, -1) AND L < loline), 1, 0);
upcond = IIf(between AND BarsSince(up) < BarsSince(dn) , 1, 0);
dncond = IIf(between AND BarsSince(dn) < BarsSince(up) , 1, 0);
upline = IIf(up OR upcond, loline, Null);
dnline = IIf(dn OR dncond, hiline, Null);

Plot(upline, "", colorBlack, styleStaircase) ;
Plot(dnline, "", colorBlack, styleStaircase) ;

Buy=upline;
Sell=dnline;
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);

Col = IIf(Buy,colorGreen,IIf(Sell,colorRed,colorBlack));
Plot(C, "", col, styleBar);

PlotShapes(Buy*shapeUpArrow,colorGreen);
PlotShapes(Sell*shapeDownArrow,colorRed);
 

Similar threads