Simple Coding Help - No Promise.

Hello Coding Experts, Can a scanner be made out of these conditions?
Thanks in advance

( latest volume > latest sma( latest close , 20 ) and latest close > latest upper bollinger band( 20 , 2 ) and weekly close > weekly upper bollinger band( 20 , 2 ) and monthly close > monthly upper bollinger band( 20 , 2 ) and latest rsi( 14 ) > 60 and weekly rsi( 14 ) > 60 and monthly rsi( 14 ) > 60 and monthly wma( monthly close , 30 ) > monthly wma( monthly close , 50 ) and 1 month ago wma( monthly close , 30 )<= 1 month ago wma( monthly close , 50 ) and monthly wma( monthly close , 30 ) > 60 and monthly wma( monthly close , 50 ) > 60 ) )
 

RadhuK

Well-Known Member
Hello Coding Experts, Can a scanner be made out of these conditions?
Thanks in advance

( latest volume > latest sma( latest close , 20 ) and latest close > latest upper bollinger band( 20 , 2 ) and weekly close > weekly upper bollinger band( 20 , 2 ) and monthly close > monthly upper bollinger band( 20 , 2 ) and latest rsi( 14 ) > 60 and weekly rsi( 14 ) > 60 and monthly rsi( 14 ) > 60 and monthly wma( monthly close , 30 ) > monthly wma( monthly close , 50 ) and 1 month ago wma( monthly close , 30 )<= 1 month ago wma( monthly close , 50 ) and monthly wma( monthly close , 30 ) > 60 and monthly wma( monthly close , 50 ) > 60 ) )
//Try this

X1 = V> MA(V,20);
X2 = C> BBandTop(C,20,2);

WKC = TimeFrameGetPrice("C", inWeekly , 0);
WGrap8 = BBandTop(WKC,20,2) ;//
X3 = WKc > WGrap8;

MKC = TimeFrameGetPrice("C", inMonthly , 0);
MGrap8 = BBandTop(MKC,20,2) ;//
X4 = MKc > MGrap8;

X5 = RSI(14)>60;

wwRSI = TimeFrameCompress(RSI(14), inWeekly );
WRSI = TimeFrameExpand(wwRSI, inWeekly );
X6 = WRSI>60;

mmRSI = TimeFrameCompress(RSI(14), inMonthly );
MRSI = TimeFrameExpand(mmRSI, inMonthly );
X7 = MRSI>60;

X8 = Cross(MA(MKc,30),MA(MKc,50));

BUY = X1 AND X2 AND X3 AND X4 AND X5 AND X6 AND X7 AND X8;
 
//Try this

X1 = V> MA(V,20);
X2 = C> BBandTop(C,20,2);

WKC = TimeFrameGetPrice("C", inWeekly , 0);
WGrap8 = BBandTop(WKC,20,2) ;//
X3 = WKc > WGrap8;

MKC = TimeFrameGetPrice("C", inMonthly , 0);
MGrap8 = BBandTop(MKC,20,2) ;//
X4 = MKc > MGrap8;

X5 = RSI(14)>60;

wwRSI = TimeFrameCompress(RSI(14), inWeekly );
WRSI = TimeFrameExpand(wwRSI, inWeekly );
X6 = WRSI>60;

mmRSI = TimeFrameCompress(RSI(14), inMonthly );
MRSI = TimeFrameExpand(mmRSI, inMonthly );
X7 = MRSI>60;

X8 = Cross(MA(MKc,30),MA(MKc,50));

BUY = X1 AND X2 AND X3 AND X4 AND X5 AND X6 AND X7 AND X8;
Thank you so much , I will let you know after checking...
 
Hi,
I am scanning this AFL for signals and i am receiving Error10 at line S[i] = C[i]-m*(A[i]);. I tried using a condition as suggested in the help documentation to invoke but still receiving the same error. Below is the condition i tried.
Code:
 if (i>0){
    S[i] = C[i]-m*(A[i]);
    T[i] = 1;
    }
 else{
    S[i] = C[i];
    T[i] = 1;}
Conditions for Replication:
  1. I see this error occurring only when i try to run it on all symbols in AmiBroker.
  2. I do not see this error when running on Nifty 500 watchlist which has maximum stocks (496) in my watchlists.
  3. When i add all symbols in my database to a watchlist (1710 symbols), it is giving the same error.

Help Needed:
  1. Ability to scan all symbols at once.


PS: I downloaded this indicator from WiseStockTrader.com.

