Simple Coding Help - No Promise.

Dear AFL Experts/Seniors

plz one more help me in this Afl code. It's a Wma Vwap crossover.plz plot buy/sell signal on crossover when Wma candle completion above or below Vwap.





_SECTION_BEGIN("Chart Settings");
SetChartOptions(0,chartShowArrows|chartShowDates);
SetChartBkColor(ParamColor("Outer Panel",colorGrey40));
SetChartBkGradientFill(ParamColor("Upper Chart",colorBlack),ParamColor("Lower Chart",colorBlack));
GraphXSpace=Param("GraphXSpace",10,0,100,1);
dec = (Param("Decimals",2,0,7,1)/10)+1;
bi = BarIndex();
Lbi = LastValue(BarIndex());
sbi = SelectedValue(bi);
x1= BarCount-1;
Title = EncodeColor(55)+ Title = Name() + " " + EncodeColor(32) + Date() +
" " + EncodeColor(5) + "{{INTERVAL}} " +
EncodeColor(55)+ " Open = "+ EncodeColor(52)+ WriteVal(O,dec) +
EncodeColor(55)+ " High = "+ EncodeColor(5) + WriteVal(H,dec) +
EncodeColor(55)+ " Low = "+ EncodeColor(32)+ WriteVal(L,dec) +
EncodeColor(55)+ " Close = "+ EncodeColor(52)+ WriteVal(C,dec)+
EncodeColor(55)+ " Volume = "+ EncodeColor(52)+ WriteVal(V,1);
_SECTION_END();

_SECTION_BEGIN("BACKGROUD LTRS");
SetChartOptions(0,chartShowArrows|chartShowDates);
GfxSetOverlayMode(0);
GfxSetTextAlign( 6 );// center alignment
GfxSetTextColor( ParamColor("Text Color", ColorHSB( 98, 119, 112 ) ));
GfxSetBkMode(0); // transparent
GfxSelectFont("Verdana", Status("pxheight")/20 );
GfxTextOut( Name(), Status("pxwidth")/2, Status("pxheight")/14 );
GfxSelectFont("Arial", Status("pxheight")/27 );
_SECTION_END();


_SECTION_BEGIN ("VWAP");
/*
The VWAP for a stock is calculated by adding the value traded for every transaction in that stock ("price" x "number of shares traded") and dividing the total shares traded. A VWAP is computed from the Open of the market to the market Close, AND is calculated by Volume weighting all transactions during this time period
*/
PlotOHLC(O,H,L,C,"Price",IIf(C>O,colorGreen,colorRed),styleCandle);
Bars_so_far_today = 1 + BarsSince( Day() != Ref(Day(), -1));
StartBar = ValueWhen(TimeNum() == 093000, BarIndex());
TodayVolume = Sum(V,Bars_so_far_today);
IIf (BarIndex() >= StartBar, VWAP = Sum (C * V, Bars_so_far_today ) /
TodayVolume,0);
Plot (VWAP,"VWAP",colorYellow, styleThick);

_SECTION_END();

_SECTION_BEGIN("WMA");
P = ParamField("Price field",-1);
Periods = Param("Periods", 5, 2, 300, 1, 10 );
Plot( EMA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );
_SECTION_END();
 
Dear AFL Experts/Seniors
plz one more help me in this Afl code. It's a Wma Vwap crossover.plz plot buy/sell signal on crossover when Wma candle completion above or below Vwap.


