AFL needed pls help

#2
AFL need to draw a line between HH(highest high) and LL(Lowest low) calculated between specific time period.suppose(10:00-11:30).
Hello friend
I have an AFL that plots HH,HL,LL,LH in chart but this couldn't calculate specific time between two points. I post the AFL hope it's help you little .


Regards
AnAtheist:)

_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();

_SECTION_BEGIN("vol histr");

PlotVOL = ParamToggle( "plot Volume?","No| Yes",0);

VolColor = (C>O OR (C==O AND (H-C)<=(C-L)))*ParamColor ("VUpColor" ,colorGreen) +

(C<O OR (C==O AND (H-C)>(C-L)))*ParamColor( "VDnColor" ,colorRed) ;

VolScale = Param("1/Vol. Height (TimeBar chart)(fraction of window) 5=1/5=20%",5, 2, 100, 1.0) ; // Timebars

if (PlotVOL >0)

{

Vheight = VolScale;

Plot(Prec(Volume ,0),"V",VolColor, styleNoTitle| styleOwnScale| styleThick| ParamStyle( "VStyle", styleHistogram,

maskHistogram) ,Vheight );

}
_SECTION_END();

_SECTION_BEGIN("hhll");
Q = Param( "% Change", 2, 0.1, 10, 0.1 );
Z = Zig( C , q ) ;
HH = ( ( Z < Ref( Z, -1 ) AND Ref( Z, -1 ) > Ref( Z, -2 ) ) AND (Peak( z, q, 1 ) > Peak( Z, q, 2 ) ) );
LH = ( ( Z < Ref( Z, -1 ) AND Ref( Z, -1 ) > Ref( Z, -2 ) ) AND (Peak( Z, q, 1 ) < Peak( Z, q, 2 ) ) );
HL = ( ( Z > Ref( Z, -1 ) AND Ref( Z, -1 ) < Ref( Z, -2 ) ) AND (Trough( Z, q, 1 ) > Trough( Z, q, 2 ) ) );
LL = ( ( Z > Ref( Z, -1 ) AND Ref( Z, -1 ) < Ref( Z, -2 ) ) AND (Trough( Z, q, 1 ) < Trough( Z, q, 2 ) ) );
GraphXSpace = 5;
dist = 0.5 * ATR( 20 );

for ( i = 0; i < BarCount; i++ )
{
if ( HH )
PlotText( "HH", i, H[ i ] + dist, colorYellow );

if ( LH )
PlotText( "LH", i, H[ i ] + dist, colorYellow );

if ( HL )
PlotText( "HL", i, L[ i ] - dist, colorPink );

if ( LL )
PlotText( "LL", i, L[ i ] - dist, colorPink );

}
_SECTION_END();

_SECTION_BEGIN("BACK COLR");
SetChartBkGradientFill( ParamColor("BgTop", ColorRGB( 172,172,172 )),

ParamColor("BgBottom", ColorRGB( 172,172,172 )),ParamColor("titleblock",ColorRGB( 172,172,172 )));
_SECTION_END();
 
#3
Hi thanx for replying.i checked u r code..its jus showing O,H,L,C(iam using a new version of AB) after calculating HH,LL or upper or lower trendline.
if i want to plot a pattern or a line i use Plot then price blah blah but can i plot line between two prices nearby or suppose HHV,LLV using "Plot".
can i use Gfxmoveto,GfxLineto to draw a line but how can i find the coordinates of a specific price(HHV) at a given time in a graph.

kindly help if u have any info.
 
#5
i figured out how to do it.
NIFTY 1 MIN INTRADAY TRADING AFL
_SECTION_BEGIN("Exact cross over");
// Plotting the Price;
Plot (C,"close",colorBlack ,styleCandle );
P1=Ref(HHV(High,30),-1);
P2=Ref(LLV(Low,30),-1);

P3=(P1+P2)/2;

