100% found this document useful (1 vote)
322 views3 pages

RISE ON - FALL ON - Afl

The document contains code for analyzing candlestick patterns to generate buy and sell signals. It defines several conditions to identify specific candlestick patterns indicating a potential trend reversal. These include patterns with 3 higher/lower closes, a mother candle with 3 baby candles of the same color, and restrictions on the highs and lows of the baby candles relative to the mother. When the conditions are met, it plots lines and arrows on the chart to visualize the signals and triggers audio alerts. It also adds columns showing entry, stoploss and target levels for any generated long and short signals.

Uploaded by

Rajen Vyas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
322 views3 pages

RISE ON - FALL ON - Afl

The document contains code for analyzing candlestick patterns to generate buy and sell signals. It defines several conditions to identify specific candlestick patterns indicating a potential trend reversal. These include patterns with 3 higher/lower closes, a mother candle with 3 baby candles of the same color, and restrictions on the highs and lows of the baby candles relative to the mother. When the conditions are met, it plots lines and arrows on the chart to visualize the signals and triggers audio alerts. It also adds columns showing entry, stoploss and target levels for any generated long and short signals.

Uploaded by

Rajen Vyas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

_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", colorDefault ), styleNoTitle |
ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();

// Condition for 3 Higher Closes


CON1 = (Ref(C,-3)> Ref(C,-4)) AND (Ref(C,-2)> Ref(C,-3)) AND (Ref(C,-1)> Ref(C,-
2));

// Condition for 1 Mother Candle & 3 Green Baby Candles


CON7 = (Ref(C,-4) < Ref(O,-4)) AND (Ref(C,-3)> Ref(O,-3)) AND (Ref(C,-2)> Ref(O,-
2)) AND (Ref(C,-1)> Ref(O,-1));

// Condition for 3 Baby Bar's Low higher than Mother Candle's Low
CON2 = (Ref(L,-3)> Ref(L,-4)) AND (Ref(L,-2)> Ref(L,-4)) AND (Ref(L,-1)> Ref(L,-
4));

// Condition for 3 Baby Bar's High lower than Mother Candle's High
CON3 = (Ref(H,-3)< Ref(H,-4)) AND (Ref(H,-2)< Ref(H,-4)) AND (Ref(H,-1)< Ref(H,-
4));

// Condition for 3 Lower Closes


CON4 = (Ref(C,-3)< Ref(C,-4)) AND (Ref(C,-2)< Ref(C,-3)) AND (Ref(C,-1)< Ref(C,-
2));

// Condition for 1 Mother Candle & 3 Red Baby Candles


CON8 = (Ref(C,-4) > Ref(O,-4)) AND (Ref(C,-3)< Ref(O,-3)) AND (Ref(C,-2)< Ref(O,-
2)) AND (Ref(C,-1)< Ref(O,-1));

// Condition for 3 Baby Bar's Low higher than Mother Candle's Low
CON5 = (Ref(L,-3)> Ref(L,-4)) AND (Ref(L,-2)> Ref(L,-4)) AND (Ref(L,-1)> Ref(L,-
4));

// Condition for 3 Baby Bar's High lower than Mother Candle's High
CON6 = (Ref(H,-3)< Ref(H,-4)) AND (Ref(H,-2)< Ref(H,-4)) AND (Ref(H,-1)< Ref(H,-
4));

// BUY / SELL CONDITIONS


Buy = CON1 AND CON2 AND CON3 AND CON7 AND H > Ref(HHV(H,3),-1);
Sell = CON4 AND CON5 AND CON6 AND CON8 AND L < Ref(LLV(L,3),-1);

// Plotting Dashed Line at High & Low of Buy Mother Candle


bar_before_buy=Ref(Buy,4);
hh=ValueWhen(bar_before_buy,H);
ll=ValueWhen(bar_before_buy,L);
Plot(hh,"",colorBlue,styleDashed);
Plot (ll,"",colorBlue,styleDashed);

// Plotting Line at High & Low of Buy Signal Candles


bar_before_buy=Ref(Buy,1);
Stoploss_for_buy=Ref(Buy,3);
hh=ValueWhen(bar_before_buy,H);
ll=ValueWhen(Stoploss_for_buy,L);
Plot(hh,"",colorGreen,styleLine,Null,Null,-2,0,0);
Plot (ll,"",colorGreen,styleLine);
// Plotting Dashed Line at High & Low of Sell Mother Candle
bar_before_sell=Ref(Sell,4);
hh=ValueWhen(bar_before_sell,H);
ll=ValueWhen(bar_before_sell,L);
Plot(hh,"",colorPink,styleDashed);
Plot(ll,"",colorPink,styleDashed);