_SECTION_BEGIN("Plot_the_signals");
SetChartOptions(0,chartShowArrows|chartShowDates);
SetChartBkColor(ParamColor("Outer Panel",colorGrey40));
SetChartBkGradientFill(ParamColor("Upper Chart",colorBlack),ParamColor("Lower Chart",colorBlack));
GraphXSpace=Param("GraphXSpace",10,0,100,1);
dec = (Param("Decimals",2,0,7,1)/10)+1;
bi = BarIndex();
Lbi = LastValue(BarIndex());
sbi = SelectedValue(bi);
x1= BarCount-1;
Title = EncodeColor(55)+ Title = Name() + " " + EncodeColor(32) + Date() +
" " + EncodeColor(5) + "{{INTERVAL}} " +
EncodeColor(55)+ " Open = "+ EncodeColor(52)+ WriteVal(O,dec) +
EncodeColor(55)+ " High = "+ EncodeColor(5) + WriteVal(H,dec) +
EncodeColor(55)+ " Low = "+ EncodeColor(32)+ WriteVal(L,dec) +
EncodeColor(55)+ " Close = "+ EncodeColor(52)+ WriteVal(C,dec)+
EncodeColor(55)+ " Volume = "+ EncodeColor(52)+ WriteVal(V,1);
SetChartOptions(0,chartShowArrows|chartShowDates);
GfxSetOverlayMode(0);
GfxSetTextAlign( 6 );// center alignment
GfxSetTextColor( ParamColor("Text Color", ColorHSB( 98, 119, 112 ) ));
GfxSetBkMode(0); // transparent
GfxSelectFont("Verdana", Status("pxheight")/20 );
GfxTextOut( Name(), Status("pxwidth")/2, Status("pxheight")/14 );
GfxSelectFont("Arial", Status("pxheight")/27 );
PlotOHLC(O,H,L,C,"Price",IIf(C>O,colorGreen,colorRed),styleCandle);
Bars_so_far_today = 1 + BarsSince( Day() != Ref(Day(), -1));
StartBar = ValueWhen(TimeNum() == 093000, BarIndex());
TodayVolume = Sum(V,Bars_so_far_today);
IIf (BarIndex() >= StartBar, VWAP = Sum (C * V, Bars_so_far_today ) /
TodayVolume,0);
Plot (VWAP,"VWAP",colorYellow, styleThick);
P = ParamField("Price field",-1);
Periods = Param("Periods", 5, 2, 300, 1, 10 );
Plot( EMA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );
Buy = Cross(EMA( P, Periods ),VWAP) ;
Sell = Cross(VWAP,EMA( P, Periods )) ;
buy = ExRem( buy, sell );
sell = ExRem( sell, buy );
PlotShapes( Buy * shapeUpArrow + Sell * shapeDownArrow, IIf( Buy, colorGreen, colorRed ) );
_SECTION_END();
 
Hi
Please add cross over buy sell arrows,

_SECTION_BEGIN("MACD_3_MINS");
r1 = Param( "Fast avg", 12, 2, 200, 1 );
r2 = Param( "Slow avg", 26, 2, 200, 1 );
r3 = Param( "Signal avg", 9, 2, 200, 1 );

TimeFrameSet(in1Minute * 3);
//K=M;
//D=S
M60 = MACD(r1, r2);
S60 = Signal(r1,r2,r3);
TimeFrameRestore();
M = TimeFrameExpand(M60, in1Minute * 3);
S = TimeFrameExpand(S60, in1Minute * 3);
Hi = IIf(M > S, M, S);
Lo = IIf(M < S, M, S);
COLOR = IIf(Ref(S,1) > Ref(M,1), colorPaleBlue, colorTan);
//COLOR = IIf(K > D AND (K > 80 OR D > 80) OR D > K AND (K < 20 OR D <20), colorLightGrey, COLOR);
PlotOHLC(Lo,Hi,Lo,Hi,"",COLOR, styleNoLabel | styleCloud);
Plot(S, "S60", colorBlack, styleThick );
Plot(M, "M60", colorBlack, styleThick );
//===================================

_SECTION_END();
 
Hi
Please add cross over buy sell arrows,


_SECTION_END();
Here it is for you reference.


_SECTION_BEGIN("MACD_3_MINS");
r1 = Param( "Fast avg", 12, 2, 200, 1 );
r2 = Param( "Slow avg", 26, 2, 200, 1 );
r3 = Param( "Signal avg", 9, 2, 200, 1 );

TimeFrameSet(in1Minute * 3);
//K=M;
//D=S
M60 = MACD(r1, r2);
S60 = Signal(r1,r2,r3);
TimeFrameRestore();
M = TimeFrameExpand(M60, in1Minute * 3);
S = TimeFrameExpand(S60, in1Minute * 3);
Hi = IIf(M > S, M, S);
Lo = IIf(M < S, M, S);
COLOR = IIf(Ref(S,1) > Ref(M,1), colorPaleBlue, colorTan);
Sell = Cross(S,M);
Buy = Cross(M,S);
PlotShapes( Buy * shapeUpArrow + Sell * shapeDownArrow, IIf( Buy, colorGreen, colorRed ) );
//COLOR = IIf(K > D AND (K > 80 OR D > 80) OR D > K AND (K < 20 OR D <20), colorLightGrey, COLOR);
PlotOHLC(Lo,Hi,Lo,Hi,"",COLOR, styleNoLabel | styleCloud);
Plot(S, "S60", colorBlack, styleThick );
Plot(M, "M60", colorBlack, styleThick );

_SECTION_END();
 
and starsystem sir add doji in above candlestick exploration code with confirmation which i explained in attached picture....and show on chart where it formed...pls sir
thanks in advance.
 