//Plotting Fast EMAs;
Plot(P1 ,"P1",colorBlue ,styleLine );
//Plotting Slow EMAs
Plot(P2,"P2",colorRed ,styleLine );
// calculation of crossover value;
g=(EMA(Close, 3) * (2 / 4 - 1)-EMA(Close, 15) * (2 / 16 - 1)) / (2 /4- 2 /16);
// explanation : 2/4 is actually 2/(Fast ema+1) and 2/61 is 2/(slow ema+1)
e=Ref(g,-1);
//buy or sell conditions;


Buy=Cross( C,P3);
Sell=Cross(P2,C);

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


// Plotting shapes;
shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
PlotShapes( shape, IIf( Buy, colorGreen, colorRed ),0, IIf( Buy, Low, High ) );
//displaying signals with crossover value;
GraphXSpace = 5;

_SECTION_END();



NumColumns =6;

Column0 = Buy;
Column0Name = "315 BUY";
Column1= Sell;
Column1Name= "315 SELL";


Column2= V;
Column2Name= "volume";

Column3= V/Ref(V,-1);
Column3Name= "volume change";


Column4= C;
Column4Name= "close";


Column5= ((C-Ref(C,-1))/Ref(C,-1))*100;
Column5Name= "% gain";


Buy= Buy;
Sell= Sell;

Filter= V>50000 AND ( Buy OR Sell) AND Column5>0.5 AND C>50 ;
 
#6
i dont understand what u r afl is trying to do..its not what i want!
u posted this!!
sir,
pl help to make afl for following simple conditions.

1. eight fixed time zones 9.30 to 10.00, 10.01 to 10.30 till mkt ends.
2. first buy signals will comeafter completed first time .i.e after 10.01
3. high and low of all time zones are to be displayed.
4. buy or sell signal will generate if price cross high or low of previous time zone only.
5.exrem to be used .
thanks.
lol
i will see what i can do?
 

mehtaka

Active Member
#8
Can anyone help me out to rectify the erros in this AFL.


