# Buy on current candle if price is increased more than 5% of Previous Close

#### momin02

##### Member
Please Make a afl formula for bank nifty, condition for buy is mentioned below:
Buy on current candle if price is increased more than 5% of Previous Close and Sell vice versa

#### Aerinnon

##### Member
Yes, it's not a bad option for a deal, but of course there are some nuances, it does not always work, the main thing to pay attention to the levels, because there may be a situation where the price has significantly jumped, but a strong indicator to buy or sell has not yet given.

#### momin02

##### Member
Yes you are right so I have again thought and working on a new formula which would be a give more good and accurate result but I am not a programmer so I was stuck on a few points. If you help me I can share with you afl formula.

#### momin02

##### Member
Dear seniors, Help me, How to remove Buy signals from Short side in Amibroker AFL.

#### momin02

##### Member
Dear seniors, Help me, How to Insert Sell signal for the condition "High Price of the Intraday -20%" in Amibroker AFL.

_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();

// Current Day High Low//
_SECTION_BEGIN("PreDay HLC");
function CDL( array )
{
doy = DayOfYear();
Lastdoy = doy == LastValue( doy );
Dayline = array * Lastdoy;

return IIf( Dayline, Dayline, Null );
}

//TIME FRAME CALCULATION
H1 = TimeFrameGetPrice( "H", inDaily, 1 ); // yesterdays high
L1 = TimeFrameGetPrice( "L", inDaily, 1 ); // low
C1 = TimeFrameGetPrice( "C", inDaily, 1 ); // close
DayO = TimeFrameGetPrice("O", inDaily); // current day open

//PLOTS
Plot( cdl( H1 ), "", colorRed, styleLine + styleThick + styleNoRescale + styleNoLabel );
PlotText("High",BarCount,LastValue(TimeFrameGetPrice( "H", inDaily, 1 ),True),colorBlue);

Plot( cdl( L1 ), "", colorBrightGreen, styleLine + styleThick + styleNoLabel );
PlotText("Low",BarCount,LastValue(TimeFrameGetPrice( "L", inDaily, 1 ),True),colorRed);

_SECTION_END();

#### Kazil

##### New Member
It looks like momentum strategy. However, your trading strategy should be more complex and include indicators along with S&R levels. The whole idea can work but all the signals should be justified by indicators and charts.

#### momin02

##### Member
Please help me seniors I am getting Buy side continuous Buy signal on chart. Please remove excess signal of Buy on chart. Intra Day Trading with 15 minutes chart on Nifty Call Option. This is Ribbon Bar Trading when ribbon bar color change signal generate. I have tried but getting excess signal on buy side on chart.

//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
//TRENDING RIBBON
// Paste the code below to your price chart somewhere and green ribbon means both
// both MACD and ADX trending up so if the red ribbon shows up the MACD and the ADX
// are both trending down.
_SECTION_BEGIN("trending ribbon");
uptrend= PDI()>MDI() AND MACD()>Signal() ;
downtrend= MDI()>PDI() AND Signal()>MACD() ;
Plot( 2, /* defines the height of the ribbon in percent of pane width */"",
IIf( uptrend AND EMA(C,50)>=Ref(EMA(C,50),-1), colorLime, IIf( downtrend OR EMA(C,50)<Ref(EMA(C,50),-1),
colorRed, colorAqua )), /* choose color */
styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );

Buy = IIf( uptrend AND EMA(C,50)>=Ref(EMA(C,50),-1),colorLime,0) AND NOT GapUp();// AND TimeNum() >= TrdBegin1 AND TimeNum() <= TrdEnd1;
Sell = IIf( downtrend AND EMA(C,50)<=Ref(EMA(C,50),-1),colorRed,colorAqua);// OR TimeNum() >= SqOff; // AND NOT GapDown();

//Non Repainting - Signals happens only after the close of the current
Sell = Ref(Sell,-1);

shape1 = Buy * shapeUpArrow + Sell * shapeDownArrow;
Plot(C, "Close", colorDefault, styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
PlotShapes( shape1, IIf( Buy, colorLime, colorLightOrange ), 0, IIf( Buy, Low, High ), -15 );

ExRem(Sell,0);

_SECTION_END();
//-----------------------------------------------------------------------------------------

Last edited:

#### bunti_k23

##### Well-Known Member
KYA BOLTE MAJA AAYA?