// Plotting Line at High & Low of Buy Signal Candles


bar_before_sell=Ref(Sell,1);
Stoploss_for_sell=Ref(Sell,3);
hh=ValueWhen(stoploss_for_sell,H);
ll=ValueWhen(bar_before_sell,L);
Plot(hh,"",colorRed,styleLine);
Plot(ll,"",colorRed,styleLine,Null,Null,-2,0,0);

// Plotting Buy/Sell Arrow


PlotShapes(IIf(Buy,shapeUpArrow,shapeNone),colorGreen,0,L,Offset= -30);
PlotShapes(IIf(Sell,shapeDownArrow,shapeNone),colorRed,0,H,Offset = -30);

//ApplyStop( stopTypeLoss, stopModePercent, 1 ); // 1% max loss from short/buy


price
//ApplyStop( stopTypeProfit, stopModePercent, 1 ); // 1% profit target from
short/buy price

// Alerts for Buy / Sell Signals


AlertIf( Buy, "SOUND C:\\Windows\\Media\\Windows Proximity Notification.wav",
"Audio alert",1);
AlertIf( Sell, "SOUND C:\\Windows\\Media\\Windows Proximity Notification.wav",
"Audio alert",2);

// Raju Sir's Code (Copied & Pasted)


XXX=999.99;
//Mother Bar
MLOW=Ref(L,-3);
MHIGH=Ref(H,-3);
MCLOSE=Ref(C,-3);
MOPEN=Ref(O,-3);

//Candle 1
D1LOW=Ref(L,-2);
D1HIGH=Ref(H,-2);
D1CLOSE=Ref(C,-2);
D1OPEN=Ref(O,-2);

//Candle 2
D2LOW=Ref(L,-1);
D2HIGH=Ref(H,-1);
D2CLOSE=Ref(C,-1);
D2OPEN=Ref(O,-1);

//Candle 3
D3LOW=L;
D3HIGH=H;
D3CLOSE=C;
D3OPEN=O;

MotherBar = MHIGH > D1HIGH AND MHIGH > D2HIGH AND MHIGH> D3HIGH AND MLOW < D1LOW
AND MLOW < D2LOW AND MLOW < D3LOW AND MHIGH > MOPEN AND MLOW < MOPEN;
Buy= MotherBar AND MOPEN > MCLOSE AND D1CLOSE > MCLOSE AND D2CLOSE > D1CLOSE AND
D3CLOSE > D2CLOSE AND D1CLOSE > D1OPEN AND D2CLOSE > D2OPEN AND D3CLOSE > D3OPEN;
Sell = MotherBar AND MOPEN < MCLOSE AND D1CLOSE < MCLOSE AND D2CLOSE < D1CLOSE AND
D3CLOSE < D2CLOSE AND D1CLOSE < D1OPEN AND D2CLOSE < D2OPEN AND D3CLOSE < D3OPEN;

//Sorting only high volume stocks


Filter=(Buy OR Sell);// AND Volume > 200000;

Mdiff = MHIGH - MLOW;


LowestLow=Min(D3LOW,Min(Ref(D2LOW,-1),Ref(D1LOW,-2)));
HighestHigh=Max(D3HIGH,Min(Ref(D2HIGH,-1),Ref(D1HIGH,-2)));
LTarget = HighestHigh + 2*Mdiff;
STarget = LowestLow - 2*Mdiff;
LEntry = HighestHigh + (HighestHigh*0.05/100);
SEntry = LowestLow - (LowestLow*0.05/100);

//Long Positions
AddColumn(IIf(Buy,LEntry,Null),"Long-Above",1.2,colorGreen);
AddColumn(IIf(Buy,LowestLow,Null),"Long-Stoploss",1.2,colorGreen);
AddColumn(IIf(Buy,LTarget,Null),"Long-Target",1.2,colorGreen);
//Short Positions
AddColumn(IIf(Sell,SEntry,Null),"Short-Below",1.2,colorRed);
AddColumn(IIf(Sell,HighestHigh,Null),"Short-Stoploss",1.2,colorRed);
AddColumn(IIf(Sell,STarget,Null),"Short-Target",1.2,colorRed);

You might also like