Code:
// Downloaded From https://www.WiseStockTrader.com
/*Magical Trend Indicator with update
Created By : Rakesh Solanki
For www.nascenttraders.com
Date: 11/02/2017*/
_SECTION_BEGIN("Magic Trend Indicator Update");
SetBarsRequired(sbrAll,sbrAll);
SetFormulaName( "Magic Trend Indicator Update" );
SetOption( "Initialequity", 100000 );
SetOption( "AccountMargin", 0.25 );
SetOption( "MinShares", 1 );
MaxOpenPos = Param( "MaxOpenPos", 20, 1, 200, 1 );
SetOption( "MaxOpenPositions", MaxOpenPos );
SetOption( "PriceBoundChecking", 1 );
SetOption( "CommissionMode", 1 );
SetOption( "CommissionAmount", 0.01 );
PositionSize = -400 / ( MaxOpenPos );
P = Param("Period",20,2,25,1);
m = Param("Multiplier",3,0.1,5,0.1);
A = ATR(P);
for(i=0;i<P;i++)
{
 S[i] = C[i]-m*(A[i]);
 T[i] = 1;
}
for(i=P;i<BarCount;i++)
{
 if(C[i] > S[i-1])
 {
 if(T[i-1]==1)
 {
 S[i] = Max(C[i] - m*A[i],S[i-1]);
 T[i] = 1;
 }
 else
 {
 S[i] = C[i] - m*A[i];
 T[i] = 1;
 }
 
 }
 else
 {
 if(T[i-1]==-1)
 {
 S[i] = Min(C[i] + m*A[i],S[i-1]);
 T[i] = -1;
 }
 else
 {
 S[i] = C[i] + m*A[i];
 T[i] = -1;
 }
 }
}
Buy = Cover = C>S;
Short = Sell = C<S;
Buy = ExRem(Buy,Sell OR Short);
Sell = ExRem(Sell,Buy);
Short = ExRem(Short,Cover OR Buy);
Cover = ExRem(Cover,Short);
BuyPrice = ValueWhen(Buy,C,1);
SellPrice = ValueWhen(Sell,C,1);
ShortPrice = ValueWhen(Short,C,1);
CoverPrice = ValueWhen(Cover,C,1);
Offset = -12;
PlotShapes(Buy*shapeUpArrow,colorBrightGreen,0,Min(S,L),Offset);
PlotShapes(Short*shapeDownArrow,colorRed,0,Max(S,H),Offset);
PlotShapes(Cover*shapeHollowUpArrow,colorBrightGreen,0,Min(S,L),Offset);
PlotShapes(Sell*shapeHollowDownArrow,colorRed,0,Max(S,H),Offset);
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(S,"STOP",IIf(C>S,colorBrightGreen,colorRed),styleDots|styleStaircase|styleThick|styleNoTitle );
PlotOHLC(O,H,L,C,"Close",colorDefault,styleCandle|styleNoTitle);
GfxSetOverlayMode(1);
GfxSelectFont("Verdana", 12, 800, True );
GfxSetBkMode(0);
GfxSetTextColor(ColorRGB(18,18,18));
GfxTextOut("Created By: Rakesh Solanki", 800 , 430 );
GfxSelectFont("Verdana", 14, 800, True );
GfxSetBkMode(1);
GfxTextOut("www.nascenttraders.com" , 800 ,400 );
Open_Long = Flip( Buy, Sell );
Open_Short = Flip( Sell, Buy );
Buy_Price = ValueWhen( Buy, BuyPrice, 1 );
Short_Price = ValueWhen( Short, ShortPrice, 1 );
Sell_Price = IIf( Sell, ValueWhen( Sell, SellPrice, 1 ), Short_Price );
Cover_Price = IIf( Cover, ValueWhen( Cover, CoverPrice, 1 ), Buy_Price );
Profit = IIf( Open_Long, ( Close - Buy_Price ), IIf( Open_Short, ( Short_Price - Close ), 0 ) );
Last_Profit = IIf( Ref( Open_Long, -1 ) == 1 AND Open_Long != 1, ( Sell_Price - Buy_Price ), IIf( Ref( Open_Short, -1 ) == 1 AND Open_Short != 1, ( Short_Price - Cover_Price ), 0 ) );
Cum_Profit[0] = Last_Profit[0];
PreviousProfit = ValueWhen(Last_Profit!=0,Last_Profit,1);
for ( i = 1;i < BarCount;i++ )
{
 Cum_Profit[i] = Cum_Profit[i-1] + Last_Profit[i];
}
Trade[0] = 0;
for ( i = 1;i < BarCount;i++ )
{
 if ( Buy[i] == 1 OR Short[i] == 1 )
 {
 Trade[i] = Trade[i-1] + 1;
 }
 else
 {
 Trade[i] = Trade[i-1];
 }
}
// Trade Report //
TR = ParamToggle( "Trade Report", "Show|Hide", 1 );
 
if ( TR == 1 )
{
 GfxSelectFont( "Verdana", 10, 100 );
 GfxSetBkMode( 1 );
 GfxSetTextColor( ColorRGB(50,50,50) );
 y = Status( "pxchartheight" );
 
 GfxTextOut( ( "Total Trades : " + WriteVal( Trade, 3.0 ) ), 13, y - 125 );
 GfxTextOut( ( "Total Profit : " + WriteVal( Cum_Profit, 4.2 ) ), 13, y - 100 );
 GfxTextOut( ( "Previous Profit : " + WriteVal( PreviousProfit, 2.2 ) ), 13, y - 50 );
 GfxTextOut( ( "Price : " + WriteVal( Close, 2.2 ) ), 13, y - 75 );
 GfxTextOut( ( "Current Profit : " + WriteVal( Profit, 2.2 ) ), 13, y - 25 );
}
_SECTION_END();
 