SetOption("EveryBarNullCheck", True);_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} - O : %g, H : %g, L : %g, C : %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
SetChartOptions(0,chartShowArrows|chartShowDates | chartWrapTitle | chartLogarithmic);_SECTION_BEGIN("Chart Display Theme");CDT = ParamList
("Chart Display Theme", "White background with B/W candles|Black background with R/G candles",1);param_ShowSystemTitle = ParamToggle("Show System Title ?","No|Yes",1); param_ignoreWarning = ParamToggle("Ignore Warning ?","No|Yes");TA_CDT(CDT);_SECTION_END();_SECTION_BEGIN("Alerts");Param_AudioAlert = ParamToggle("Audio / text Alert?","No|Yes",1);Param_ManualVoiceAlerts = ParamToggle
("Alert in human voice?","No|Yes",1);Param_AlertFrequency = Param("Audio Alert / human voice alert frequency?",10,5,1000,1);Param_ShowValuesBox = ParamToggle("Display values in Box?","No|Yes",1);Param_BoxLocation = ParamList("Box Location?", "Left Top|Left Bottom|Right Top|Right Bottom",0);Param_BoxBackgroundColour = ParamColor
("Box background colour?",colorDarkGrey);Param_HideBoxBehindChart = ParamToggle("Hide Box behind Chart?", "No|Yes");_SECTION_END();_SECTION_BEGIN("Money Management");Param_Show_Equity = ParamToggle("Show Equity ?(Enter correct INITIAL EQUITY in AA Settings)","No|Yes");Param_Margin = Param
("Margin required (used for backtesting only)", 15,0.001,100,0.001);Param_LotSize = Param("Lot Size (used for backtesting only)", 50,5,5000,5);Param_NoOfLots = Param("No of lots normally traded (used for backtesting only)",2,1,10000,1);Param_drawdown=ParamList("Trailing Stoploss Method", "% of total trade value|Fixed amount per share");Param_Stoploss_percent = Param
("Stoploss % per trade", 0.7,0.01,5,0.01);Param_Stoploss_amount = Param("Stoploss Amount per share", 15, 0.01,50000,0.01);_SECTION_END();_SECTION_BEGIN("Support-Resistance");Param_ShowResSup = ParamToggle("Show Resistance / Support ?","No|Yes");Param_HowManyRS = Param("How many Support / Resistance to show ?",2,0,10,1);Param_ResSupVolatility = Param
("Support / Resistance Volatility ",0.1,0.1,100,0.1);Param_SupLineColor = ParamColor("Support Line Color",colorBrightGreen);Param_SupLineStyle = ParamStyle("Support Line Style", styleLine|styleNoTitle);Param_ResLineColor = ParamColor("Resistance Line Color",colorRed);Param_ResLineStyle = ParamStyle("Resistance Line Style",
styleLine|styleNoTitle);if(Param_ShowResSup AND Param_HowManyRS>0) TA_SSR(Param_HowManyRS,Param_ResSupVolatility,Param_SupLineColor,Param_ResLineColor,Param_SupLineStyle,Param_ResLineStyle);_SECTION_END();_SECTION_BEGIN("Trading System");Param_ShowReversals =
ParamToggle("Show possible reversals ?","No|Yes");if(Param_ShowReversals) TA_SR();Param_ShowArrows = ParamToggle("Show Buy/Sell/Short/Cover Arrows ?","No|Yes",1);firstBarEntryExit = ParamToggle("First bar trade entry / exit ?","No|Yes");CloseDailyPosition =
ParamToggle("Close Daily Position?","No|Yes");ExitOnCandleNo = Param("If yes, exit on Candle No?",76,5,500); TA_TSCEN(firstBarEntryExit,CloseDailyPosition,ExitOnCandleNo);_SECTION_END();
SetOption("AllowSameBarExit", False);SetOption("AllowPositionShrinking", False);SetOption("FuturesMode", True);SetOption("InterestRate",0);SetOption("MaxOpenPositions",1);RoundLotSize = Param_LotSize;
SetOption("MinShares",RoundLotSize);SetOption("PriceBoundChecking",False);SetOption("AccountMargin",Param_Margin);SetOption("ReverseSignalForcesExit",True);SetOption("UsePrevBarEquityForPosSizing",True);
SetOption("GenerateReport",1);SetOption("MaxOpenLong",1);SetOption("MaxOpenShort",1);SetOption("RefreshWhenCompleted",True);SetPositionSize( RoundLotSize*Param_NoOfLots, spsShares ); SetTradeDelays(0,0,0,0);
BuyPrice = Close;SellPrice = Close;ShortPrice = Close;CoverPrice = Close; TA_TSCE(Param_drawdown,Param_NoOfLots,Param_Stoploss_Percent,Param_Stoploss_amount,Param_LotSize,firstBarEntryExit,CloseDailyPosition,ExitOnCandleNo);TA_PEAAVB
(Param_BoxLocation, Param_Show_Equity,Param_ShowArrows,Param_AudioAlert,Param_ManualVoiceAlerts, Param_AlertFrequency,param_ShowSystemTitle,Param_ShowValuesBox, Param_HideBoxBehindChart,Param_BoxBackgroundColour,param_ignoreWarning);_SECTION_BEGIN("Volume Selector");showVolume =
ParamToggle("Show Volume ?", "No|Yes",1);displayStyle = ParamList("Volume Display Mode", "Normal Volume|Coloured Volume|Volume at Price|Volume at Price (grouped)|Volume at Price + Volume|Volume at Price + Coloured Volume|Volume at Price (grouped) + Volume|Volume at Price (grouped) + Coloured Volume|Customised VAP / candles");Param_NormalVolumeColor
= ParamColor("Normal Volume Colour", colorDarkBlue); Param_NormalVolumeStyle = ParamStyle( "Normal Volume Style", styleHistogram | styleOwnScale | styleNoLabel, maskHistogram );Param_UpVolumeColor =
ParamColor("Up Volume Colour", colorGreen); Param_DownVolumeColor = ParamColor("Down Volume Colour", colorRed); Param_ColouredVolumeStyle = ParamStyle( "Coloured Volume Style", styleHistogram | styleOwnScale | styleNoLabel, maskHistogram);Param_VAPLinesCount =
Param("VAP Lines Count", 100, 5, 1000, 1 ); Param_VAPLinesWidth = Param("VAP Lines Width", 40, 1, 100, 1 ); Param_VAPVolumeColor = ParamColor("VAP Color", colorGold);Param_VAPSide = ParamToggle("VAP Side", "Left|Right" ); Param_VAPOverlay =
4*ParamToggle("VAP Z-order", "On top|Behind", 1 ); Param_VAPStyle = 2 * ParamToggle("VAP(grouped) Style", "Fill|Lines",1);Param_Segment = Param("No. of candles for Customized VAP",10,2,1000,1);if(showVolume){segmentValue
= IIf( Interval() < inDaily, Day(), Month() );segmentValue = segmentValue != Ref( segmentValue, -1 );if(displayStyle =="Normal Volume"){Plot( Volume, "Vol ", Param_NormalVolumeColor, Param_NormalVolumeStyle, 2);}else if
(displayStyle == "Coloured Volume"){Plot( Volume, "Vol ", IIf( C > O, Param_UpVolumeColor,Param_DownVolumeColor), Param_ColouredVolumeStyle, 2);}else if (displayStyle =="Volume at Price"){PlotVAPOverlay
(Param_VAPLinesCount , Param_VAPLinesWidth, Param_VAPVolumeColor, Param_VAPSide | Param_VAPOverlay );}else if (displayStyle=="Volume at Price (grouped)"){PlotVAPOverlayA(segmentValue, Param_VAPLinesCount, Param_VAPLinesWidth, Param_VAPVolumeColor, Param_VAPSide | Param_VAPStyle | Param_VAPOverlay);}else if
(displayStyle =="Volume at Price + Volume"){Plot( Volume, "Vol ", Param_NormalVolumeColor, Param_NormalVolumeStyle, 2);PlotVAPOverlay( Param_VAPLinesCount , Param_VAPLinesWidth, Param_VAPVolumeColor, Param_VAPSide | Param_VAPOverlay );}else if (displayStyle =="Volume at Price + Coloured Volume"){Plot
( Volume, "Vol ", IIf( C > O, Param_UpVolumeColor,Param_DownVolumeColor), Param_ColouredVolumeStyle, 2);PlotVAPOverlay( Param_VAPLinesCount , Param_VAPLinesWidth, Param_VAPVolumeColor, Param_VAPSide | Param_VAPOverlay );}else if (displayStyle=="Volume at Price (grouped) + Volume"){Plot
( Volume, "Vol ", Param_NormalVolumeColor, Param_NormalVolumeStyle, 2);PlotVAPOverlayA(segmentValue, Param_VAPLinesCount, Param_VAPLinesWidth, Param_VAPVolumeColor, Param_VAPSide | Param_VAPStyle | Param_VAPOverlay);}else if (displayStyle=="Volume at Price (grouped) + Coloured Volume"){Plot
( Volume, "Vol ", IIf( C > O, Param_UpVolumeColor,Param_DownVolumeColor), Param_ColouredVolumeStyle, 2);PlotVAPOverlayA(segmentValue, Param_VAPLinesCount, Param_VAPLinesWidth, Param_VAPVolumeColor, Param_VAPSide | Param_VAPStyle | Param_VAPOverlay);}else if
(displayStyle=="Customised VAP / candles") TA_SCV(Param_Segment,Param_VAPLinesCount, Param_VAPLinesWidth, Param_VAPVolumeColor,Param_VAPSide,Param_VAPStyle,Param_VAPOverlay); _SECTION_END();}
 