Attachments

Hello,

There is nothing in the code that prevents hourly or even 1 min explorations from showing results. Hourly Explorations run perfectly on my system. I have made slight modification which ***might*** be causing that.

From line 357 replace following.

STS = /*Bears*/
WriteIf(KBR, "Bearish Kicker", "") +
WriteIf(EveningDojiStar, "Evening Doji Star", "") +
WriteIf(EveningStar, "Evening Star","") +
WriteIf(GraveStoneDoji, "Grave Stone Doji","") +
WriteIf(Bear3Formation, "Bear 3 Formation","") +
WriteIf(BearishAbandonedBaby, "Bearish Abandoned Baby","") +
WriteIf(BearishBeltHold, "Bearish Belt Hold","") +
WriteIf(BearishCounterAttack, "Bearish Counter Attack","") +
WriteIf(BearishHaramiCross, "Bearish Harami Cross","") +
WriteIf(BearishHarami, "Bearish Harami","") +
WriteIf(BearishSeparatingLine, "BearishSeparatingLine","") +
WriteIf(DarkCloudCover, "DarkCloudCover","") +
WriteIf(EngulfingBear, "Engulfing Bear","") +
WriteIf(HangingMan, "Hanging Man","") +
WriteIf(ShootingStar, "Shooting Star","") +
WriteIf(ThreeBlackCrows, "Three Black Crows","") +
WriteIf(TriStarBottom, "TriStar Bottom","") +
WriteIf(TweezerTops, "Tweezer Tops","") +
WriteIf(UpsideGapTwoCrows, "UpsideGapTwoCrows", "") +
/*Bulls*/
WriteIf(KBL, "Bullish Kicker","") +
WriteIf(MorningStar, "Morning Star","") +
WriteIf(MorningDojiStar, "Morning Doji Star","") +
WriteIf(Bull3Formation, "Bull 3 Formation","") +
WriteIf(BullishAbandonedBaby, "Bullish Abandoned Baby","") +
WriteIf(BullishBeltHold, "Bullish Belt Hold","") +
WriteIf(BullishCounterAttack, "Bullish Counter Attack","") +
WriteIf(BullishHaramiCross, "Bullish Harami Cross","") +
WriteIf(BullishHarami, "Bullish Harami","") +
WriteIf(BullishSeparatingLine, "Bullish Separating Line","") +
WriteIf(DragonflyDoji, "Dragonfly Doji","") +
WriteIf(EngulfingBull, "Engulfing Bull","") +
WriteIf(Hammer, "Hammer","") +
WriteIf(InvertedHammer, "Inverted Hammer","") +
WriteIf(PiercingLine, "Piercing Line","") +
WriteIf(SeperatingLines, "Seperating Lines","") +
WriteIf(ThreeWhiteSoldiers, "Three White Soldiers","") +
WriteIf(TriStarTop, "Tri-Star Top","") +
WriteIf(TweezerBottoms, "Tweezer Bottoms","");

Filter = 1;

Col = IIf(KBR OR EveningDojiStar OR EveningStar OR GraveStoneDoji OR Bear3Formation OR BearishAbandonedBaby
OR BearishBeltHold OR BearishCounterAttack OR BearishHaramiCross OR BearishHarami OR BearishSeparatingLine
OR DarkCloudCover OR EngulfingBear OR HangingMan OR ShootingStar OR ThreeBlackCrows OR TriStarBottom
OR TweezerTops OR UpsideGapTwoCrows, colorRed, IIf( MorningStar OR MorningDojiStar OR Bull3Formation
OR BullishAbandonedBaby OR BullishBeltHold OR BullishCounterAttack OR BullishHaramiCross
OR BullishHarami OR BullishSeparatingLine OR DragonflyDoji OR EngulfingBull OR Hammer OR InvertedHammer
OR PiercingLine OR SeperatingLines OR ThreeWhiteSoldiers OR TriStarTop OR TweezerBottoms OR KBL, colorGreen, colorRed));
AddColumn(C, "Close", 1.2);
AddTextColumn(sts, "Candle", 1.0, Col, colorDefault,100);
 
sir i replaced as u mentioned but still on hourly tf it is showing wrong result...means it is showing all hourly formed candles ....pls see result on hourly tf u will understand.
and sir i want doji explorer in this code bt it should scan only those doji which i attached in pic means a green candle close above doji high and for sell red candle close below doji low ....sir pls add theses both cnditions in above afl.
 
Hello,

There is nothing in the code that prevents hourly or even 1 min explorations from showing results. Hourly Explorations run perfectly on my system. I have made slight modification which ***might*** be causing that.