Hi to all seniors...

I want a candlestick pattern explorer, I know you all will say there are plenty afl over internet and I tried all but not matching my criteria so seriously I want different conditions. which are as follows, and yes I need only bullish bearish engulfing, bullish bearish harami, evening and morning star, shooting star, hammer and twizzer top & bottom.
I do not want to consider previous trend, just candle patterns condition should match nothing else.
Now I will explain conditions of all one by one :-

1. Bullish Engulfing:

First candle body should be red then second green candle should either engulf only previous first red candle body or engulf whole candle with wicks both condition allow, now this second green candle low should not break by previous first red candle low, now important is next third candle should be green only and this one also not break the low of second green candle, so now signal should come after this third green candle closing.

2. Bearish Engulfing:

First candle body should be green then second red candle should either engulf only previous green candle body or engulf whole candle with wicks both condition allow, now this second red candle high should not break by previous first green candle high, now important is next third candle should be red only and this one also not break the high of second red candle, so now signal should come after this third red candle closing.

3. Bullish Harami:

First candle body should be red then second candle should be green and its body only should not big more than 50% of first red candle body only, now the first red candle low should not break by second green candle low, now important is next third candle should be green only and this one not break the low of first red candle, so now signal should come after this third green candle closing.

4. Bearish Harami:

First candle body should be green then second candle should be red and its body only should not big more than 50% of first green candle body only, now the first green candle high should not break by second red candle high, now important is next third candle should be red only and this one also not break the high of the first green candle so now signal should come after this third red candle closing.

5. Shooting Star:

First candle should be green then second candle body can either be red or green but its body should be minimum 20% to maximum 30% of its high-low range, and its upper wick should be minimum 70% to maximum 80% of its high-low range, there can be small wick below its body, this second candle high should not break by first green candle, now third candle should be red and this red candle should also not break high of second candle high, so now signal should come after this third red candle closing.

6. Hammer:

First candle should be red then second candle body can either be red or green but its body should be minimum 20% to maximum 30% of its high-low range, and its lower wick should be minimum 70% to maximum 80% of its high-low range, there can be small wick above Its body, this second candle low should not break by first red candle, now third candle should be green and this green candle should also not break low of second candle low, so now signal should come after this third green candle closing.

7. Morning Star:

First candle should be red then second candle should be single candle spinning top which body can be red or green and this candle low should not break by first red candle low, then third candle should be green and also its low should not break the second candle spinning top low, so now signal should come after this third green candle closing.

8. Evening Star:

First candle should be green then second candle should be single candle spinning top which body can be red or green and this candle high should not break by first green candle high, then third candle should be red and also its high should not break the second candle spinning top high, so now signal should come after this red green candle closing.

9. Twizzer Top:

First candle should be green then second candle should be red, now both these candles high should be equal, now third candle should be red and this third red candle high should not break the both first and second candles high, now signal should come after this third red candle closing.

10. Twizzer Bottom:

First candle should be red then second candle should be green, now both these candles low should be equal, now third candle should be green and this third green candle low should not break the both first and second candles low, now signal should come after this third red candle closing.

Note: Please make this exploration for all time frames, if possible plot an arrow on signal candle.

I request to all seniors and afl experts please make this afl.

Thanks in advance.
 
_SECTION_BEGIN("Dark Cloud Cover");

per_reng=(Ref(H,-1)-Ref(L,-1));
mid=Ref(H,-1)-(per_reng/2);
Cond1=Ref(C,-1)>Ref(O,-1);
Cond2=O>Ref(H,-1);
Cond3=L>Ref(L,-1);
Cond4=C<mid;
Cond5=C>Ref(O,-1);

drkclud=Cond1 AND Cond2 AND Cond3 AND Cond4 AND Cond5;
Filter=drkclud;

AddColumn(C,"current price",1.2,colorWhite,colorBlack);
PlotShapes(IIf(drkclud,shapeDownArrow,shapeNone),colorRed,0,H,Offset=-30);




in this afl i just want to add 1 more condition for making third candle that, this third candle should be red and second candle high should not break by first and third candle thats it...and after closing this third candle signal should come.

its will take little time pls..
 
in this afl i just want to add 1 more condition for making third candle that, this third candle should be red and second candle high should not break by first and third candle thats it...and after closing this third candle signal should come.

its will take little time pls..
LOL . . . u know tht it will take little time !! . . . anyway,
better describe, e.g., like below (assuming current candle is going to be the signal candle),

Current candle (n), conditions,
previous candle (n-1) conditions,
old candle (n-2) conditions,
older candle (n-3) conditions . . . and continue till as many candles and/or conditions u want to specify

this way people will understand which candle u r referring to as first one (new or older)
 

Similar threads