sr114

Well-Known Member
#10
hi this is for u

// Intraday Range /////////////////
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
SetChartBkGradientFill( ParamColor("Inner panel upper",colorBlack),ParamColor("Inner panel lower",colorBlack));


//.....................................................
HiDay = TimeFrameGetPrice("H", inDaily);
LoDay = TimeFrameGetPrice("L", inDaily);
Plot(HiDay ,"",colorRed,styleDashed); // ,styleOwnScale);
Plot(LoDay ,"",colorBrightGreen,styleDashed); // , styleOwnScale);


//================================
HiHrly = TimeFrameGetPrice("H", inHourly);
LoHrly = TimeFrameGetPrice("L", inHourly);
Plot(HiHrly ,"",10,styleDashed); //,styleOwnScale );
Plot(LoHrly ,"",50,styleDashed); //,styleOwnScale );

//GraphXSpace=10;


Plot( C, "Cl.", colorBrightGreen, styleCandle );

//PlotShapes(shapeSmallCircle*(H==HiDay),colorBlue,0,H,20);
//PlotShapes(shapeSmallCircle*(L==Loday),colorBlue,0,L,-20);

PlotShapes(shapeSmallCircle*(H==HiHrly),4,0,H,20);
PlotShapes(shapeSmallCircle*(L==LoHrly),51,0,L,-20);