From line 357 replace following.

STS = /*Bears*/
WriteIf(KBR, "Bearish Kicker", "") +
WriteIf(EveningDojiStar, "Evening Doji Star", "") +
WriteIf(EveningStar, "Evening Star","") +
WriteIf(GraveStoneDoji, "Grave Stone Doji","") +
WriteIf(Bear3Formation, "Bear 3 Formation","") +
WriteIf(BearishAbandonedBaby, "Bearish Abandoned Baby","") +
WriteIf(BearishBeltHold, "Bearish Belt Hold","") +
WriteIf(BearishCounterAttack, "Bearish Counter Attack","") +
WriteIf(BearishHaramiCross, "Bearish Harami Cross","") +
WriteIf(BearishHarami, "Bearish Harami","") +
WriteIf(BearishSeparatingLine, "BearishSeparatingLine","") +
WriteIf(DarkCloudCover, "DarkCloudCover","") +
WriteIf(EngulfingBear, "Engulfing Bear","") +
WriteIf(HangingMan, "Hanging Man","") +
WriteIf(ShootingStar, "Shooting Star","") +
WriteIf(ThreeBlackCrows, "Three Black Crows","") +
WriteIf(TriStarBottom, "TriStar Bottom","") +
WriteIf(TweezerTops, "Tweezer Tops","") +
WriteIf(UpsideGapTwoCrows, "UpsideGapTwoCrows", "") +
/*Bulls*/
WriteIf(KBL, "Bullish Kicker","") +
WriteIf(MorningStar, "Morning Star","") +
WriteIf(MorningDojiStar, "Morning Doji Star","") +
WriteIf(Bull3Formation, "Bull 3 Formation","") +
WriteIf(BullishAbandonedBaby, "Bullish Abandoned Baby","") +
WriteIf(BullishBeltHold, "Bullish Belt Hold","") +
WriteIf(BullishCounterAttack, "Bullish Counter Attack","") +
WriteIf(BullishHaramiCross, "Bullish Harami Cross","") +
WriteIf(BullishHarami, "Bullish Harami","") +
WriteIf(BullishSeparatingLine, "Bullish Separating Line","") +
WriteIf(DragonflyDoji, "Dragonfly Doji","") +
WriteIf(EngulfingBull, "Engulfing Bull","") +
WriteIf(Hammer, "Hammer","") +
WriteIf(InvertedHammer, "Inverted Hammer","") +
WriteIf(PiercingLine, "Piercing Line","") +
WriteIf(SeperatingLines, "Seperating Lines","") +
WriteIf(ThreeWhiteSoldiers, "Three White Soldiers","") +
WriteIf(TriStarTop, "Tri-Star Top","") +
WriteIf(TweezerBottoms, "Tweezer Bottoms","");

Filter = 1;

Col = IIf(KBR OR EveningDojiStar OR EveningStar OR GraveStoneDoji OR Bear3Formation OR BearishAbandonedBaby
OR BearishBeltHold OR BearishCounterAttack OR BearishHaramiCross OR BearishHarami OR BearishSeparatingLine
OR DarkCloudCover OR EngulfingBear OR HangingMan OR ShootingStar OR ThreeBlackCrows OR TriStarBottom
OR TweezerTops OR UpsideGapTwoCrows, colorRed, IIf( MorningStar OR MorningDojiStar OR Bull3Formation
OR BullishAbandonedBaby OR BullishBeltHold OR BullishCounterAttack OR BullishHaramiCross
OR BullishHarami OR BullishSeparatingLine OR DragonflyDoji OR EngulfingBull OR Hammer OR InvertedHammer
OR PiercingLine OR SeperatingLines OR ThreeWhiteSoldiers OR TriStarTop OR TweezerBottoms OR KBL, colorGreen, colorRed));
AddColumn(C, "Close", 1.2);
AddTextColumn(sts, "Candle", 1.0, Col, colorDefault,100);
sir i replaced as u mentioned but still on hourly tf it is showing wrong result...means it is showing all hourly formed candles ....pls see result on hourly tf u will understand.
and sir i want doji explorer in this code bt it should scan only those doji which i attached in pic means a green candle close above doji high and for sell red candle close below doji low ....sir pls add theses both cnditions in above afl.
 

john302928

Well-Known Member
https://aflcode.com/swing-high-swing-low-finder/
Hi there is a swing high low plotting afl in the above link. Could anyone please help me add the exploration and I would like to have the results table as scrip name, latest swing high value, latest swing low value

Please help . thanks
 

Similar threads