if( ParamToggle("Tooltip shows", "All Values|Only Prices" ) )
{
ToolTip=StrFormat("Open: %g\nHigh: %g\nLow: %g\nClose: %g (%.1f%%)\nVolume: "+NumToStr( V, 1.0 ), O, H, L, C, SelectedValue( ROC( C, 1 )));
}

Title =
EncodeColor(colorBrightGreen)+ "Hi-Lo" + " | " + Name() + " | " + EncodeColor(colorBrightGreen)+ Interval(2)
+ EncodeColor(colorBrightGreen) + " | " + Date() +" | "
+"\n"+EncodeColor(10) +"Open ="+O +","+" High ="+H +" ,"+" Low ="+L +","+ " Close ="+C + " | Volume : "+ WriteVal(V,1.0)
+"\n"+EncodeColor(colorBrightGreen) + "Day's Range = Rs." + EncodeColor(colorBrightGreen) + StrToNum(NumToStr((HiDay - LoDay), 1.2))+ "\n"+
EncodeColor(colorWhite) + "Day's Hi = Rs." + EncodeColor(colorWhite) + Hiday + "\n" +
EncodeColor(colorWhite) + "Day's Lo= Rs." + EncodeColor(colorWhite) + Loday + "\n" + "\n"+

EncodeColor(colorBrightGreen) + "Hrly Range = Rs." + EncodeColor(colorBrightGreen) + StrToNum(NumToStr((Hihrly - Lohrly), 1.2))+"\n"+
EncodeColor(colorWhite) + "Hrly Hi = Rs." + EncodeColor(colorWhite) + HiHrly + "\n" +
EncodeColor(colorWhite) + "Hrly Lo = Rs." + EncodeColor(colorWhite) + LoHrly + "\n" +"\n";


_SECTION_BEGIN("Magnified Market Price");
//by Vidyasagar, [email protected]//
FS=Param("Font Size",28,11,100,1);
GfxSelectFont("Arial", FS, 700, italic = False, underline = False, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorViolet) );
Hor=Param("Horizontal Position",766,1,1200,1);
Ver=Param("Vertical Position",1,1,1,1);
GfxTextOut("Cls : "+C,Hor , Ver );

YC=TimeFrameGetPrice("C",inDaily,-1);
DD=Prec(C-YC,2);
xx=Prec((DD/YC)*100,2);
GfxSelectFont("Arial", 12, 700, italic = False, underline = False, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor(ParamColor("Color",colorViolet) );
//GfxTextOut(""+DD+" ("+xx+"%)", Hor+5, Ver+45 );

_SECTION_END();

regards
sr114
 

Similar threads