Lot you want to find high beta stock in your portfolio.
Beta is basically measuring the volatility of stock. So if Yesbank has Beta reading over period of 50 days as 1.8 so this means if Nifty will move 1, Yesbank will move 1.8.
Use the code below for Beta Exploration.
Run explore on Amibroker for n last days = 1 //Setting when you click analysis in amibroker
function
Beta( BaseSymbol, N )
{
Chg =
ROC( C, 1 );
ChgBase =
ROC( Foreign( BaseSymbol, "C" ), 1 );
return ( N * Sum( Chg * ChgBase , N ) - Sum( Chg, N) * Sum( ChgBase, N ) ) /
( N *
Sum( ChgBase ^ 2 , N ) - Sum( ChgBase, N ) ^ 2 );
}
symbol =
ParamStr( "Symbol", "NSEnifty" );
Plot
( Beta( symbol, Param("Periods", 21, 2, 100 ) ), _DEFAULT_NAME(), ParamColor( "Color", ColorCycle ) );
Filter
=
1;
AddTextColumn
(FullName(), "FullName");
AddColumn
(Close, "Close", 1.2);
AddColumn
(Beta("NSEnifty",50), "Beta",1.2); //Replace NSEnifty with your Nifty Symbol here
Monday, September 7, 2015
Finding High Beta Stock in Amibroker
Sunday, August 2, 2015
Pivot Point AFL
This AFL plots all Pivots in chart with trend identifications.
//Mr.Divyesh worked out this
ppl = ParamToggle("","Off|On",1);
numbars = LastValue(Cum(Status("barvisible")));
fraction= IIf(StrRight(Name(),3) == "", 3.2, 3.2);
hts = -33.5;
_SECTION_BEGIN("Indicators");
RSI_Periods = Param("RSI Periods", 2, 1, 100, 1);
MA_Periods = Param("Periods for MAV", 50, 1, 200, 1);
Daily_Trend_MA_Pds = Param("Periods for Trend EMA", 6, 1, 100, 1);
MAV_Value = V/EMA(V, MA_Periods);
_SECTION_END();
// Check if previous day's close is above its 6-day EMA
DailyClose = TimeFrameCompress(Close, inDaily);
DailyEMA = EMA( DailyClose, Daily_Trend_MA_Pds);
DailyClose = TimeFrameExpand(DailyClose, inDaily, expandFirst);
DailyEma = TimeFrameExpand(DailyEMA, inDaily, expandFirst);
//Plot(DailyEma,"DailEma",colorCustom12,styleLine);
// Trend detection based on 6EMA for Daily
Daily_Trend_UP = DailyClose > DailyEMA;
Daily_Trend_DOWN = DailyClose < DailyEMA;
Trend_UP_Text = WriteIf(Daily_Trend_UP, "Daily Trend UP", "");
Trend_DOWN_Text = WriteIf(Daily_Trend_DOWN, "Daily Trend DOWN", "");
Trend_Neutral_Text = WriteIf(NOT Daily_Trend_DOWN AND NOT Daily_Trend_UP, "Neutral", "");
TrendCol = IIf(Daily_Trend_UP, colorGreen, IIf(Daily_Trend_DOWN, colorRed, colorLightGrey));
_SECTION_END();
_SECTION_BEGIN("i");
/* ICHIMOKU CHART */
n1 = Param("Èøèìîêó: ïåðèîä 1",9,1,200,1);
n2 = Param("Èøèìîêó: ïåðèîä 2",26,1,400,1);
n3 = Param("Èøèìîêó: ïåðèîä 3",52,1,600,1);
TenkanSen =(HHV(H,n1)+LLV(L,n1))/2; // Tenkan-sen (Òåíêàí-ñåí) – ýòî ñðåäíåå çíà÷åíèå öåíû çà ïåðâûé ïðîìåæóòîê âðåìåíè (ðàâíà (high+low)/2, ãäå high è low – ìàêñèìóì è ìèíèìóì çà ïåðèîä).
KijunSen =(HHV(H,n2)+LLV(L,n2))/2; // Kijun-sen (Êèäæóí-ñåí) – ýòî ñðåäíåå çíà÷åíèå öåíû çà âòîðîé ïðîìåæóòîê.
ChinkouSpan =Ref(C,-n2); // Chinkou Span (×èêîó ñïåí) - öåíà çàêðûòèÿ òåêóùåãî áàðà, ñäâèíóòàÿ íàçàä íà âåëè÷èíó âòîðîãî âðåìåííîãî èíòåðâàëà.
Cks = Close; // Ãðàôè÷åñêèé Chinkou Span, ñäâèã íàçàä çàñ÷åò îòðèñîâêè.
SenkouSpanA =Ref((KijunSen+TenkanSen)/2,-n2); // Senkou Span A (Ñåíêîó ñïåí À) / Up Kumo - ñåðåäèíà ðàññòîÿíèÿ ìåæäó Tenkan-sen è Kijun-sen, ñäâèíóòîå âïåðåä íà âåëè÷èíó âòîðîãî âðåìåííîãî èíòåðâàëà.
SpA =(KijunSen+TenkanSen)/2; // Ãðàôè÷åñêèé Senkou Span A , ñäâèã âïåðåä çàñ÷åò îòðèñîâêè.
SenkouSpanB =Ref((HHV(H,n3)+LLV(L,n3))/2,-n2); // Senkou Span B (Ñåíêîó ñïåí Â) / Down Kumo - ñðåäíåå çíà÷åíèå öåíû çà òðåòèé âðåìåííîé èíòåðâàë, ñäâèíóòîå âïåðåä íà âåëè÷èíó âòîðîãî âðåìåííîãî èíòåðâàëà.
SpB =(HHV(H,n3)+LLV(L,n3))/2; // Ãðàôè÷åñêèé Senkou Span B, ñäâèã âïåðåä çàñ÷åò îòðèñîâêè.
DL = Ref( C, 25 );
Plot (SpA,"SenkouSpanA",colorOrange,styleDashed,0,0,n2);
Plot (SpB,"SenkouSpanB",colorPink,styleDashed,0,0,n2);
_SECTION_END();
_SECTION_BEGIN("Price");
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
pds = 20;
MAFAST = EMA( Close, 20 );
MASLOW = EMA( Close, 40 );
DonchianUpper = HHV( Ref( H, -1 ), pds ); // Highest high value of highs in last 20 periods
DonchianLower = LLV( Ref( L, -1 ), pds ); // Lowest low value of low in last 20 periods
DonchianMiddle = ( DonchianUpper + DonchianLower ) / 2;
UpTrend = C > ( LLV( L, 20 ) + 2 * ATR( 10 ) ) AND EMA( Close, 20 ) > EMA( Close, 40 );
DnTrend = C < ( HHV( H, 20 ) - 2 * ATR( 10 ) ) AND EMA( Close, 20 ) < EMA( Close, 40 );
Color = IIf( UpTrend, colorBlue, IIf( DnTrend, colorRed, colorYellow) );
// Plots a 20 period Donchian channel
Plot( C, "Price", Color, styleCandle | styleThick );
NewDay = IIf(Day() != Ref(Day(), -1) OR BarIndex() == LastValue(BarIndex()), 1, 0);
//Plot(NewDay, "", 47, 2 + 32768 + 4096, Minvalue = 0, Maxvalue = 1);
_SECTION_END();
_SECTION_BEGIN("PIVOT POINTS");
/* This code calculates the previous days high, low and close */
Hi1 = IIf(Day()!=Ref(Day(),-1),Ref(HighestSince(Day()!=Ref(Day(),-1),H,1),-1),0);
Hi = ValueWhen(Day()!=Ref(Day(),-1),Hi1,1);
Lo1 = IIf(Day()!=Ref(Day(),-1),Ref(LowestSince(Day()!=Ref(Day(),-1),L,1),-1),0);
Lo = ValueWhen(Day()!=Ref(Day(),-1),Lo1,1);
Cl1 = IIf(Day()!=Ref(Day(),-1),Ref(C,-1),0);
C1 = ValueWhen(Day()!=Ref(Day(),-1),Cl1,1);
wHi=TimeFrameGetPrice("H",inWeekly,-1);
wLo=TimeFrameGetPrice("L",inWeekly,-1);
wCl=TimeFrameGetPrice("C",inWeekly,-1);
mHi=TimeFrameGetPrice("H",inMonthly,-1);
mLo=TimeFrameGetPrice("L",inMonthly,-1);
mCl=TimeFrameGetPrice("C",inMonthly,-1);
//----------------------------------------------------------------------------------
/* This code calculates Daily Piovts */
rg = (Hi - Lo);
bp = (Hi + Lo + C1)/3; bpI = LastValue (bp,1);
r1 = (bp*2)-Lo; r1I = LastValue (r1,1);
s1 = (bp*2)-Hi; s1I = LastValue (s1,1);
r2 = bp + r1 - s1; r2I = LastValue (r2,1);
s2 = bp - r1 + s1; s2I = LastValue (s2,1);
r3 = bp + r2 - s1; r3I = LastValue (r3,1);
s3 = bp - r2 + s1; s3I = LastValue (s3,1);
r4 = bp + r2 - s2; r4I = LastValue (r4,1);
s4 = bp - r2 + s2; s4I = LastValue (s4,1);
wrg = (wHi - wLo);
wbp = (wHi + wLo + wCl)/3; wbpI = LastValue (wbp,1);
wr1 = (wbp*2)-wLo; wr1I = LastValue (wr1,1);
ws1 = (wbp*2)-wHi; ws1I = LastValue (ws1,1);
wr2 = wbp + wr1 - ws1; wr2I = LastValue (wr2,1);
ws2 = wbp - wr1 + ws1; ws2I = LastValue (ws2,1);
wr3 = wbp + wr2 - ws1; wr3I = LastValue (wr3,1);
ws3 = wbp - wr2 + ws1; ws3I = LastValue (ws3,1);
wr4 = wbp + wr2 - ws2; wr4I = LastValue (wr4,1);
ws4 = wbp - wr2 + ws2; ws4I = LastValue (ws4,1);
mrg = (mHi - mLo);
mobp = (mHi + mLo + mCl)/3; mobpI = LastValue (mobp,1);
mr1 = (mobp*2)-mLo; mr1I = LastValue (mr1,1);
ms1 = (mobp*2)-mHi; ms1I = LastValue (ms1,1);
mr2 = mobp + mr1 - ms1; mr2I = LastValue (mr2,1);
ms2 = mobp - mr1 + ms1; ms2I = LastValue (ms2,1);
if(ppl==1) {
Plot(bp,"",colorBlue,styleDashed|styleLine|styleNoRescale);
Plot(s1,"",colorRed,styleDashed|styleNoRescale);
Plot(s2,"",colorRed,styleDashed|styleNoRescale);
Plot(s3,"",colorRed,styleDashed|styleNoRescale);
Plot(s4,"",colorRed,styleDashed|styleNoRescale);
Plot(r1,"",colorGreen,styleDashed|styleNoRescale);
Plot(r2,"",colorGreen,styleDashed|styleNoRescale);
Plot(r3,"",colorGreen,styleDashed|styleNoRescale);
Plot(r4,"",colorGreen,styleDashed|styleNoRescale);
Plot(wbp,"",colorTan,styleDashed|styleLine|styleNoRescale);
Plot(ws1,"",colorPaleGreen,styleDashed|styleNoRescale);
Plot(ws2,"",colorPaleGreen,styleDashed|styleNoRescale);
//Plot(ws3,"",colorPaleGreen,styleDashed|styleNoRescale);
//Plot(ws4,"",colorPaleGreen,styleDashed|styleNoRescale);
Plot(wr1,"",colorPaleBlue,styleDashed|styleNoRescale);
Plot(wr2,"",colorPaleBlue,styleDashed|styleNoRescale);
//Plot(wr3,"",colorPaleBlue,styleDashed|styleNoRescale);
//Plot(wr4,"",colorPaleBlue,styleDashed|styleNoRescale);
Plot(mobp,"",colorTan,styleDashed|styleLine|styleNoRescale);
Plot(ms1,"",colorPaleGreen,styleDashed|styleNoRescale);
Plot(mr1,"",colorPaleBlue,styleDashed|styleNoRescale);
PlotText(" Pivot = " + WriteVal(bp,fraction), LastValue(BarIndex())-(numbars/Hts), bpI +5, colorBlue);
PlotText(" Resistance 1 = " + WriteVal(r1,fraction), LastValue(BarIndex())-(numbars/Hts), r1I +0.05, colorGreen);
PlotText(" Support 1 = " + WriteVal(s1,fraction), LastValue(BarIndex())-(numbars/Hts), s1I +0.05, colorRed);
PlotText(" Resistance 2 = " + WriteVal(r2,fraction), LastValue(BarIndex())-(numbars/Hts), r2I +0.05, colorGreen);
PlotText(" Support 2 = " + WriteVal(s2,fraction), LastValue(BarIndex())-(numbars/Hts), s2I +0.05, colorRed);
PlotText(" Resistance 3 = " + WriteVal(r3,fraction), LastValue(BarIndex())-(numbars/Hts), r3I +0.05, colorGreen);
PlotText(" Support 3 = " + WriteVal(s3,fraction), LastValue(BarIndex())-(numbars/Hts), s3I +0.05, colorRed);
PlotText(" Resistance 4 = " + WriteVal(r4,fraction), LastValue(BarIndex())-(numbars/Hts), r4I +0.05, colorGreen);
PlotText(" Support 4 = " + WriteVal(s4,fraction), LastValue(BarIndex())-(numbars/Hts), s4I +0.05, colorRed);
PlotText(" W Pivot = " + WriteVal(wbp,fraction), LastValue(BarIndex())-(numbars/Hts), wbpI +0.05, colorTan);
PlotText(" W Resistance 1 = " + WriteVal(wr1,fraction), LastValue(BarIndex())-(numbars/Hts), wr1I +0.05, colorPaleBlue);
PlotText(" W Support 1 = " + WriteVal(ws1,fraction), LastValue(BarIndex())-(numbars/Hts), ws1I +0.05, colorPaleGreen);
PlotText(" W Resistance 2 = " + WriteVal(wr2,fraction), LastValue(BarIndex())-(numbars/Hts), wr2I +0.05, colorPaleBlue);
PlotText(" W Support 2 = " + WriteVal(ws2,fraction), LastValue(BarIndex())-(numbars/Hts), ws2I +0.05, colorPaleGreen);
//PlotText(" W Resistance 3 = " + WriteVal(wr3,fraction), LastValue(BarIndex())-(numbars/Hts), wr3I +0.05, colorPaleBlue);
//PlotText(" W Support 3 = " + WriteVal(ws3,fraction), LastValue(BarIndex())-(numbars/Hts), ws3I +0.05, colorPaleGreen);
//PlotText(" W Resistance 4 = " + WriteVal(wr4,fraction), LastValue(BarIndex())-(numbars/Hts), wr4I +0.05, colorPaleBlue);
//PlotText(" W Support 4 = " + WriteVal(ws4,fraction), LastValue(BarIndex())-(numbars/Hts), ws4I +0.05, colorPaleGreen);
PlotText(" M Pivot = " + WriteVal(mobp,fraction), LastValue(BarIndex())-(numbars/Hts), mobpI+0.05, colorTan);
PlotText(" M Resistance 1 = " + WriteVal(mr1,fraction), LastValue(BarIndex())-(numbars/Hts), mr1I+0.05, colorPaleBlue);
PlotText(" M Support 1 = " + WriteVal(ms1,fraction), LastValue(BarIndex())-(numbars/Hts), ms1I+0.05, colorPaleGreen);
}
_SECTION_END();
_SECTION_BEGIN("L.T.P.");
cx = Param( "cxposn", 1000, 0, 1250, 1 );
cy = Param( "cyposn", 25, 0, 500, 1 );
GfxSelectFont( "Candara", 18, 98, False );
gfxcup = SelectedValue(C > Ref(C,-1));
gfxpcolor = IIf(gfxcup,colorBrightGreen,colorRed);
GfxSetTextColor(gfxpcolor);
//GfxSetTextColor( colorWhite );
GfxTextOut( "L.T.P. " + C + " ", cx, cy );
_SECTION_END();
_SECTION_BEGIN("Background text");
SetChartBkColor(colorBlack);
strWeekday = StrMid("---sunday---Monday--TuesdayWednesday-Thursday--Friday--Saturday", SelectedValue(DayOfWeek())*9,9);
GraphXSpace=Param("GraphXSpace",15,-55,200,1);
C13=Param("fonts",20,10,30,1 );
C14=Param("left-right",2.1,1.0,5.0,0.1 );
C15=Param("up-down",12,1,20,1 );
Miny = Status("axisminy");
Maxy = Status("axismaxy");
lvb = Status("lastvisiblebar");
fvb = Status("firstvisiblebar");
pxwidth = Status("pxwidth");
pxheight = Status("pxheight");
GfxSetBkMode(transparent=1);
GfxSetOverlayMode(1);
GfxSelectFont("Candara", Status("pxheight")/C13 );
GfxSetTextAlign( 6 );
GfxSetTextColor( ColorRGB (217,217,213));
GfxTextOut( Name(), Status("pxwidth")/C14, Status("pxheight")/C15 );
GfxSelectFont("Tahoma", Status("pxheight")/C13*0.5 );
GfxSetTextColor( ColorRGB (103,103,103));
GfxSelectFont("Candara", Status("pxheight")/C13*0.5 );
GfxSetTextColor( ColorRGB (103,103,103));
GfxSelectFont("MS Sans Serif", 10, 500, False, False, 0);
_SECTION_END();
_SECTION_BEGIN("Title");
DODay = TimeFrameGetPrice("O", inDaily);
DHiDay = TimeFrameGetPrice("H", inDaily);
DLoDay = TimeFrameGetPrice("L", inDaily);
Title = EncodeColor(colorWhite)+ Name() + ", " + Interval(2) + ", " + Date() + " - "+strWeekday + " - " +
EncodeColor(colorWhite) + "\nO " + EncodeColor(colorWhite) + O +
", H : " + H +
", L : " + L +
", C : " + C +
"\n"+EncodeColor(colorWhite)+ " Day-Open : " +DODay + " Day-High : " +DHiDay + " Day-Low : " + DLoDay +
"\n" + EncodeColor(colorRed) + Trend_Down_Text + EncodeColor(colorBrightGreen) + Trend_Up_Text +
EncodeColor(colorWhite) + Trend_Neutral_Text +
EncodeColor(colorCustom12) + " || Trend value: " + WriteVal(DailyEMA,1)
;
_SECTION_BEGIN("Time Left");
function GetSecondNum()
{
Time = Now( 4 );
Seconds = int( Time % 100 );
Minutes = int( Time / 100 % 100 );
Hours = int( Time / 10000 % 100 );
SecondNum = int( Hours * 60 * 60 + Minutes * 60 + Seconds );
return SecondNum;
}
RequestTimedRefresh( 1 );
TimeFrame = Interval();
SecNumber = GetSecondNum();
Newperiod = SecNumber % TimeFrame == 0;
SecsLeft = SecNumber - int( SecNumber / TimeFrame ) * TimeFrame;
SecsToGo = TimeFrame - SecsLeft;
x=Param("xposn",430,0,1000,1);
y=Param("yposn",40,0,1000,1);
GfxSelectSolidBrush( ColorRGB( 230, 230, 230 ) );
GfxSelectPen( ColorRGB( 230, 230, 230 ), 2 );
if ( NewPeriod )
{
GfxSelectSolidBrush( colorYellow );
GfxSelectPen( colorYellow, 2 );
Say( "New period" );
}
cx = Param( "cxposn", 1100, 0, 1250, 1 );
cy = Param( "cyposn", 10, 0, 500, 1 );
GfxSelectFont( "Candara", 12, 98, False );
//gfxcup = SelectedValue(C > Ref(C,-1));
//gfxpcolor = IIf(gfxcup,colorBrightGreen,colorRed);
GfxSetTextColor(colorRed);
//GfxSetTextColor( colorWhite );
GfxTextOut( "T i m e L e f t " + SecsToGo + " ", cx, cy );
_SECTION_END();
_SECTION_BEGIN("PIVOTS Hourly");
TimeFrameSet(inHourly);
HourlyH= LastValue(Ref(H,-1));
HourlyL= LastValue(Ref(L,-1));
HourlyC= LastValue(Ref(C,-1));
TimeFrameRestore();
//Daily
HPP = (HourlyL + HourlyH + HourlyC)/3;HPPI = LastValue (HPP,1);
HR1 = (2 * HPP) - HourlyL;HR1I = LastValue (HR1,1);
HS1 = (2 * HPP) - HourlyH;HS1I = LastValue (HS1,1);
HR2 = HPP + (HourlyH - HourlyL);HR2I = LastValue (HR2,1);
HS2 = HPP - (HourlyH - HourlyL);HS2I = LastValue (HS2,1);
HR3 = HourlyH + 2*(HPP - HourlyL);HR3I = LastValue (HR3,1);
HS3 = HourlyL - 2*(HourlyH - HPP);HS3I = LastValue (HS3,1);
SHOWDPIVOTS = ParamToggle("Daily Pivots", "No|Yes",0);
SHOW3 = ParamToggle("3rd Line", "No|Yes",0);
if (SHOWDPIVOTS & SHOW3)
{
Plot(HS3, "S3",ColorR);
Plot(HR3, "R3",ColorG);
PlotText(" H Resis 3 = " + WriteVal(HR3,fraction), LastValue(BarIndex())-(numbars/Hts), HR3I +0.05, colorGreen);
PlotText(" H Sup 3 = " + WriteVal(HS3,fraction), LastValue(BarIndex())-(numbars/Hts), HS3I +0.05, colorRed);
}
for (i=BarCount-2;i>(BarCount-13);i--)//set the last bars to the final PP value
{
HPP[i] = HPP[BarCount-1];
HR1[i] = HR1[BarCount-1];
HR2[i] = HR2[BarCount-1];
HS1[i] = HS1[BarCount-1];
HS2[i] = HS2[BarCount-1];
ColorG[i] = colorGreen;
ColorB[i] = colorBlue;
ColorR[i] = colorRed;
}
//
// Conceal all but the trailing portion of the line
//
for (i=0;i<BarCount-15;i++) //hide the line except most recent 15 bars
{
ColorR[i] = ColorG[i] = ColorB[i] = colorBlack;
}
if (SHOWDPIVOTS) {
Plot(HR2, "R2",ColorG);
Plot(HR1, "R1",ColorG);
Plot(HPP, "PP",ColorB);
Plot(HS1, "S1",ColorR);
Plot(HS2, "S2",ColorR);
PlotText(" H Pivot = " + WriteVal(HPP,fraction), LastValue(BarIndex())-(numbars/Hts), HPPI +0.05, colorBlue);
PlotText(" H Resis 1 = " + WriteVal(HR1,fraction), LastValue(BarIndex())-(numbars/Hts), HR1I +0.05, colorGreen);
PlotText(" H Sup 1 = " + WriteVal(HS1,fraction), LastValue(BarIndex())-(numbars/Hts), HS1I +0.05, colorRed);
PlotText(" H Resis 2 = " + WriteVal(HR2,fraction), LastValue(BarIndex())-(numbars/Hts), HR2I +0.05, colorGreen);
PlotText(" H Sup 2 = " + WriteVal(HS2,fraction), LastValue(BarIndex())-(numbars/Hts), HS2I +0.05, colorRed);
}
if (SHOWDPIVOTS & SHOW3)
{
Plot(S3, "S3",ColorR);
Plot(R3, "R3",ColorG);
PlotText(" H Resis 3 = " + WriteVal(HR3,fraction), LastValue(BarIndex())-(numbars/Hts), HR3I +0.05, colorGreen);
PlotText(" H Sup 3 = " + WriteVal(HS3,fraction), LastValue(BarIndex())-(numbars/Hts), HS3I +0.05, colorRed);
}
_SECTION_END();
//Mr.Divyesh worked out this
ppl = ParamToggle("","Off|On",1);
numbars = LastValue(Cum(Status("barvisible")));
fraction= IIf(StrRight(Name(),3) == "", 3.2, 3.2);
hts = -33.5;
_SECTION_BEGIN("Indicators");
RSI_Periods = Param("RSI Periods", 2, 1, 100, 1);
MA_Periods = Param("Periods for MAV", 50, 1, 200, 1);
Daily_Trend_MA_Pds = Param("Periods for Trend EMA", 6, 1, 100, 1);
MAV_Value = V/EMA(V, MA_Periods);
_SECTION_END();
// Check if previous day's close is above its 6-day EMA
DailyClose = TimeFrameCompress(Close, inDaily);
DailyEMA = EMA( DailyClose, Daily_Trend_MA_Pds);
DailyClose = TimeFrameExpand(DailyClose, inDaily, expandFirst);
DailyEma = TimeFrameExpand(DailyEMA, inDaily, expandFirst);
//Plot(DailyEma,"DailEma",colorCustom12,styleLine);
// Trend detection based on 6EMA for Daily
Daily_Trend_UP = DailyClose > DailyEMA;
Daily_Trend_DOWN = DailyClose < DailyEMA;
Trend_UP_Text = WriteIf(Daily_Trend_UP, "Daily Trend UP", "");
Trend_DOWN_Text = WriteIf(Daily_Trend_DOWN, "Daily Trend DOWN", "");
Trend_Neutral_Text = WriteIf(NOT Daily_Trend_DOWN AND NOT Daily_Trend_UP, "Neutral", "");
TrendCol = IIf(Daily_Trend_UP, colorGreen, IIf(Daily_Trend_DOWN, colorRed, colorLightGrey));
_SECTION_END();
_SECTION_BEGIN("i");
/* ICHIMOKU CHART */
n1 = Param("Èøèìîêó: ïåðèîä 1",9,1,200,1);
n2 = Param("Èøèìîêó: ïåðèîä 2",26,1,400,1);
n3 = Param("Èøèìîêó: ïåðèîä 3",52,1,600,1);
TenkanSen =(HHV(H,n1)+LLV(L,n1))/2; // Tenkan-sen (Òåíêàí-ñåí) – ýòî ñðåäíåå çíà÷åíèå öåíû çà ïåðâûé ïðîìåæóòîê âðåìåíè (ðàâíà (high+low)/2, ãäå high è low – ìàêñèìóì è ìèíèìóì çà ïåðèîä).
KijunSen =(HHV(H,n2)+LLV(L,n2))/2; // Kijun-sen (Êèäæóí-ñåí) – ýòî ñðåäíåå çíà÷åíèå öåíû çà âòîðîé ïðîìåæóòîê.
ChinkouSpan =Ref(C,-n2); // Chinkou Span (×èêîó ñïåí) - öåíà çàêðûòèÿ òåêóùåãî áàðà, ñäâèíóòàÿ íàçàä íà âåëè÷èíó âòîðîãî âðåìåííîãî èíòåðâàëà.
Cks = Close; // Ãðàôè÷åñêèé Chinkou Span, ñäâèã íàçàä çàñ÷åò îòðèñîâêè.
SenkouSpanA =Ref((KijunSen+TenkanSen)/2,-n2); // Senkou Span A (Ñåíêîó ñïåí À) / Up Kumo - ñåðåäèíà ðàññòîÿíèÿ ìåæäó Tenkan-sen è Kijun-sen, ñäâèíóòîå âïåðåä íà âåëè÷èíó âòîðîãî âðåìåííîãî èíòåðâàëà.
SpA =(KijunSen+TenkanSen)/2; // Ãðàôè÷åñêèé Senkou Span A , ñäâèã âïåðåä çàñ÷åò îòðèñîâêè.
SenkouSpanB =Ref((HHV(H,n3)+LLV(L,n3))/2,-n2); // Senkou Span B (Ñåíêîó ñïåí Â) / Down Kumo - ñðåäíåå çíà÷åíèå öåíû çà òðåòèé âðåìåííîé èíòåðâàë, ñäâèíóòîå âïåðåä íà âåëè÷èíó âòîðîãî âðåìåííîãî èíòåðâàëà.
SpB =(HHV(H,n3)+LLV(L,n3))/2; // Ãðàôè÷åñêèé Senkou Span B, ñäâèã âïåðåä çàñ÷åò îòðèñîâêè.
DL = Ref( C, 25 );
Plot (SpA,"SenkouSpanA",colorOrange,styleDashed,0,0,n2);
Plot (SpB,"SenkouSpanB",colorPink,styleDashed,0,0,n2);
_SECTION_END();
_SECTION_BEGIN("Price");
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
pds = 20;
MAFAST = EMA( Close, 20 );
MASLOW = EMA( Close, 40 );
DonchianUpper = HHV( Ref( H, -1 ), pds ); // Highest high value of highs in last 20 periods
DonchianLower = LLV( Ref( L, -1 ), pds ); // Lowest low value of low in last 20 periods
DonchianMiddle = ( DonchianUpper + DonchianLower ) / 2;
UpTrend = C > ( LLV( L, 20 ) + 2 * ATR( 10 ) ) AND EMA( Close, 20 ) > EMA( Close, 40 );
DnTrend = C < ( HHV( H, 20 ) - 2 * ATR( 10 ) ) AND EMA( Close, 20 ) < EMA( Close, 40 );
Color = IIf( UpTrend, colorBlue, IIf( DnTrend, colorRed, colorYellow) );
// Plots a 20 period Donchian channel
Plot( C, "Price", Color, styleCandle | styleThick );
NewDay = IIf(Day() != Ref(Day(), -1) OR BarIndex() == LastValue(BarIndex()), 1, 0);
//Plot(NewDay, "", 47, 2 + 32768 + 4096, Minvalue = 0, Maxvalue = 1);
_SECTION_END();
_SECTION_BEGIN("PIVOT POINTS");
/* This code calculates the previous days high, low and close */
Hi1 = IIf(Day()!=Ref(Day(),-1),Ref(HighestSince(Day()!=Ref(Day(),-1),H,1),-1),0);
Hi = ValueWhen(Day()!=Ref(Day(),-1),Hi1,1);
Lo1 = IIf(Day()!=Ref(Day(),-1),Ref(LowestSince(Day()!=Ref(Day(),-1),L,1),-1),0);
Lo = ValueWhen(Day()!=Ref(Day(),-1),Lo1,1);
Cl1 = IIf(Day()!=Ref(Day(),-1),Ref(C,-1),0);
C1 = ValueWhen(Day()!=Ref(Day(),-1),Cl1,1);
wHi=TimeFrameGetPrice("H",inWeekly,-1);
wLo=TimeFrameGetPrice("L",inWeekly,-1);
wCl=TimeFrameGetPrice("C",inWeekly,-1);
mHi=TimeFrameGetPrice("H",inMonthly,-1);
mLo=TimeFrameGetPrice("L",inMonthly,-1);
mCl=TimeFrameGetPrice("C",inMonthly,-1);
//----------------------------------------------------------------------------------
/* This code calculates Daily Piovts */
rg = (Hi - Lo);
bp = (Hi + Lo + C1)/3; bpI = LastValue (bp,1);
r1 = (bp*2)-Lo; r1I = LastValue (r1,1);
s1 = (bp*2)-Hi; s1I = LastValue (s1,1);
r2 = bp + r1 - s1; r2I = LastValue (r2,1);
s2 = bp - r1 + s1; s2I = LastValue (s2,1);
r3 = bp + r2 - s1; r3I = LastValue (r3,1);
s3 = bp - r2 + s1; s3I = LastValue (s3,1);
r4 = bp + r2 - s2; r4I = LastValue (r4,1);
s4 = bp - r2 + s2; s4I = LastValue (s4,1);
wrg = (wHi - wLo);
wbp = (wHi + wLo + wCl)/3; wbpI = LastValue (wbp,1);
wr1 = (wbp*2)-wLo; wr1I = LastValue (wr1,1);
ws1 = (wbp*2)-wHi; ws1I = LastValue (ws1,1);
wr2 = wbp + wr1 - ws1; wr2I = LastValue (wr2,1);
ws2 = wbp - wr1 + ws1; ws2I = LastValue (ws2,1);
wr3 = wbp + wr2 - ws1; wr3I = LastValue (wr3,1);
ws3 = wbp - wr2 + ws1; ws3I = LastValue (ws3,1);
wr4 = wbp + wr2 - ws2; wr4I = LastValue (wr4,1);
ws4 = wbp - wr2 + ws2; ws4I = LastValue (ws4,1);
mrg = (mHi - mLo);
mobp = (mHi + mLo + mCl)/3; mobpI = LastValue (mobp,1);
mr1 = (mobp*2)-mLo; mr1I = LastValue (mr1,1);
ms1 = (mobp*2)-mHi; ms1I = LastValue (ms1,1);
mr2 = mobp + mr1 - ms1; mr2I = LastValue (mr2,1);
ms2 = mobp - mr1 + ms1; ms2I = LastValue (ms2,1);
if(ppl==1) {
Plot(bp,"",colorBlue,styleDashed|styleLine|styleNoRescale);
Plot(s1,"",colorRed,styleDashed|styleNoRescale);
Plot(s2,"",colorRed,styleDashed|styleNoRescale);
Plot(s3,"",colorRed,styleDashed|styleNoRescale);
Plot(s4,"",colorRed,styleDashed|styleNoRescale);
Plot(r1,"",colorGreen,styleDashed|styleNoRescale);
Plot(r2,"",colorGreen,styleDashed|styleNoRescale);
Plot(r3,"",colorGreen,styleDashed|styleNoRescale);
Plot(r4,"",colorGreen,styleDashed|styleNoRescale);
Plot(wbp,"",colorTan,styleDashed|styleLine|styleNoRescale);
Plot(ws1,"",colorPaleGreen,styleDashed|styleNoRescale);
Plot(ws2,"",colorPaleGreen,styleDashed|styleNoRescale);
//Plot(ws3,"",colorPaleGreen,styleDashed|styleNoRescale);
//Plot(ws4,"",colorPaleGreen,styleDashed|styleNoRescale);
Plot(wr1,"",colorPaleBlue,styleDashed|styleNoRescale);
Plot(wr2,"",colorPaleBlue,styleDashed|styleNoRescale);
//Plot(wr3,"",colorPaleBlue,styleDashed|styleNoRescale);
//Plot(wr4,"",colorPaleBlue,styleDashed|styleNoRescale);
Plot(mobp,"",colorTan,styleDashed|styleLine|styleNoRescale);
Plot(ms1,"",colorPaleGreen,styleDashed|styleNoRescale);
Plot(mr1,"",colorPaleBlue,styleDashed|styleNoRescale);
PlotText(" Pivot = " + WriteVal(bp,fraction), LastValue(BarIndex())-(numbars/Hts), bpI +5, colorBlue);
PlotText(" Resistance 1 = " + WriteVal(r1,fraction), LastValue(BarIndex())-(numbars/Hts), r1I +0.05, colorGreen);
PlotText(" Support 1 = " + WriteVal(s1,fraction), LastValue(BarIndex())-(numbars/Hts), s1I +0.05, colorRed);
PlotText(" Resistance 2 = " + WriteVal(r2,fraction), LastValue(BarIndex())-(numbars/Hts), r2I +0.05, colorGreen);
PlotText(" Support 2 = " + WriteVal(s2,fraction), LastValue(BarIndex())-(numbars/Hts), s2I +0.05, colorRed);
PlotText(" Resistance 3 = " + WriteVal(r3,fraction), LastValue(BarIndex())-(numbars/Hts), r3I +0.05, colorGreen);
PlotText(" Support 3 = " + WriteVal(s3,fraction), LastValue(BarIndex())-(numbars/Hts), s3I +0.05, colorRed);
PlotText(" Resistance 4 = " + WriteVal(r4,fraction), LastValue(BarIndex())-(numbars/Hts), r4I +0.05, colorGreen);
PlotText(" Support 4 = " + WriteVal(s4,fraction), LastValue(BarIndex())-(numbars/Hts), s4I +0.05, colorRed);
PlotText(" W Pivot = " + WriteVal(wbp,fraction), LastValue(BarIndex())-(numbars/Hts), wbpI +0.05, colorTan);
PlotText(" W Resistance 1 = " + WriteVal(wr1,fraction), LastValue(BarIndex())-(numbars/Hts), wr1I +0.05, colorPaleBlue);
PlotText(" W Support 1 = " + WriteVal(ws1,fraction), LastValue(BarIndex())-(numbars/Hts), ws1I +0.05, colorPaleGreen);
PlotText(" W Resistance 2 = " + WriteVal(wr2,fraction), LastValue(BarIndex())-(numbars/Hts), wr2I +0.05, colorPaleBlue);
PlotText(" W Support 2 = " + WriteVal(ws2,fraction), LastValue(BarIndex())-(numbars/Hts), ws2I +0.05, colorPaleGreen);
//PlotText(" W Resistance 3 = " + WriteVal(wr3,fraction), LastValue(BarIndex())-(numbars/Hts), wr3I +0.05, colorPaleBlue);
//PlotText(" W Support 3 = " + WriteVal(ws3,fraction), LastValue(BarIndex())-(numbars/Hts), ws3I +0.05, colorPaleGreen);
//PlotText(" W Resistance 4 = " + WriteVal(wr4,fraction), LastValue(BarIndex())-(numbars/Hts), wr4I +0.05, colorPaleBlue);
//PlotText(" W Support 4 = " + WriteVal(ws4,fraction), LastValue(BarIndex())-(numbars/Hts), ws4I +0.05, colorPaleGreen);
PlotText(" M Pivot = " + WriteVal(mobp,fraction), LastValue(BarIndex())-(numbars/Hts), mobpI+0.05, colorTan);
PlotText(" M Resistance 1 = " + WriteVal(mr1,fraction), LastValue(BarIndex())-(numbars/Hts), mr1I+0.05, colorPaleBlue);
PlotText(" M Support 1 = " + WriteVal(ms1,fraction), LastValue(BarIndex())-(numbars/Hts), ms1I+0.05, colorPaleGreen);
}
_SECTION_END();
_SECTION_BEGIN("L.T.P.");
cx = Param( "cxposn", 1000, 0, 1250, 1 );
cy = Param( "cyposn", 25, 0, 500, 1 );
GfxSelectFont( "Candara", 18, 98, False );
gfxcup = SelectedValue(C > Ref(C,-1));
gfxpcolor = IIf(gfxcup,colorBrightGreen,colorRed);
GfxSetTextColor(gfxpcolor);
//GfxSetTextColor( colorWhite );
GfxTextOut( "L.T.P. " + C + " ", cx, cy );
_SECTION_END();
_SECTION_BEGIN("Background text");
SetChartBkColor(colorBlack);
strWeekday = StrMid("---sunday---Monday--TuesdayWednesday-Thursday--Friday--Saturday", SelectedValue(DayOfWeek())*9,9);
GraphXSpace=Param("GraphXSpace",15,-55,200,1);
C13=Param("fonts",20,10,30,1 );
C14=Param("left-right",2.1,1.0,5.0,0.1 );
C15=Param("up-down",12,1,20,1 );
Miny = Status("axisminy");
Maxy = Status("axismaxy");
lvb = Status("lastvisiblebar");
fvb = Status("firstvisiblebar");
pxwidth = Status("pxwidth");
pxheight = Status("pxheight");
GfxSetBkMode(transparent=1);
GfxSetOverlayMode(1);
GfxSelectFont("Candara", Status("pxheight")/C13 );
GfxSetTextAlign( 6 );
GfxSetTextColor( ColorRGB (217,217,213));
GfxTextOut( Name(), Status("pxwidth")/C14, Status("pxheight")/C15 );
GfxSelectFont("Tahoma", Status("pxheight")/C13*0.5 );
GfxSetTextColor( ColorRGB (103,103,103));
GfxSelectFont("Candara", Status("pxheight")/C13*0.5 );
GfxSetTextColor( ColorRGB (103,103,103));
GfxSelectFont("MS Sans Serif", 10, 500, False, False, 0);
_SECTION_END();
_SECTION_BEGIN("Title");
DODay = TimeFrameGetPrice("O", inDaily);
DHiDay = TimeFrameGetPrice("H", inDaily);
DLoDay = TimeFrameGetPrice("L", inDaily);
Title = EncodeColor(colorWhite)+ Name() + ", " + Interval(2) + ", " + Date() + " - "+strWeekday + " - " +
EncodeColor(colorWhite) + "\nO " + EncodeColor(colorWhite) + O +
", H : " + H +
", L : " + L +
", C : " + C +
"\n"+EncodeColor(colorWhite)+ " Day-Open : " +DODay + " Day-High : " +DHiDay + " Day-Low : " + DLoDay +
"\n" + EncodeColor(colorRed) + Trend_Down_Text + EncodeColor(colorBrightGreen) + Trend_Up_Text +
EncodeColor(colorWhite) + Trend_Neutral_Text +
EncodeColor(colorCustom12) + " || Trend value: " + WriteVal(DailyEMA,1)
;
_SECTION_BEGIN("Time Left");
function GetSecondNum()
{
Time = Now( 4 );
Seconds = int( Time % 100 );
Minutes = int( Time / 100 % 100 );
Hours = int( Time / 10000 % 100 );
SecondNum = int( Hours * 60 * 60 + Minutes * 60 + Seconds );
return SecondNum;
}
RequestTimedRefresh( 1 );
TimeFrame = Interval();
SecNumber = GetSecondNum();
Newperiod = SecNumber % TimeFrame == 0;
SecsLeft = SecNumber - int( SecNumber / TimeFrame ) * TimeFrame;
SecsToGo = TimeFrame - SecsLeft;
x=Param("xposn",430,0,1000,1);
y=Param("yposn",40,0,1000,1);
GfxSelectSolidBrush( ColorRGB( 230, 230, 230 ) );
GfxSelectPen( ColorRGB( 230, 230, 230 ), 2 );
if ( NewPeriod )
{
GfxSelectSolidBrush( colorYellow );
GfxSelectPen( colorYellow, 2 );
Say( "New period" );
}
cx = Param( "cxposn", 1100, 0, 1250, 1 );
cy = Param( "cyposn", 10, 0, 500, 1 );
GfxSelectFont( "Candara", 12, 98, False );
//gfxcup = SelectedValue(C > Ref(C,-1));
//gfxpcolor = IIf(gfxcup,colorBrightGreen,colorRed);
GfxSetTextColor(colorRed);
//GfxSetTextColor( colorWhite );
GfxTextOut( "T i m e L e f t " + SecsToGo + " ", cx, cy );
_SECTION_END();
_SECTION_BEGIN("PIVOTS Hourly");
TimeFrameSet(inHourly);
HourlyH= LastValue(Ref(H,-1));
HourlyL= LastValue(Ref(L,-1));
HourlyC= LastValue(Ref(C,-1));
TimeFrameRestore();
//Daily
HPP = (HourlyL + HourlyH + HourlyC)/3;HPPI = LastValue (HPP,1);
HR1 = (2 * HPP) - HourlyL;HR1I = LastValue (HR1,1);
HS1 = (2 * HPP) - HourlyH;HS1I = LastValue (HS1,1);
HR2 = HPP + (HourlyH - HourlyL);HR2I = LastValue (HR2,1);
HS2 = HPP - (HourlyH - HourlyL);HS2I = LastValue (HS2,1);
HR3 = HourlyH + 2*(HPP - HourlyL);HR3I = LastValue (HR3,1);
HS3 = HourlyL - 2*(HourlyH - HPP);HS3I = LastValue (HS3,1);
SHOWDPIVOTS = ParamToggle("Daily Pivots", "No|Yes",0);
SHOW3 = ParamToggle("3rd Line", "No|Yes",0);
if (SHOWDPIVOTS & SHOW3)
{
Plot(HS3, "S3",ColorR);
Plot(HR3, "R3",ColorG);
PlotText(" H Resis 3 = " + WriteVal(HR3,fraction), LastValue(BarIndex())-(numbars/Hts), HR3I +0.05, colorGreen);
PlotText(" H Sup 3 = " + WriteVal(HS3,fraction), LastValue(BarIndex())-(numbars/Hts), HS3I +0.05, colorRed);
}
for (i=BarCount-2;i>(BarCount-13);i--)//set the last bars to the final PP value
{
HPP[i] = HPP[BarCount-1];
HR1[i] = HR1[BarCount-1];
HR2[i] = HR2[BarCount-1];
HS1[i] = HS1[BarCount-1];
HS2[i] = HS2[BarCount-1];
ColorG[i] = colorGreen;
ColorB[i] = colorBlue;
ColorR[i] = colorRed;
}
//
// Conceal all but the trailing portion of the line
//
for (i=0;i<BarCount-15;i++) //hide the line except most recent 15 bars
{
ColorR[i] = ColorG[i] = ColorB[i] = colorBlack;
}
if (SHOWDPIVOTS) {
Plot(HR2, "R2",ColorG);
Plot(HR1, "R1",ColorG);
Plot(HPP, "PP",ColorB);
Plot(HS1, "S1",ColorR);
Plot(HS2, "S2",ColorR);
PlotText(" H Pivot = " + WriteVal(HPP,fraction), LastValue(BarIndex())-(numbars/Hts), HPPI +0.05, colorBlue);
PlotText(" H Resis 1 = " + WriteVal(HR1,fraction), LastValue(BarIndex())-(numbars/Hts), HR1I +0.05, colorGreen);
PlotText(" H Sup 1 = " + WriteVal(HS1,fraction), LastValue(BarIndex())-(numbars/Hts), HS1I +0.05, colorRed);
PlotText(" H Resis 2 = " + WriteVal(HR2,fraction), LastValue(BarIndex())-(numbars/Hts), HR2I +0.05, colorGreen);
PlotText(" H Sup 2 = " + WriteVal(HS2,fraction), LastValue(BarIndex())-(numbars/Hts), HS2I +0.05, colorRed);
}
if (SHOWDPIVOTS & SHOW3)
{
Plot(S3, "S3",ColorR);
Plot(R3, "R3",ColorG);
PlotText(" H Resis 3 = " + WriteVal(HR3,fraction), LastValue(BarIndex())-(numbars/Hts), HR3I +0.05, colorGreen);
PlotText(" H Sup 3 = " + WriteVal(HS3,fraction), LastValue(BarIndex())-(numbars/Hts), HS3I +0.05, colorRed);
}
_SECTION_END();
Tuesday, July 28, 2015
Turtle trading system
Refer turtle trading or donchian channel for better use of this AFL
pds = 20;
MAFAST = EMA( Close, 20 );
MASLOW = EMA( Close, 40 );
DonchianUpper = HHV( Ref( H, -1 ), pds );
DonchianLower = LLV( Ref( L, -1 ), pds );
DonchianMiddle = ( DonchianUpper + DonchianLower ) / 2;
UpTrend = C > ( LLV( L, 20 ) + 2 * ATR( 10 ) ) AND EMA( Close, 20 ) > EMA( Close, 40 );
DnTrend = C < ( HHV( H, 20 ) - 2 * ATR( 10 ) ) AND EMA( Close, 20 ) < EMA( Close, 40 );
Color = IIf( UpTrend, colorBlue, IIf( DnTrend, colorOrange, colorCustom11 ) );
Plot( C, "Price", Color, styleBar | styleThick );
Plot( DonchianUpper, "Donchian U", ParamColor( "DU Color", colorBlue ), ParamStyle( "DU Style", styleLine ) );
Plot( DonchianMiddle, "Donchian M", ParamColor( "DM Color", colorBrightGreen ), ParamStyle( "DM Style", styleNoLine ) );
Plot( DonchianLower, "Donchian L", ParamColor( "DL Color", colorRed ), ParamStyle( "DL Style", styleLine ) );
Title = WriteVal( DonchianUpper, 1.2 ) + WriteVal( DonchianLower, 1.2 ) + WriteVal( DonchianMiddle, 1.2 );
Buy = High > Ref( HHV( High, 20 ), -1 ) AND MAFAST > MASLOW;
Short = Low < Ref( LLV( Low, 20 ), -1 ) AND MAFAST < MASLOW;
_SECTION_BEGIN( "Chandelier Exit" );
SetBarsRequired( 50, 50 );
Multiple = Param( "Multiple", 3, 0.5, 10, 0.1 );
ATRPeriods = Param( "ATR Periods", 20, 1, 50, 1 );
stopArray = Null;
atrArray = ATR( ATRPeriods );
HHArray = Null;
LLArray = Null;
exitArray = Null;
trendDirection = 0;
for ( i = 0; i < BarCount; i++ )
{
if ( Short[i] )
{
stopArray[i] = Low[i] + ( Multiple * atrArray[i] );
LLArray[i] = Low[i];
trendDirection = 0 - 1;
}
if ( Buy[i] )
{
stopArray[i] = High[i] - ( Multiple * atrArray[i] );
HHArray[i] = High[i];
trendDirection = 1;
}
exitArray[i] = 0;
if ( trendDirection > 0 )
{
if ( trendDirection > 1 )
{
if ( Low[i] < stopArray[i-1] )
{
trendDirection = 0;
exitArray[i] = 1;
}
else
{
if ( High[i] > HHArray[i-1] )
HHArray[i] = High[i];
else
HHArray[i] = HHArray[i-1];
stopArray[i] = HHArray[i] - ( Multiple * atrArray[i] );
}
}
trendDirection = trendDirection + 1;
}
if ( trendDirection < 0 )
{
if ( trendDirection < 0 - 1 )
{
if ( High[i] > stopArray[i-1] )
{
trendDirection = 0;
exitArray[i] = 0 - 1;
}
else
{
if ( Low[i] < LLArray[i-1] )
LLArray[i] = Low[i];
else
LLArray[i] = LLArray[i-1];
stopArray[i] = LLArray[i] + ( Multiple * atrArray[i] );
}
}
trendDirection = trendDirection - 1;
}
if ( trendDirection == 0 )
{
stopArray[i] = 0;
LLArray[i] = 0;
HHArray[i] = 0;
}
}
Sell = Cover = exitarray;
Buy = ExRem( Buy, Sell );
Sell = ExRem( Sell, Buy );
Short = ExRem( Short, Cover );
Cover = ExRem( Cover, Short );
PlotShapes( Buy*shapeUpArrow, colorBrightGreen, 0, Low );
PlotShapes( Short*shapeDownArrow, colorRed, 0, High );
PlotShapes( abs( exitArray )*shapeHollowCircle, colorYellow, 0, ValueWhen( stopArray, stopArray, 1 ), 0 );
Plot( stopArray, "Chand", ParamColor( "Chand Color:", colorYellow ), ParamStyle( "Chand Style", styleDashed ) );
_N( Title = EncodeColor( colorYellow ) + StrFormat( "{{NAME}} - {{INTERVAL}} - {{DATE}}--Turtle_System_Rev_A \n OP= %g Hi= %g Lo= %g CL= %g (%.1f%%) \n Vol= " + WriteVal( V, 1.0 ) + "\n" + " {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ) );//=cnb
_SECTION_END();
pds = 20;
MAFAST = EMA( Close, 20 );
MASLOW = EMA( Close, 40 );
DonchianUpper = HHV( Ref( H, -1 ), pds );
DonchianLower = LLV( Ref( L, -1 ), pds );
DonchianMiddle = ( DonchianUpper + DonchianLower ) / 2;
UpTrend = C > ( LLV( L, 20 ) + 2 * ATR( 10 ) ) AND EMA( Close, 20 ) > EMA( Close, 40 );
DnTrend = C < ( HHV( H, 20 ) - 2 * ATR( 10 ) ) AND EMA( Close, 20 ) < EMA( Close, 40 );
Color = IIf( UpTrend, colorBlue, IIf( DnTrend, colorOrange, colorCustom11 ) );
Plot( C, "Price", Color, styleBar | styleThick );
Plot( DonchianUpper, "Donchian U", ParamColor( "DU Color", colorBlue ), ParamStyle( "DU Style", styleLine ) );
Plot( DonchianMiddle, "Donchian M", ParamColor( "DM Color", colorBrightGreen ), ParamStyle( "DM Style", styleNoLine ) );
Plot( DonchianLower, "Donchian L", ParamColor( "DL Color", colorRed ), ParamStyle( "DL Style", styleLine ) );
Title = WriteVal( DonchianUpper, 1.2 ) + WriteVal( DonchianLower, 1.2 ) + WriteVal( DonchianMiddle, 1.2 );
Buy = High > Ref( HHV( High, 20 ), -1 ) AND MAFAST > MASLOW;
Short = Low < Ref( LLV( Low, 20 ), -1 ) AND MAFAST < MASLOW;
_SECTION_BEGIN( "Chandelier Exit" );
SetBarsRequired( 50, 50 );
Multiple = Param( "Multiple", 3, 0.5, 10, 0.1 );
ATRPeriods = Param( "ATR Periods", 20, 1, 50, 1 );
stopArray = Null;
atrArray = ATR( ATRPeriods );
HHArray = Null;
LLArray = Null;
exitArray = Null;
trendDirection = 0;
for ( i = 0; i < BarCount; i++ )
{
if ( Short[i] )
{
stopArray[i] = Low[i] + ( Multiple * atrArray[i] );
LLArray[i] = Low[i];
trendDirection = 0 - 1;
}
if ( Buy[i] )
{
stopArray[i] = High[i] - ( Multiple * atrArray[i] );
HHArray[i] = High[i];
trendDirection = 1;
}
exitArray[i] = 0;
if ( trendDirection > 0 )
{
if ( trendDirection > 1 )
{
if ( Low[i] < stopArray[i-1] )
{
trendDirection = 0;
exitArray[i] = 1;
}
else
{
if ( High[i] > HHArray[i-1] )
HHArray[i] = High[i];
else
HHArray[i] = HHArray[i-1];
stopArray[i] = HHArray[i] - ( Multiple * atrArray[i] );
}
}
trendDirection = trendDirection + 1;
}
if ( trendDirection < 0 )
{
if ( trendDirection < 0 - 1 )
{
if ( High[i] > stopArray[i-1] )
{
trendDirection = 0;
exitArray[i] = 0 - 1;
}
else
{
if ( Low[i] < LLArray[i-1] )
LLArray[i] = Low[i];
else
LLArray[i] = LLArray[i-1];
stopArray[i] = LLArray[i] + ( Multiple * atrArray[i] );
}
}
trendDirection = trendDirection - 1;
}
if ( trendDirection == 0 )
{
stopArray[i] = 0;
LLArray[i] = 0;
HHArray[i] = 0;
}
}
Sell = Cover = exitarray;
Buy = ExRem( Buy, Sell );
Sell = ExRem( Sell, Buy );
Short = ExRem( Short, Cover );
Cover = ExRem( Cover, Short );
PlotShapes( Buy*shapeUpArrow, colorBrightGreen, 0, Low );
PlotShapes( Short*shapeDownArrow, colorRed, 0, High );
PlotShapes( abs( exitArray )*shapeHollowCircle, colorYellow, 0, ValueWhen( stopArray, stopArray, 1 ), 0 );
Plot( stopArray, "Chand", ParamColor( "Chand Color:", colorYellow ), ParamStyle( "Chand Style", styleDashed ) );
_N( Title = EncodeColor( colorYellow ) + StrFormat( "{{NAME}} - {{INTERVAL}} - {{DATE}}--Turtle_System_Rev_A \n OP= %g Hi= %g Lo= %g CL= %g (%.1f%%) \n Vol= " + WriteVal( V, 1.0 ) + "\n" + " {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ) );//=cnb
_SECTION_END();
Wednesday, July 22, 2015
The Great AFL
It creates Top and bottom with Candle colors. If Top occurs then it forms black colored candle . Similarly bottom start with White colored candles.
One of the best AFL.
_SECTION_BEGIN("Price");
upbar = C > Ref( H, -1 );
downbar = C < Ref( L, -1 );
/* Colourized price bars drawn here */
Graph0 = Close;
Graph0Style = 128;
barcolor = IIf( downbar, 4, IIf( upbar, 5, 1 ) );
Graph0BarColor = ValueWhen( barcolor != 0, barcolor );
// Only allowed in recent Beta
//SetBarFillColor = ValueWhen( barcolor != 0, barcolor );
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();
One of the best AFL.
_SECTION_BEGIN("Price");
upbar = C > Ref( H, -1 );
downbar = C < Ref( L, -1 );
/* Colourized price bars drawn here */
Graph0 = Close;
Graph0Style = 128;
barcolor = IIf( downbar, 4, IIf( upbar, 5, 1 ) );
Graph0BarColor = ValueWhen( barcolor != 0, barcolor );
// Only allowed in recent Beta
//SetBarFillColor = ValueWhen( barcolor != 0, barcolor );
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();
Sunday, July 19, 2015
Bollinger Band Breakout on Squeeze
Price = EMA(Close, Length);
// Keltner
kLength = Length;
kN = 1.5;
kATR = ATR(kLength);
kUpper = Price + kN * kATR;
kLower = Price - kN * kATR;
GfxSetOverlayMode(1);
GfxSetTextAlign( 1 );// center alignment
GfxSetTextColor( colorRed ) ;
GfxSetBkMode(0); // transparent
GfxSelectFont("From Cartoon Blocks", Status("pxheight")/12 );
GfxTextOut( "stockmarketq.blogspot.in", Status("pxwidth")/2, Status("pxheight")/3 );
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() );
// Bollinger
bbLength = Length;
bbN = 2;
bbStDevValues = StDev(Close, bbLength);
bbUpper = Price + bbN * bbStDevValues;
bbLower = Price - bbN * bbStDevValues;
IsBBSqueeze = bbUpper <= kUpper AND bbLower >= kLower;
Proportion = (kUpper - kLower) / (bbUpper - bbLower);
BBBreakout = Cross(1,Proportion);
Periods = Param("BBPeriods", 14, 2, 300, 1 );
Width = Param("Width", 2, 0, 10, 0.05 );
Color = ParamColor("Color", colorCycle );
Style = ParamStyle("Style");
bbtop=BBandTop( C, Periods, Width );
bbbot=BBandBot( C, Periods, Width );
Plot(bbtop, "", Color, Style );
Plot(bbbot , "", Color, Style );
sqeezcolor=ColorRGB(194,220,218);
PlotOHLC( bbtop,bbtop, bbbot,bbbot, "",IIf(IsBBSqueeze,colorYellow,colorLightGrey), styleCloud|styleNoRescale, Null, Null, Null, -1 );
Plot(Close,"Close",IIf(C>=O,colorBrightGreen,colorRed),styleCandle);
Filter = BBBreakout AND V>50000 AND C>30;
AddColumn(BBBreakout, "BB Breakout", 1, colorWhite, IIf(BBBreakout==1, colorBlue, colorWhite));
//set default sorting to Date/time in descending order in results window
SetSortColumns(-2);
Wednesday, July 15, 2015
Pin Bar AFL
_SECTION_BEGIN("Pin Bar AFL");
SetBarsRequired(100000,0);
GraphXSpace = 15;
SetChartOptions(0,chartShowArrows|chartShowDates);
SetChartBkColor(ParamColor("bkcolor",colorBlack));
GfxSetBkMode(0);
GfxSetOverlayMode(1);
SetBarFillColor(IIf(C>O,ParamColor("Candle UP Color", colorGreen),IIf(C<=O,ParamColor("Candle Down Color", colorRed),colorLightGrey)));
Plot(C,"\nPrice",IIf(C>O,ParamColor("Wick UP Color", colorDarkGreen),IIf(C<=O,ParamColor("Wick Down Color", colorDarkRed),colorLightGrey)),64,0,0,0,0);
dec = (Param("Decimals",2,0,7,1)/10)+1;
Title = EncodeColor(80)+ Title = Name() + " " + EncodeColor(32) + Date() +
" " + EncodeColor(5) + "{{INTERVAL}} " +
EncodeColor(99)+ " Open = "+ EncodeColor(99)+ WriteVal(O,dec) +
EncodeColor(99)+ " High = "+ EncodeColor(5) + WriteVal(H,dec) +
EncodeColor(99)+ " Low = "+ EncodeColor(32)+ WriteVal(L,dec) +
EncodeColor(99)+ " Close = "+ EncodeColor(99)+ WriteVal(C,dec)+
EncodeColor(99)+ " Volume = "+ EncodeColor(99)+ WriteVal(V,1);
MaxNoseBodySize = 0.33; // Max. Body / Candle length ratio of the Nose Bar
NoseBodyPosition = 0.4; // Body position in Nose Bar (e.g. top/bottom 40%)
LeftEyeOppositeDirection = True; // true = Direction of Left Eye Bar should be opposite to pattern (bearish bar for bullish Pinbar pattern and vice versa)
NoseSameDirection = False; // true = Direction of Nose Bar should be the same as of pattern (bullish bar for bullish Pinbar pattern and vice versa)
NoseBodyInsideLeftEyeBody = False; // true = Nose Body should be contained inside Left Eye Body
LeftEyeMinBodySize = 0.1; // Min. Body / Candle length ratio of the Left Eye Bar
NoseProtruding = 0.5; // Minmum protrusion of Nose Bar compared to Nose Bar length
NoseBodyToLeftEyeBody = 1; // Maximum relative size of the Nose Bar Body to Left Eye Bar Body
NoseLengthToLeftEyeLength = 0; // Minimum relative size of the Nose Bar Length to Left Eye Bar Length
LeftEyeDepth = 0.2; // Minimum relative depth of the Left Eye to its length; depth is difference with Nose's back
up=down =0;
point = 0.1;
blpin=brpin=False;
for(i=1;i<BarCount;i++)
{
NoseLength = High[i] - Low[i];
if (NoseLength == 0) NoseLength = Point;
LeftEyeLength = High[i - 1] - Low[i - 1];
if (LeftEyeLength == 0) LeftEyeLength = Point;
NoseBody = abs(Open[i] - Close[i]);
if (NoseBody == 0) NoseBody = point;
LeftEyeBody = abs(Open[i - 1] - Close[i - 1]);
if (LeftEyeBody == 0) LeftEyeBody = point;
// Bearish Pinbar
if (High[i] - High[i - 1] >= NoseLength * NoseProtruding) // Nose protrusion
{
if (NoseBody / NoseLength <= MaxNoseBodySize) // Nose body to candle length ratio
{
if (1 - (High[i] - Max(Open[i], Close[i])) / NoseLength < NoseBodyPosition) // Nose body position in bottom part of the bar
{
if ((!LeftEyeOppositeDirection) || (Close[i - 1] > Open[i - 1])) // Left Eye bullish if required
{
if ((!NoseSameDirection) || (Close[i] < Open[i])) // Nose bearish if required
{
if (LeftEyeBody / LeftEyeLength >= LeftEyeMinBodySize) // Left eye body to candle length ratio
{
if ((Max(Open[i], Close[i]) <= High[i - 1]) && (Min(Open[i], Close[i]) >= Low[i - 1])) // Nose body inside Left Eye bar
{
if (NoseBody / LeftEyeBody <= NoseBodyToLeftEyeBody) // Nose body to Left Eye body ratio
{
if (NoseLength / LeftEyeLength >= NoseLengthToLeftEyeLength) // Nose length to Left Eye length ratio
{
if (Low[i] - Low[i - 1] >= LeftEyeLength * LeftEyeDepth) // Left Eye low is low enough
{
if ((!NoseBodyInsideLeftEyeBody) || ((Max(Open[i], Close[i]) <= Max(Open[i - 1], Close[i - 1])) && (Min(Open[i], Close[i]) >= Min(Open[i - 1], Close[i - 1])))) // Nose body inside Left Eye body if required
{
Down[i] = High[i] + 5 * Point + NoseLength / 5;
brpin[i]=True;
}
}
}
}
}
}
}
}
}
}
}
// Bullish Pinbar
if (Low[i - 1] - Low[i] >= NoseLength * NoseProtruding) // Nose protrusion
{
if (NoseBody / NoseLength <= MaxNoseBodySize) // Nose body to candle length ratio
{
if (1 - (Min(Open[i], Close[i]) - Low[i]) / NoseLength < NoseBodyPosition) // Nose body position in top part of the bar
{
if ((!LeftEyeOppositeDirection) || (Close[i - 1] < Open[i - 1])) // Left Eye bearish if required
{
if ((!NoseSameDirection) || (Close[i] > Open[i])) // Nose bullish if required
{
if (LeftEyeBody / LeftEyeLength >= LeftEyeMinBodySize) // Left eye body to candle length ratio
{
if ((Max(Open[i], Close[i]) <= High[i - 1]) && (Min(Open[i], Close[i]) >= Low[i - 1])) // Nose body inside Left Eye bar
{
if (NoseBody / LeftEyeBody <= NoseBodyToLeftEyeBody) // Nose body to Left Eye body ratio
{
if (NoseLength / LeftEyeLength >= NoseLengthToLeftEyeLength) // Nose length to Left Eye length ratio
{
if (High[i - 1] - High[i] >= LeftEyeLength * LeftEyeDepth) // Left Eye high is high enough
{
if ((!NoseBodyInsideLeftEyeBody) || ((Max(Open[i], Close[i]) <= Max(Open[i - 1], Close[i - 1])) && (Min(Open[i], Close[i]) >= Min(Open[i - 1], Close[i - 1])))) // Nose body inside Left Eye body if required
{
Up[i] = Low[i] - 5 * Point - NoseLength / 5;
blpin[i]=True;
}
}
}
}
}
}
}
}
}
}
}
}
for( i = 1; i < BarCount; i++ )
{
if(blpin[i] ) PlotText( "bull.pin " , i, L[ i ]-2.5, colorLime );
if(brpin[i] ) PlotText( " bear pin" , i, H[ i ]+2.5, colorOrange );
}
PlotShapes(shapeHollowSmallSquare*brpin,4,0,H ,5);
PlotShapes(shapeHollowSmallSquare*blpin,5,0,L ,-5);
Filter= Blpin OR brpin;
AddColumn(blpin,"bull pin",1.2);
Addcolumn(brpin,"bear pin",1.2);
AddColumn(Close,"Close",1.2);
_SECTION_END();
Tuesday, July 7, 2015
ROCKET JET
This consists of many indicators and given the level of meter with signals.
_SECTION_BEGIN("Chart Settings");
SetChartOptions(0,chartShowArrows|chartShowDates);
SetChartBkColor(ParamColor("Outer Panel",colorBlack));
SetChartBkGradientFill(ParamColor("Upper Chart",colorDarkTeal),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( "BASERECTANGEL" );
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorBlue );
GfxSelectSolidBrush( colorDarkBlue );
GfxSelectPen( colorBlue, 1 );
// broader color
GfxRectangle(0,15,203,600);
_SECTION_END();
_SECTION_BEGIN("res/sup-s1");
DayH = TimeFrameGetPrice("H", inDaily, -1);// yesterdays high
DayL = TimeFrameGetPrice("L", inDaily, -1);//low
DayC = TimeFrameGetPrice("C", inDaily, -1);//close
DayO = TimeFrameGetPrice("O", inDaily);// current day open
HiDay = TimeFrameGetPrice("H", inDaily);
LoDay = TimeFrameGetPrice("L", inDaily);
PP = (DayH + DayL + DayO + DayO) / 4 ;
R1 = (2 * PP) - DayL;
S1 = (2 * PP) - DayH;
R2 = PP + R1 - S1;
S2 = PP + S1 - R1;
R3 = R2 + (R1 - PP);
S3 = S2 - (PP - S1);
style = styleLine | styleThick + styleNoRescale;
rcolor = colorBlue;
scolor = colorRed;
pcolor = colorGreen;
GfxSelectFont("arial", 10, 700 ); GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorRed) );
Hor=Param("Horizontal Position",20,10,1200,1);
Ver=Param("Vertical Position",420,300,500,500);
GfxTextOut(""+s1,Hor , Ver );
_SECTION_END();
_SECTION_BEGIN("res/sup-s2");
GfxSelectFont("arial", 10, 700 ); GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorRed) );
Hor=Param("Horizontal Position",20,10,1200,1);
Ver=Param("Vertical Position",480,300,500,500);
GfxTextOut(""+s2,Hor , Ver );
_SECTION_END();
_SECTION_BEGIN("res/sup-s3");
GfxSelectFont("arial", 10, 700 ); GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorRed) );
Hor=Param("Horizontal Position",20,10,1200,1);
Ver=Param("Vertical Position",540,300,600,600);
GfxTextOut(""+s3,Hor , Ver );
_SECTION_END();
_SECTION_BEGIN("res/sup-r1");
GfxSelectFont("arial", 10, 700 ); GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorGreen) );
Hor=Param("Horizontal Position",150,10,1200,1);
Ver=Param("Vertical Position",420,300,500,500);
GfxTextOut(""+r1,Hor , Ver );
_SECTION_END();
_SECTION_BEGIN("res/sup-r2");
GfxSelectFont("arial", 10, 700 ); GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorGreen) );
Hor=Param("Horizontal Position",150,10,1200,1);
Ver=Param("Vertical Position",480,300,500,500);
GfxTextOut(""+r2,Hor , Ver );
_SECTION_END();
_SECTION_BEGIN("res/sup-r3");
GfxSelectFont("arial", 10, 700 ); GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorGreen) );
Hor=Param("Horizontal Position",150,10,1200,1);
Ver=Param("Vertical Position",540,300,500,500);
GfxTextOut(""+r3,Hor , Ver );
_SECTION_END();
_SECTION_BEGIN("MACD");
r1 = Param( "Fast avg", 12, 2, 200, 1 );
r2 = Param( "Slow avg", 26, 2, 200, 1 );
r3 = Param( "Signal avg", 9, 2, 200, 1 );
r4 = Param( "Wk slow", 17, 2, 200, 1 );
r5 = Param( "Wk fast", 8, 2, 200, 1 );
m1=MACD(r1,r2);
s1=Signal(r1,r2,r3);
_SECTION_END();
_SECTION_BEGIN("WRITE");
GfxSelectFont("arial", 8, 700 ); GfxSetBkMode( colorLightBlue );
GfxSetTextColor( ParamColor("Color",colorLightBlue) );
Hor=Param("Horizontal Position",0,10,1200,1);
Ver=Param("Vertical Position",580,100,50,50);
GfxTextOut(" R O C K E T J E T",Hor , Ver );
_SECTION_END();
_SECTION_BEGIN("Forex_Main_mrtq13");
///////////////////////////////////
Title =
EncodeColor(colorWhite)+ Title = Name () + " | "
+EncodeColor(colorYellow) + Date() + " | "
+EncodeColor(colorTurquoise)+ "O : "+ EncodeColor(colorLightGrey)+ O + " | "
+EncodeColor(colorTurquoise)+ "H : "+ EncodeColor(colorLightGrey)+ H + " | "
+EncodeColor(colorTurquoise)+ "L : "+ EncodeColor(colorLightGrey)+ L + " | "
+EncodeColor(colorTurquoise)+ "C : "+ WriteIf(C> Ref(C, -1),EncodeColor(colorBrightGreen),EncodeColor(colorRed))+ C + " | "
+EncodeColor(colorTurquoise)+ "Change : ("+ WriteIf(C> Ref(C, -1),EncodeColor(colorBrightGreen),EncodeColor(colorRed)) + WriteVal(C-Ref(C,-1))+" Rs."
+EncodeColor(colorTurquoise)+ " /"+ WriteIf(C> Ref(C, -1),EncodeColor(colorBrightGreen),EncodeColor(colorRed))+ WriteVal( ROC( C, 1 ))+""+ " % "
+EncodeColor(colorTurquoise)+ ") | Volume : " + WriteIf(V> Ref(V, -1),EncodeColor(colorBrightGreen),EncodeColor(colorRed))+ WriteVal(V,1)
;
_SECTION_END();
_SECTION_BEGIN("Flower");
Show_color = ParamToggle("Display CandleColor", "No|Yes", 1);
r1 = Param( "ColorFast avg", 5, 2, 200, 1 );
r2 = Param( "ColorSlow avg", 10, 2, 200, 1 );
r3 = Param( "ColorSignal avg", 5, 2, 200, 1 );
Prd1=Param("ATR Period",4,1,20,1);
Prd2=Param("Look Back",7,1,20,1);
green = HHV(LLV(L,Prd1)+ATR(Prd1),Prd2);
red = LLV(HHV(H,Prd1)-ATR(Prd1),Prd2);
flowerClose = EMA((Open+High+Low+Close)/4,3) ;
flowerOpen = EMA((Ref(Open,-1) + Ref(flowerClose,-1))/2,3);
Temp = Max(High, flowerOpen);
flowerHigh = EMA(Max(Temp, flowerClose),3);
Temp = Min(Low,flowerOpen);
flowerLow = EMA(Min(Temp, flowerClose),3);
m1=MACD(r1,r2);
s1=Signal(r1,r2,r3);
mycolor=IIf(m1<0 AND m1>s1, colorYellow,IIf(m1>0 AND
m1>s1,colorWhite,IIf(m1>0 AND m1<s1,colorDarkYellow,colorRed)));
if(Show_color)
{
ColorHighliter = myColor;
SetBarFillColor( ColorHighliter );
}
barColor=IIf(C>Green ,colorWhite,IIf(C < RED,colorRed,colorWhite));
PlotOHLC( IIf(flowerOpen<flowerClose, flowerOpen,
flowerClose),flowerHigh,flowerLow,IIf(flowerOpen<flowerClose, flowerClose,
flowerOpen), "Close", barColor, styleNoTitle | styleCandle);
_SECTION_END();
_SECTION_BEGIN("Bands");
SupResB =Param("Sup-Res Short",6,0,100,1);
nn=SupResB;
Bandlinecol=ParamColor("SupResLineColor",ColorRGB(82,82,82));
ParmCloud = ParamToggle("Cloud", "No|Yes", 0);
BoxCloudColor=ParamColor("BoxCloudColor",ColorRGB(27,27,27));
Line2=Param("ResLineLength",100,2,500,0.1);
Daysback1 = Line2;
FirstBar1 = BarCount - DaysBack1;
Hh=HHV(flowerHigh,nn);
LL=LLV(flowerLow,nn);
Res2=Hh;
Sup2=LL;
BandRes=IIf(BarIndex() >= Firstbar1,EndValue(Res2),Null);
BandSup=IIf(BarIndex() >= Firstbar1,EndValue(Sup2),Null);
Plot(BandRes,"",Bandlinecol,ParamStyle("ShortSupBand",styleLine|styleDashed|stylehidden|styleNoTitle|styleNoLabel|styleThick,maskAll));
Plot(BandSup,"",Bandlinecol,ParamStyle("ShortResBand",styleLine|styleDashed|stylehidden|styleNoTitle|styleNoLabel|styleThick,maskAll));
CS=BandRes;
CR=BandSup;
if(parmCloud == 1)
PlotOHLC( CS, CS, CR,CR, "Band",BoxCloudColor, styleCloud | styleNoLabel|styleNoTitle);
_SECTION_END();
_SECTION_BEGIN("Breakout Setting");
Buyperiods=Param("Breakout periods best is usually 18",5,1,100,1,1);
Sellperiods=Param("Exit Breakout",5,1,100,1,1);
HaClose =EMA((O+H+L+C)/4,3); // Woodie
//HaClose =(O+H+L+C)/4;
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
HaHigh = Max( H, Max( HaClose, HaOpen ) );
HaLow = Min( L, Min( HaClose, HaOpen ) );
Buy= C>Ref(HHV(High,Buyperiods),-1) ;
Sell= C<Ref(LLV(Low,Sellperiods),-1);
/* exrem is one method to remove surplus strade signals. It removes excessive signals of arrow */
Buy = ExRem(Buy, Sell);
Sell = ExRem(Sell, Buy);
PlotShapes( IIf( Buy, shapeSmallUpTriangle, shapeNone ), colorWhite, layer = 0,yposition = HaLow, offset = -30);
//PlotShapes( IIf( Buy, shapeSmallCircle, shapeNone ), colorWhite, layer = 0,yposition = HaLow, offset = -8);
PlotShapes( IIf( Sell, shapeSmallDownTriangle, shapeNone ), colorRed, layer = 0, yposition = HaHigh, offset = -30);
//PlotShapes( IIf( Sell, shapeSmallCircle, shapeNone ), colorRed, layer = 0, yposition = HaHigh, offset = -8);
_SECTION_END();
_SECTION_BEGIN("Graphics");
GrpPrm=Param("Graphic Space",-5,-10,10);
GraphXSpace=GrpPrm;
_SECTION_END();
//#include <T3.AFL>;
_SECTION_BEGIN("PFE");
pds=10;
x=sqrt((ROC(C,9)*ROC(C,9))+100);
y=Sum(sqrt((ROC(C,1)* ROC(C,1))+1),pds);
z=(x/y);
pfe=EMA(IIf(C>Ref(C,-9),z,-z)*100,5);
rsidn=pfe <-10 AND pfe<Ref(pfe,-1);
rsiup=pfe >10 AND pfe>Ref(pfe,-1);
rsiresult1 = WriteIf( rsiup,"cu", "");
rsiresult2 = WriteIf( rsidn,"cd", "");
RequestTimedRefresh( 0 );
GfxSelectFont( "Tahoma", 12, 120 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );
if ( rsiresult1 =="cu")
{
GfxSelectSolidBrush( ColorRGB(0,90,0) );
}
else
if ( rsiresult2 =="cd")
{
GfxSelectSolidBrush( ColorRGB(90,0,0));
}
else
if ( rsiresult2 =="")
{
GfxSelectSolidBrush( colorDarkTeal );
}
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorBlue );
GfxCircle( 100,90,50 );
_SECTION_END();
//GfxRoundRect( 15,305,135,215, 5, 5 );
GfxCircle( 100,100,70 );
_SECTION_END();
_SECTION_BEGIN("STC");
_SECTION_BEGIN("Schaff Trend Cycle");
/*
Ported directly from original STC Tradestation code
results differ from other Amibroker versions that are not based directly on original EasyLanguage code
http://mediaserver.fxstreet.com/Reports/99afdb5f-d41d-4a2c-802c-f5d787df886c/ebfbf387-4b27-4a0f-848c-039f4ab77c00.pdf
*/
MA1=23;
MA2=50;
TCLen=10;
MA1=Param("ShortMACDLen",23,5,36);
MA2=Param("LOngMACDLen",50,10,100);
TCLen=Param("TCLen(StochPeriod)",10,5,20);
Factor=.5;
//Calculate a MACD Line
XMac = MACD(MA1,MA2) ; // MACD in Amibroker always uses Close for MACD calculation
//1st Stochastic: Calculate Stochastic of a MACD
Value1 = LLV(XMac, TCLen);
Value2 = HHV(XMac, TCLen) - Value1;
//Frac1=1; // prime Frac1 to a default of 1
//Frac1 = IIf(Value2 > 0, ((XMac - Value1) / Value2) * 100, Ref(FRAC1,-1));
// have to "prime" first value so that reference to "i-1" does not result in subscript out of range
// since MACD for both periods is not defined until MA2 period, 0 seems to be mathematically correct priming value
frac1=0;
for (i = 1; i < BarCount; i++) {
if (Value2[i] > 0) {
frac1[i] = ((XMac[i] - Value1[i])/Value2[i])*100;
}
else {
frac1[i]= frac1[i-1];
}
}
//Smoothed calculation for %FastD of MACD
PF[0]=frac1[0];
PF[1]=frac1[1];
for (i = 2; i < BarCount; i++) {
PF[i]=PF[i-1]+(Factor*(frac1[i]-PF[i-1]));
}
//2nd Stochastic: Calculate Stochastic of Smoothed Percent FastD, above.
Value3 = LLV(PF, TCLen);
Value4 = HHV(PF, TCLen) - Value3;
//%FastK of PF
/*
Frac2=1;
Frac2 = IIf(Value4 > 0, ((PF - Value3) / Value4) * 100, Ref(FRAC2,-1));
*/
frac2[0]=0;
for (i = 1; i < BarCount; i++) {
if (Value4[i] > 0 ) {
frac2[i]=((PF[i] - Value3[i])/Value4[i])*100;
}
else {
frac2[i]=frac2[i-1];
}
}
//Smoothed calculation for %FastD of PF
PFF[0]=frac2[0];
PFF[1]=frac2[1];
for (i = 2; i < BarCount; i++) {
PFF[i]=PFF[i-1]+(Factor*(frac2[i]-PFF[i-1]));
}
//HT=ParamColor("HT", colorRed );
rsidn=pff <2;
rsiup=pff >98;
rsiresult1 = WriteIf( rsiup,"cu", "");
rsiresult2 = WriteIf( rsidn,"cd", "");
RequestTimedRefresh( 0 );
GfxSelectFont( "Tahoma", 12, 120 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );
if ( rsiresult1 =="cu")
{
GfxSelectSolidBrush( ColorRGB(0,120,0) );
}
else
if ( rsiresult2 =="cd")
{
GfxSelectSolidBrush( ColorRGB(120,0,0));
}
else
if ( rsiresult2 =="")
{
GfxSelectSolidBrush( colorDarkTeal );
}
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorBlue );
GfxCircle( 100,100,60 );
_SECTION_END();
_SECTION_BEGIN("rsi");
//HT=ParamColor("HT", colorRed );
rsidn=RSI(7) <30;
rsiup=RSI(7) >70;
rsiresult1 = WriteIf( rsiup,"cu", "");
rsiresult2 = WriteIf( rsidn,"cd", "");
RequestTimedRefresh( 0 );
GfxSelectFont( "Tahoma", 12, 120 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );
if ( rsiresult1 =="cu")
{
GfxSelectSolidBrush( ColorRGB(0,150,0) );
}
else
if ( rsiresult2 =="cd")
{
GfxSelectSolidBrush( ColorRGB(150,0,0));
}
else
if ( rsiresult2 =="")
{
GfxSelectSolidBrush( colorDarkTeal );
}
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorBlue );
GfxCircle( 100,100,50 );
_SECTION_END();
_SECTION_BEGIN("Rays");
//FT=ParamColor("FT", colorRed );
Pp1=3;
Pp2=2;
CS33=HHV(LLV(flowerHigh,Pp1)-ATR(Pp2),4);
CR33=HHV(LLV(flowerHigh,Pp1)-ATR(Pp2),5);
AtrupTrendCond1 = flowerClose> CS33 ;
AtrdnTrendCond1 =CS33>flowerClose ;
ATRup = WriteIf(AtrupTrendCond1,"atrup", "");
ATRdown= WriteIf( AtrdnTrendCond1,"atrdn", "");
if ( ATRup =="atrup")
{
GfxSelectSolidBrush( ColorRGB(0,180,0) );
}
else
if (ATRdown =="atrdn")
{
GfxSelectSolidBrush( ColorRGB(180,0,0));
}
else
if ( ATRdown =="")
{
GfxSelectSolidBrush( colorDarkTeal );
}
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorBlue );
GfxSelectPen( colorBlue, 1 ); // broader color
GfxCircle( 100,100,40 );
_SECTION_END();
_SECTION_BEGIN("Exit_Beast-3");
//GT=ParamColor("GT", colorRed );
EntrylookbackPeriod=10;
EntryATRperiod=1.9;
EntrySig = C > ( LLV( flowerLow, EntrylookbackPeriod ) + EntryATRperiod * ATR( 10 ) );
ExitSig = C < ( HHV( flowerHigh, EntrylookbackPeriod ) -EntryATRperiod * ATR( 10 ) );
RequestTimedRefresh( 0 );
GfxSelectFont( "Tahoma", 12, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );
EntryB = WriteIf( EntrySig,"eu", "");
ExitB = WriteIf( ExitSig,"ed", "");
if ( EntryB =="eu")
{
GfxSelectSolidBrush( ColorRGB(0,210,0) ); //
}
else
if ( ExitB =="ed")
{
GfxSelectSolidBrush( ColorRGB(210,0,0)); //
}
else
if ( ExitB =="")
{
GfxSelectSolidBrush( colorDarkTeal );
}
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorBlue );
GfxSelectPen( colorBlue, 1 ); // broader color
GfxCircle( 100,100,30 );// changing the value of x,y,rad x-70, y-90, rad-24
_SECTION_END();
_SECTION_BEGIN("CCI9-2");
//HT=ParamColor("HT", colorRed );
ccidn=CCI(8) < 0;
cciup=CCI(9) > 0;
ccresult1 = WriteIf( cciup,"cu", "");
ccresult2 = WriteIf( ccidn,"cd", "");
RequestTimedRefresh( 0 );
GfxSelectFont( "Tahoma", 12, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );
if ( ccresult1 =="cu")
{
GfxSelectSolidBrush( ColorRGB(0,240,0) );
}
else
if ( ccresult2 =="cd")
{
GfxSelectSolidBrush( ColorRGB(240,0,0));
}
else
if ( ccresult2 =="")
{
GfxSelectSolidBrush( colorDarkTeal );
}
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorBlue );
GfxSelectPen( colorBlue, 1 ); // broader color
GfxCircle( 100,100,20);
_SECTION_END();
_SECTION_BEGIN("%BB7-1");
//IT=ParamColor("IT", colorRed );
p=7;
x=((C+2*StDev(C,p)-MA(C,p))/(4*StDev(C,p)))*100;
bbdown= x < 40;
bbup= x > 40;
bbresult1 = WriteIf( bbup,"bu", "");
bbresult2 = WriteIf( bbdown,"bd", "");
bbresult3 = WriteIf( C,"bearishrevers", "");
RequestTimedRefresh( 0 );
GfxSelectFont( "Tahoma", 12, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );
if ( bbresult1 =="bu")
{
GfxSelectSolidBrush( ColorRGB(62,255,62) );
}
else
if ( bbresult2 =="bd")
{
GfxSelectSolidBrush( ColorRGB(255,62,62) );
}
else
if ( bbresult2 =="")
{
GfxSelectSolidBrush( colorDarkTeal );
}
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorBlue );
GfxSelectPen( colorBlue, 1 ); // broader color
GfxCircle( 100,100,10 );
_SECTION_END();
_SECTION_BEGIN("MACDHIGHBULLISH");
r1 = Param( "Fast avg", 12, 2, 200, 1 );
r2 = Param( "Slow avg", 26, 2, 200, 1 );
r3 = Param( "Signal avg", 9, 2, 200, 1 );
r4 = Param( "Wk slow", 17, 2, 200, 1 );
r5 = Param( "Wk fast", 8, 2, 200, 1 );
m1=MACD(r1,r2);
s1=Signal(r1,r2,r3);
rsidn=m1>0 AND m1>s1;
rsiresult2 = WriteIf( rsidn,"cd", "");
if ( rsiresult2 =="cd")
{
GfxSelectSolidBrush( ColorRGB(0,147,0));
}
else
if ( rsiresult2 =="")
{
GfxSelectSolidBrush( colorDarkTeal );
}
RequestTimedRefresh( 0 );
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorBlue );
GfxSelectPen( colorBlue, 1 );
// broader color
GfxRectangle(80,220,120,280);
_SECTION_END();
_SECTION_BEGIN("MACDLOWHBULLISH");
r1 = Param( "Fast avg", 12, 2, 200, 1 );
r2 = Param( "Slow avg", 26, 2, 200, 1 );
r3 = Param( "Signal avg", 9, 2, 200, 1 );
r4 = Param( "Wk slow", 17, 2, 200, 1 );
r5 = Param( "Wk fast", 8, 2, 200, 1 );
m1=MACD(r1,r2);
s1=Signal(r1,r2,r3);
rsidn=m1<0 AND m1>s1;
rsiresult2 = WriteIf( rsidn,"cd", "");
if ( rsiresult2 =="cd")
{
GfxSelectSolidBrush( ColorRGB(0,147,0));
}
else
if ( rsiresult2 =="")
{
GfxSelectSolidBrush( colorDarkTeal );
}
RequestTimedRefresh( 0 );
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorBlue );
GfxSelectPen( colorBlue, 1 );
// broader color
GfxRectangle(120,315,180,280);
_SECTION_END();
_SECTION_BEGIN("MACDLOWHBEARISH");
r1 = Param( "Fast avg", 12, 2, 200, 1 );
r2 = Param( "Slow avg", 26, 2, 200, 1 );
r3 = Param( "Signal avg", 9, 2, 200, 1 );
r4 = Param( "Wk slow", 17, 2, 200, 1 );
r5 = Param( "Wk fast", 8, 2, 200, 1 );
m1=MACD(r1,r2);
s1=Signal(r1,r2,r3);
rsidn=m1>0 AND m1<s1;
rsiresult2 = WriteIf( rsidn,"cd", "");
if ( rsiresult2 =="cd")
{
GfxSelectSolidBrush( ColorRGB(225,0,0));
}
else
if ( rsiresult2 =="")
{
GfxSelectSolidBrush( colorDarkTeal );
}
RequestTimedRefresh( 0 );
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorBlue );
GfxSelectPen( colorBlue, 1 );
// broader color
GfxRectangle(20,315,80,280);
_SECTION_END();
_SECTION_BEGIN("MACDHIGHHBEARISH");
r1 = Param( "Fast avg", 12, 2, 200, 1 );
r2 = Param( "Slow avg", 26, 2, 200, 1 );
r3 = Param( "Signal avg", 9, 2, 200, 1 );
r4 = Param( "Wk slow", 17, 2, 200, 1 );
r5 = Param( "Wk fast", 8, 2, 200, 1 );
m1=MACD(r1,r2);
s1=Signal(r1,r2,r3);
rsidn=m1<0 AND m1<s1;
rsiresult2 = WriteIf( rsidn,"cd", "");
if ( rsiresult2 =="cd")
{
GfxSelectSolidBrush( ColorRGB(225,0,0));
}
else
if ( rsiresult2 =="")
{
GfxSelectSolidBrush( colorDarkTeal );
}
RequestTimedRefresh( 0 );
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorBlue );
GfxSelectPen( colorBlue, 1 );
// broader color
GfxRectangle(80,375,120,315);
_SECTION_END();
_SECTION_BEGIN("bearishline");
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorRed );
GfxSelectPen( colorRed, 1 );
GfxMoveTo( 25,320 );
GfxLineTo( 75, 370 );
_SECTION_END();
_SECTION_BEGIN("bullishline");
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorGreen );
GfxSelectPen( colorGreen, 1 );
GfxMoveTo( 125,225 );
GfxLineTo( 175, 275 );
_SECTION_END();
_SECTION_BEGIN("volume1");
GfxSelectSolidBrush( colorDarkTeal );
GfxRoundRect(90,555,110,405,20,20);
_SECTION_END();
_SECTION_BEGIN("volume2");
GfxSelectSolidBrush( colorDarkTeal );
GfxCircle( 100,550,23 );
_SECTION_END();
_SECTION_BEGIN("spiker");
C1 = Ref(C, -1);
uc = C > C1; dc = C <= C1;
ud = C > O; dd = C <= O;
green = 1; blue = 2; yellow = 3; red = 4; white = 5;
VType = IIf(ud,
IIf(uc, green, yellow),
IIf(dd,
IIf(dc, red, blue), white));
/* green volume: up-day and up-close*/
gv = IIf(VType == green, V, 0);
/* yellow volume: up-day but down-close */
yv = IIf(VType == yellow, V, 0);
/* red volume: down-day and down-close */
rv = IIf(VType == red, V, 0);
/* blue volume: down-day but up-close */
bv = IIf(VType == blue, V, 0);
uv = gv + bv; uv1 = Ref(uv, -1); /* up volume */
dv = rv + yv; dv1 = Ref(dv, -1); /* down volume */
VolPer = Param("Adjust Vol. MA per.", 10, 1, 255, 1);
ConvPer = Param("Adjust Conv. MA per.", 4, 1, 255, 1);
MAuv = TEMA(uv, VolPer ); mauv1 = Ref(mauv, -1);
MAdv = TEMA(dv, VolPer ); madv1 = Ref(madv, -1);
MAtv = TEMA(V, VolPer );//total volume
Converge = (TEMA(MAuv - MAdv, ConvPer));
Converge1 = Ref(Converge, -1);
ConvergeUp = Converge > Converge1;
ConvergeOver = Converge > 0;
rising = ConvergeUp AND ConvergeOver;
falling = !ConvergeUp AND ConvergeOver;
_SECTION_END();
_SECTION_BEGIN("vol30");
rsiup=rising;
rsidn=falling;
down=Converge > 0;
rsiresult1 = WriteIf( rsiup,"ab", "");
rsiresult2 = WriteIf( rsidn,"cd", "");
rsiresult3 = WriteIf( down,"ef", "");
RequestTimedRefresh( 0 );
if ( rsiresult1 =="ab")
{
GfxSelectSolidBrush( ColorRGB(0,147,0) );
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorGreen );
GfxSelectPen( colorGreen, 1 );
}
else
if ( rsiresult2 =="cd")
{
GfxSelectSolidBrush( ColorRGB(0,85,0) );
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorDarkGreen );
GfxSelectPen( colorDarkGreen, 1 );
}
else
{
GfxSelectSolidBrush( ColorRGB(255,0,0) );
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorRed );
GfxSelectPen( colorRed, 1 );
}
GfxRectangle(91,550,109,430);
_SECTION_END();
_SECTION_BEGIN("vol31");
rsiup=rising;
rsidn=falling;
down=Converge > 0;
rsiresult1 = WriteIf( rsiup,"ab", "");
rsiresult2 = WriteIf( rsidn,"cd", "");
rsiresult3 = WriteIf( down,"ef", "");
RequestTimedRefresh( 0 );
if ( rsiresult1 =="ab")
{
GfxSelectSolidBrush( ColorRGB(0,147,0) );
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorGreen );
GfxSelectPen( colorGreen, 1 );
}
else
if ( rsiresult2 =="cd")
{
GfxSelectSolidBrush( ColorRGB(0,85,0) );
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorDarkGreen );
GfxSelectPen( colorDarkGreen, 1 );
}
else
{
GfxSelectSolidBrush( ColorRGB(255,0,0) );
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorRed );
GfxSelectPen( colorRed, 1 );
}
GfxCircle( 100,550,22 );
_SECTION_END();
_SECTION_BEGIN("Average 0");
//Average_switch = ParamToggle("Candle On/off", "Off|On");
P = HaClose;
Type = ParamList("Type", "Weighted,Lagless-21,Hull-26,Linear
Regression-45,Exponential,Double Exponential,Tripple
Exponential,Wilders,Simple");
Periods = Param("Periods", 20, 2, 200 );
Displacement = Param("Displacement", 1, -50, 50 );
m = 0;
if( Type == "Weighted" ) m= WMA( P, Periods );
if( Type == "Lagless-21" ) m= 2*EMA(P, Periods)-EMA(EMA(P, Periods), Periods);
if( Type == "Hull-26" ) m= WMA(2*(WMA(P, Periods/2))-WMA(P, Periods) ,4 );
if( Type == "Linear Regression-45" ) m= LinearReg( P, Periods );
if( Type == "Exponential" ) m = EMA( P, Periods );
if( Type == "Double Exponential" ) m = DEMA( P, Periods );
if( Type == "Tripple Exponential" ) m = TEMA( P, Periods );
if( Type == "Wilders" ) m = Wilders( P, Periods );
if( Type == "Simple" ) m = MA( P, Periods );
Plot( m, _DEFAULT_NAME(), ParamColor("Color", colorLightGrey),ParamStyle("Style",styleLine |styleThick|styleNoTitle ,maskAll),Displacement );
_SECTION_END();
_SECTION_BEGIN("Average 1");
//Average_switch = ParamToggle("Candle On/off", "Off|On");
P = HaClose;
Type = ParamList("Type", "Weighted,Lagless-21,Hull-26,Linear
Regression-45,Exponential,Double Exponential,Tripple
Exponential,Wilders,Simple");
Periods = Param("Periods", 60, 2, 200 );
Displacement = Param("Displacement", 1, -50, 50 );
m = 0;
if( Type == "Weighted" ) m= WMA( P, Periods );
if( Type == "Lagless-21" ) m= 2*EMA(P, Periods)-EMA(EMA(P, Periods), Periods);
if( Type == "Hull-26" ) m= WMA(2*(WMA(P, Periods/2))-WMA(P, Periods) ,4 );
if( Type == "Linear Regression-45" ) m= LinearReg( P, Periods );
if( Type == "Exponential" ) m = EMA( P, Periods );
if( Type == "Double Exponential" ) m = DEMA( P, Periods );
if( Type == "Tripple Exponential" ) m = TEMA( P, Periods );
if( Type == "Wilders" ) m = Wilders( P, Periods );
if( Type == "Simple" ) m = MA( P, Periods );
Plot( m, _DEFAULT_NAME(), ParamColor("Color", colorGrey50),ParamStyle("Style",styleLine |styleNoTitle ,maskAll),Displacement );
_SECTION_END();
_SECTION_BEGIN("Average 5");
P = HaClose;
Type = ParamList("Type", "Weighted,Lagless-21,Hull-26,Linear
Regression-45,Exponential,Double Exponential,Tripple
Exponential,Wilders,Simple");
Periods = Param("Periods", 120 ,2, 200 );
Displacement = Param("Displacement", 1, -50, 50 );
m = 0;
if( Type == "Weighted" ) m= WMA( P, Periods );
if( Type == "Lagless-21" ) m= 2*EMA(P, Periods)-EMA(EMA(P, Periods), Periods);
if( Type == "Hull-26" ) m= WMA(2*(WMA(P, Periods/2))-WMA(P, Periods) ,4 );
if( Type == "Linear Regression-45" ) m= LinearReg( P, Periods );
if( Type == "Exponential" ) m = EMA( P, Periods );
if( Type == "Double Exponential" ) m = DEMA( P, Periods );
if( Type == "Tripple Exponential" ) m = TEMA( P, Periods );
if( Type == "Wilders" ) m = Wilders( P, Periods );
if( Type == "Simple" ) m = MA( P, Periods );
Plot( m, _DEFAULT_NAME(), ParamColor("Color", colorGrey40),ParamStyle("Style",styleLine |styleNoTitle ,maskAll),Displacement );
_SECTION_END();
_SECTION_BEGIN("Sell Average 3");
P = HaClose;
Type = ParamList("Type", "Weighted,Lagless-21,Hull-26,Linear
Regression-45,Exponential,Double Exponential,Tripple
Exponential,Wilders,Simple");
Periods = Param("Periods", 180, 2, 800 );
Displacement = Param("Displacement", 1, -50, 50 );
m = 0;
if( Type == "Weighted" ) m= WMA( P, Periods );
if( Type == "Lagless-21" ) m= 2*EMA(P, Periods)-EMA(EMA(P, Periods), Periods);
if( Type == "Hull-26" ) m= WMA(2*(WMA(P, Periods/2))-WMA(P, Periods) ,4 );
if( Type == "Linear Regression-45" ) m= LinearReg( P, Periods );
if( Type == "Exponential" ) m = EMA( P, Periods );
if( Type == "Double Exponential" ) m = DEMA( P, Periods );
if( Type == "Tripple Exponential" ) m = TEMA( P, Periods );
if( Type == "Wilders" ) m = Wilders( P, Periods );
if( Type == "Simple" ) m = MA( P, Periods );
Plot( m, _DEFAULT_NAME(), ParamColor("Color", ColorRGB(40,40,40)),ParamStyle("Style",styleLine |styleNoTitle ,maskAll),Displacement );
_SECTION_END();
_SECTION_BEGIN("trendline");
farback=Param("How Far back to go",100,50,5000,10);
nBars = Param("Number of bars", 12, 5, 40);
aHPivs = H - H;aLPivs = L - L;
aHPivHighs = H - H;aLPivLows = L - L;aHPivIdxs = H - H;aLPivIdxs = L - L;
nHPivs = 0;nLPivs = 0;lastHPIdx = 0;lastLPIdx = 0;lastHPH = 0;lastLPL = 0;
curPivBarIdx = 0;
aHHVBars = HHVBars(H, nBars);aLLVBars = LLVBars(L, nBars);
aHHV = HHV(H, nBars);aLLV = LLV(L, nBars);
aVisBars = Status("barvisible");nLastVisBar = LastValue(Highest(IIf(aVisBars, BarIndex(), 0)));
_TRACE("Last visible bar: " + nLastVisBar);
curBar = (BarCount-1);curTrend = "";if (aLLVBars[curBar] < aHHVBars[curBar]) {
curTrend = "D";}else {curTrend = "U";}
for (i=0; i<farback; i++) {curBar = (BarCount - 1) - i;
if (aLLVBars[curBar] < aHHVBars[curBar]) {
if (curTrend == "U") {curTrend = "D";
curPivBarIdx = curBar - aLLVBars[curBar];aLPivs[curPivBarIdx] = 1;aLPivLows[nLPivs] = L[curPivBarIdx];
aLPivIdxs[nLPivs] = curPivBarIdx;nLPivs++;}
} else {if (curTrend == "D") {curTrend = "U";curPivBarIdx = curBar - aHHVBars[curBar];
aHPivs[curPivBarIdx] = 1;aHPivHighs[nHPivs] = H[curPivBarIdx];
aHPivIdxs[nHPivs] = curPivBarIdx;nHPivs++;}} }
curBar = (BarCount-1);candIdx = 0;candPrc = 0;lastLPIdx = aLPivIdxs[0];lastLPL = aLPivLows[0];
lastHPIdx = aHPivIdxs[0];lastHPH = aHPivHighs[0];if (lastLPIdx > lastHPIdx) {
candIdx = curBar - aHHVBars[curBar];candPrc = aHHV[curBar];
if (lastHPH < candPrc AND candIdx > lastLPIdx AND candIdx < curBar) {
aHPivs[candIdx] = 1;
for (j=0; j<nHPivs; j++) {aHPivHighs[nHPivs-j] = aHPivHighs[nHPivs-(j+1)];
aHPivIdxs[nHPivs-j] = aHPivIdxs[nHPivs-(j+1)];}aHPivHighs[0] = candPrc ;
aHPivIdxs[0] = candIdx;nHPivs++;}} else {
candIdx = curBar - aLLVBars[curBar];candPrc = aLLV[curBar];if (lastLPL > candPrc AND
candIdx > lastHPIdx AND candIdx < curBar) {
aLPivs[candIdx] = 1;
for (j=0; j<nLPivs; j++) {aLPivLows[nLPivs-j] = aLPivLows[nLPivs-(j+1)];
aLPivIdxs[nLPivs-j] = aLPivIdxs[nLPivs-(j+1)];}aLPivLows[0] = candPrc;
aLPivIdxs[0] = candIdx;nLPivs++;}}
for (k=0; k<nHPivs; k++) {_TRACE("High pivot no. " + k
+ " at barindex: " + aHPivIdxs[k] + ", "
+ WriteVal(ValueWhen(BarIndex()==aHPivIdxs[k],
DateTime(), 1), formatDateTime)+ ", " + aHPivHighs[k]);}
a1=ahpivs==1;a2=alpivs==1;
x = Cum(1);s1=L;s11=H;pS = a2 == 1;
endt= SelectedValue(ValueWhen( pS, x, 1 ));
startt=SelectedValue(ValueWhen( pS, x, 2 ));dtS =endt-startt;
endS = SelectedValue(ValueWhen( pS, s1, 1 ) );
startS = SelectedValue( ValueWhen( pS, s1, 2 ));aS = (endS-startS)/dtS;
bS = endS;trendlineS = aS * ( x -endt ) + bS;
g3= IIf(x>startt-10,trendlineS,-1e10);
pR = a1== 1;endt1= SelectedValue(ValueWhen( pR, x, 1 ));
startt1=SelectedValue(ValueWhen( pR, x, 2 ));
dtR =endt1-startt1;endR = SelectedValue(ValueWhen( pR, s11, 1 ) );
startR = SelectedValue( ValueWhen( pR, s11, 2 ));
aR = (endR-startR)/dtR;bR = endR;
trendlineR = aR * ( x -endt1 ) + bR;
g4= IIf(x>startT1-10,trendlineR,-1e10);
_SECTION_END();
_SECTION_BEGIN("trendlineA");
dn=g3>C;
up=g3<C;
bbresult1 = WriteIf( dn,"dn", "");
bbresult2 = WriteIf( up,"up", "");
RequestTimedRefresh( 0 );
if ( bbresult1 =="dn")
{
GfxSelectSolidBrush( ColorRGB(255,0,0) );
}
else
if ( bbresult2 =="up")
{
GfxSelectSolidBrush( ColorRGB(0,147,0) );
}
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );
GfxSelectPen( colorWhite, 1 );
GfxCircle( 30,229,8 );
_SECTION_END();
_SECTION_BEGIN("trendlineA");
dn=g3>C;
up=g3<C;
bbresult1 = WriteIf( dn,"dn", "");
bbresult2 = WriteIf( up,"up", "");
RequestTimedRefresh( 0 );
if ( bbresult1 =="dn")
{
GfxSelectSolidBrush( ColorRGB(255,0,0) );
}
else
if ( bbresult2 =="up")
{
GfxSelectSolidBrush( ColorRGB(0,147,0) );
}
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );
GfxSelectPen( colorWhite, 1 );
GfxCircle( 168,367,8 );
_SECTION_END();
_SECTION_BEGIN("TRENDLINEline");
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );
GfxSelectPen( colorWhite, 1 );
GfxMoveTo( 35,234 );
GfxLineTo( 163, 362 );
_SECTION_END();
_SECTION_BEGIN("traing sl");
function vstop_func(trBull,trBear)
{
trailArray[ 0 ] = C[ 0 ]; // initialize
for( i = 1; i < BarCount; i++ )
{
prev = trailArray[ i - 1 ];
if (C[ i ] > prev AND C[ i - 1 ] > prev)
{
trailArray[ i ] = Max(prev,C[ i ] - trBull[ i ]);
}
else if (C[ i ] < prev AND C[ i - 1 ] < prev)
{
trailArray[ i ] = Min(prev,C[ i ] + trBear[ i ]);
}
else if (C[ i ] > prev)
{
trailArray[ i ] = C[ i ] - trBull[ i ];
}
else
{
trailArray[ i ] = C[ i ] + trBear[ i ];
}
}
return trailArray;
}
per = Param("per",20, 1, 150, 1);
multBull = Param("multBull",2, 1, 4, 0.05);
multBear = Param("multBear",2, 1, 4, 0.05);
trBull = multBull * ATR(per);
trBear = multBear * ATR(per);
trailArray = vstop_func(trBull,trBear);
s0=trailArray;
s1= s0 > C ;
s2= s0 <C ;
ccresult1 = WriteIf( s1,"cu", "");
ccresult2 = WriteIf( s2,"cd", "");
GfxSelectFont("arial", 13, 700 ); GfxSetBkMode( colorRed);
GfxSetTextColor( ParamColor("Color",colorRed) );
Hor=Param("Horizontal Position",30,10,1200,1);
Ver=Param("Vertical Position",185,100,50,50);
if ( ccresult1 =="cu")
{
GfxTextOut(""+s0,Hor , Ver );
}
else
GfxSelectFont("arial", 13, 700 ); GfxSetBkMode( colorGreen );
GfxSetTextColor( ParamColor("Color",colorGreen) );
Hor=Param("Horizontal Position",75,10,1200,1);
Ver=Param("Vertical Position",185,100,50,50);
if ( ccresult2 =="")
{
GfxTextOut(""+s0,Hor , Ver );
}
_SECTION_END();
_SECTION_BEGIN("traing s2");
s0=trailArray;
s1= s0 > C ;
s2= s0 <C ;
ccresult1 = WriteIf( s1,"cu", "");
ccresult2 = WriteIf( s2,"cd", "");
GfxSelectFont("arial", 13, 700 ); GfxSetBkMode( colorBrightGreen );
GfxSetTextColor( ParamColor("Color",colorBrightGreen) );
Hor=Param("Horizontal Position",30,10,1200,1);
Ver=Param("Vertical Position",185,100,50,50);
if ( ccresult2 =="cd")
{
GfxTextOut(""+s0,Hor , Ver );
}
else
GfxSelectFont("arial", 13, 700 ); GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorWhite) );
Hor=Param("Horizontal Position",75,10,1200,1);
Ver=Param("Vertical Position",185,100,50,50);
if ( ccresult1 =="")
{
GfxTextOut(""+s0,Hor , Ver );
}
_SECTION_END();
_SECTION_BEGIN("CMP");
GfxSelectFont("arial", 13, 700 ); GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorWhite) );
Hor=Param("Horizontal Position",120,10,1200,1);
Ver=Param("Vertical Position",185,100,50,50);
GfxTextOut(""+C,Hor , Ver );
_SECTION_END();
_SECTION_BEGIN("buycircle");
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorBlue );
GfxSelectPen( colorBlue, 1 );
if ( ccresult2 =="cd")
{
GfxSelectSolidBrush( ColorRGB(0,255,0) );
}
else
{
GfxSelectSolidBrush( ColorRGB(0,0,94) );
}
GfxCircle( 20,40,7 );
_SECTION_END();
_SECTION_BEGIN("sellcircle");
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorBlue );
GfxSelectPen( colorBlue, 1 );
if ( ccresult1 =="cu")
{
GfxSelectSolidBrush( ColorRGB(255,0,0) );
}
else
{
GfxSelectSolidBrush( ColorRGB(0,0,94) );
}
GfxCircle( 180,40,7 );
_SECTION_END();
_SECTION_BEGIN("Chart Settings");
SetChartOptions(0,chartShowArrows|chartShowDates);
SetChartBkColor(ParamColor("Outer Panel",colorBlack));
SetChartBkGradientFill(ParamColor("Upper Chart",colorDarkTeal),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( "BASERECTANGEL" );
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorBlue );
GfxSelectSolidBrush( colorDarkBlue );
GfxSelectPen( colorBlue, 1 );
// broader color
GfxRectangle(0,15,203,600);
_SECTION_END();
_SECTION_BEGIN("res/sup-s1");
DayH = TimeFrameGetPrice("H", inDaily, -1);// yesterdays high
DayL = TimeFrameGetPrice("L", inDaily, -1);//low
DayC = TimeFrameGetPrice("C", inDaily, -1);//close
DayO = TimeFrameGetPrice("O", inDaily);// current day open
HiDay = TimeFrameGetPrice("H", inDaily);
LoDay = TimeFrameGetPrice("L", inDaily);
PP = (DayH + DayL + DayO + DayO) / 4 ;
R1 = (2 * PP) - DayL;
S1 = (2 * PP) - DayH;
R2 = PP + R1 - S1;
S2 = PP + S1 - R1;
R3 = R2 + (R1 - PP);
S3 = S2 - (PP - S1);
style = styleLine | styleThick + styleNoRescale;
rcolor = colorBlue;
scolor = colorRed;
pcolor = colorGreen;
GfxSelectFont("arial", 10, 700 ); GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorRed) );
Hor=Param("Horizontal Position",20,10,1200,1);
Ver=Param("Vertical Position",420,300,500,500);
GfxTextOut(""+s1,Hor , Ver );
_SECTION_END();
_SECTION_BEGIN("res/sup-s2");
GfxSelectFont("arial", 10, 700 ); GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorRed) );
Hor=Param("Horizontal Position",20,10,1200,1);
Ver=Param("Vertical Position",480,300,500,500);
GfxTextOut(""+s2,Hor , Ver );
_SECTION_END();
_SECTION_BEGIN("res/sup-s3");
GfxSelectFont("arial", 10, 700 ); GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorRed) );
Hor=Param("Horizontal Position",20,10,1200,1);
Ver=Param("Vertical Position",540,300,600,600);
GfxTextOut(""+s3,Hor , Ver );
_SECTION_END();
_SECTION_BEGIN("res/sup-r1");
GfxSelectFont("arial", 10, 700 ); GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorGreen) );
Hor=Param("Horizontal Position",150,10,1200,1);
Ver=Param("Vertical Position",420,300,500,500);
GfxTextOut(""+r1,Hor , Ver );
_SECTION_END();
_SECTION_BEGIN("res/sup-r2");
GfxSelectFont("arial", 10, 700 ); GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorGreen) );
Hor=Param("Horizontal Position",150,10,1200,1);
Ver=Param("Vertical Position",480,300,500,500);
GfxTextOut(""+r2,Hor , Ver );
_SECTION_END();
_SECTION_BEGIN("res/sup-r3");
GfxSelectFont("arial", 10, 700 ); GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorGreen) );
Hor=Param("Horizontal Position",150,10,1200,1);
Ver=Param("Vertical Position",540,300,500,500);
GfxTextOut(""+r3,Hor , Ver );
_SECTION_END();
_SECTION_BEGIN("MACD");
r1 = Param( "Fast avg", 12, 2, 200, 1 );
r2 = Param( "Slow avg", 26, 2, 200, 1 );
r3 = Param( "Signal avg", 9, 2, 200, 1 );
r4 = Param( "Wk slow", 17, 2, 200, 1 );
r5 = Param( "Wk fast", 8, 2, 200, 1 );
m1=MACD(r1,r2);
s1=Signal(r1,r2,r3);
_SECTION_END();
_SECTION_BEGIN("WRITE");
GfxSelectFont("arial", 8, 700 ); GfxSetBkMode( colorLightBlue );
GfxSetTextColor( ParamColor("Color",colorLightBlue) );
Hor=Param("Horizontal Position",0,10,1200,1);
Ver=Param("Vertical Position",580,100,50,50);
GfxTextOut(" R O C K E T J E T",Hor , Ver );
_SECTION_END();
_SECTION_BEGIN("Forex_Main_mrtq13");
///////////////////////////////////
Title =
EncodeColor(colorWhite)+ Title = Name () + " | "
+EncodeColor(colorYellow) + Date() + " | "
+EncodeColor(colorTurquoise)+ "O : "+ EncodeColor(colorLightGrey)+ O + " | "
+EncodeColor(colorTurquoise)+ "H : "+ EncodeColor(colorLightGrey)+ H + " | "
+EncodeColor(colorTurquoise)+ "L : "+ EncodeColor(colorLightGrey)+ L + " | "
+EncodeColor(colorTurquoise)+ "C : "+ WriteIf(C> Ref(C, -1),EncodeColor(colorBrightGreen),EncodeColor(colorRed))+ C + " | "
+EncodeColor(colorTurquoise)+ "Change : ("+ WriteIf(C> Ref(C, -1),EncodeColor(colorBrightGreen),EncodeColor(colorRed)) + WriteVal(C-Ref(C,-1))+" Rs."
+EncodeColor(colorTurquoise)+ " /"+ WriteIf(C> Ref(C, -1),EncodeColor(colorBrightGreen),EncodeColor(colorRed))+ WriteVal( ROC( C, 1 ))+""+ " % "
+EncodeColor(colorTurquoise)+ ") | Volume : " + WriteIf(V> Ref(V, -1),EncodeColor(colorBrightGreen),EncodeColor(colorRed))+ WriteVal(V,1)
;
_SECTION_END();
_SECTION_BEGIN("Flower");
Show_color = ParamToggle("Display CandleColor", "No|Yes", 1);
r1 = Param( "ColorFast avg", 5, 2, 200, 1 );
r2 = Param( "ColorSlow avg", 10, 2, 200, 1 );
r3 = Param( "ColorSignal avg", 5, 2, 200, 1 );
Prd1=Param("ATR Period",4,1,20,1);
Prd2=Param("Look Back",7,1,20,1);
green = HHV(LLV(L,Prd1)+ATR(Prd1),Prd2);
red = LLV(HHV(H,Prd1)-ATR(Prd1),Prd2);
flowerClose = EMA((Open+High+Low+Close)/4,3) ;
flowerOpen = EMA((Ref(Open,-1) + Ref(flowerClose,-1))/2,3);
Temp = Max(High, flowerOpen);
flowerHigh = EMA(Max(Temp, flowerClose),3);
Temp = Min(Low,flowerOpen);
flowerLow = EMA(Min(Temp, flowerClose),3);
m1=MACD(r1,r2);
s1=Signal(r1,r2,r3);
mycolor=IIf(m1<0 AND m1>s1, colorYellow,IIf(m1>0 AND
m1>s1,colorWhite,IIf(m1>0 AND m1<s1,colorDarkYellow,colorRed)));
if(Show_color)
{
ColorHighliter = myColor;
SetBarFillColor( ColorHighliter );
}
barColor=IIf(C>Green ,colorWhite,IIf(C < RED,colorRed,colorWhite));
PlotOHLC( IIf(flowerOpen<flowerClose, flowerOpen,
flowerClose),flowerHigh,flowerLow,IIf(flowerOpen<flowerClose, flowerClose,
flowerOpen), "Close", barColor, styleNoTitle | styleCandle);
_SECTION_END();
_SECTION_BEGIN("Bands");
SupResB =Param("Sup-Res Short",6,0,100,1);
nn=SupResB;
Bandlinecol=ParamColor("SupResLineColor",ColorRGB(82,82,82));
ParmCloud = ParamToggle("Cloud", "No|Yes", 0);
BoxCloudColor=ParamColor("BoxCloudColor",ColorRGB(27,27,27));
Line2=Param("ResLineLength",100,2,500,0.1);
Daysback1 = Line2;
FirstBar1 = BarCount - DaysBack1;
Hh=HHV(flowerHigh,nn);
LL=LLV(flowerLow,nn);
Res2=Hh;
Sup2=LL;
BandRes=IIf(BarIndex() >= Firstbar1,EndValue(Res2),Null);
BandSup=IIf(BarIndex() >= Firstbar1,EndValue(Sup2),Null);
Plot(BandRes,"",Bandlinecol,ParamStyle("ShortSupBand",styleLine|styleDashed|stylehidden|styleNoTitle|styleNoLabel|styleThick,maskAll));
Plot(BandSup,"",Bandlinecol,ParamStyle("ShortResBand",styleLine|styleDashed|stylehidden|styleNoTitle|styleNoLabel|styleThick,maskAll));
CS=BandRes;
CR=BandSup;
if(parmCloud == 1)
PlotOHLC( CS, CS, CR,CR, "Band",BoxCloudColor, styleCloud | styleNoLabel|styleNoTitle);
_SECTION_END();
_SECTION_BEGIN("Breakout Setting");
Buyperiods=Param("Breakout periods best is usually 18",5,1,100,1,1);
Sellperiods=Param("Exit Breakout",5,1,100,1,1);
HaClose =EMA((O+H+L+C)/4,3); // Woodie
//HaClose =(O+H+L+C)/4;
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
HaHigh = Max( H, Max( HaClose, HaOpen ) );
HaLow = Min( L, Min( HaClose, HaOpen ) );
Buy= C>Ref(HHV(High,Buyperiods),-1) ;
Sell= C<Ref(LLV(Low,Sellperiods),-1);
/* exrem is one method to remove surplus strade signals. It removes excessive signals of arrow */
Buy = ExRem(Buy, Sell);
Sell = ExRem(Sell, Buy);
PlotShapes( IIf( Buy, shapeSmallUpTriangle, shapeNone ), colorWhite, layer = 0,yposition = HaLow, offset = -30);
//PlotShapes( IIf( Buy, shapeSmallCircle, shapeNone ), colorWhite, layer = 0,yposition = HaLow, offset = -8);
PlotShapes( IIf( Sell, shapeSmallDownTriangle, shapeNone ), colorRed, layer = 0, yposition = HaHigh, offset = -30);
//PlotShapes( IIf( Sell, shapeSmallCircle, shapeNone ), colorRed, layer = 0, yposition = HaHigh, offset = -8);
_SECTION_END();
_SECTION_BEGIN("Graphics");
GrpPrm=Param("Graphic Space",-5,-10,10);
GraphXSpace=GrpPrm;
_SECTION_END();
//#include <T3.AFL>;
_SECTION_BEGIN("PFE");
pds=10;
x=sqrt((ROC(C,9)*ROC(C,9))+100);
y=Sum(sqrt((ROC(C,1)* ROC(C,1))+1),pds);
z=(x/y);
pfe=EMA(IIf(C>Ref(C,-9),z,-z)*100,5);
rsidn=pfe <-10 AND pfe<Ref(pfe,-1);
rsiup=pfe >10 AND pfe>Ref(pfe,-1);
rsiresult1 = WriteIf( rsiup,"cu", "");
rsiresult2 = WriteIf( rsidn,"cd", "");
RequestTimedRefresh( 0 );
GfxSelectFont( "Tahoma", 12, 120 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );
if ( rsiresult1 =="cu")
{
GfxSelectSolidBrush( ColorRGB(0,90,0) );
}
else
if ( rsiresult2 =="cd")
{
GfxSelectSolidBrush( ColorRGB(90,0,0));
}
else
if ( rsiresult2 =="")
{
GfxSelectSolidBrush( colorDarkTeal );
}
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorBlue );
GfxCircle( 100,90,50 );
_SECTION_END();
//GfxRoundRect( 15,305,135,215, 5, 5 );
GfxCircle( 100,100,70 );
_SECTION_END();
_SECTION_BEGIN("STC");
_SECTION_BEGIN("Schaff Trend Cycle");
/*
Ported directly from original STC Tradestation code
results differ from other Amibroker versions that are not based directly on original EasyLanguage code
http://mediaserver.fxstreet.com/Reports/99afdb5f-d41d-4a2c-802c-f5d787df886c/ebfbf387-4b27-4a0f-848c-039f4ab77c00.pdf
*/
MA1=23;
MA2=50;
TCLen=10;
MA1=Param("ShortMACDLen",23,5,36);
MA2=Param("LOngMACDLen",50,10,100);
TCLen=Param("TCLen(StochPeriod)",10,5,20);
Factor=.5;
//Calculate a MACD Line
XMac = MACD(MA1,MA2) ; // MACD in Amibroker always uses Close for MACD calculation
//1st Stochastic: Calculate Stochastic of a MACD
Value1 = LLV(XMac, TCLen);
Value2 = HHV(XMac, TCLen) - Value1;
//Frac1=1; // prime Frac1 to a default of 1
//Frac1 = IIf(Value2 > 0, ((XMac - Value1) / Value2) * 100, Ref(FRAC1,-1));
// have to "prime" first value so that reference to "i-1" does not result in subscript out of range
// since MACD for both periods is not defined until MA2 period, 0 seems to be mathematically correct priming value
frac1=0;
for (i = 1; i < BarCount; i++) {
if (Value2[i] > 0) {
frac1[i] = ((XMac[i] - Value1[i])/Value2[i])*100;
}
else {
frac1[i]= frac1[i-1];
}
}
//Smoothed calculation for %FastD of MACD
PF[0]=frac1[0];
PF[1]=frac1[1];
for (i = 2; i < BarCount; i++) {
PF[i]=PF[i-1]+(Factor*(frac1[i]-PF[i-1]));
}
//2nd Stochastic: Calculate Stochastic of Smoothed Percent FastD, above.
Value3 = LLV(PF, TCLen);
Value4 = HHV(PF, TCLen) - Value3;
//%FastK of PF
/*
Frac2=1;
Frac2 = IIf(Value4 > 0, ((PF - Value3) / Value4) * 100, Ref(FRAC2,-1));
*/
frac2[0]=0;
for (i = 1; i < BarCount; i++) {
if (Value4[i] > 0 ) {
frac2[i]=((PF[i] - Value3[i])/Value4[i])*100;
}
else {
frac2[i]=frac2[i-1];
}
}
//Smoothed calculation for %FastD of PF
PFF[0]=frac2[0];
PFF[1]=frac2[1];
for (i = 2; i < BarCount; i++) {
PFF[i]=PFF[i-1]+(Factor*(frac2[i]-PFF[i-1]));
}
//HT=ParamColor("HT", colorRed );
rsidn=pff <2;
rsiup=pff >98;
rsiresult1 = WriteIf( rsiup,"cu", "");
rsiresult2 = WriteIf( rsidn,"cd", "");
RequestTimedRefresh( 0 );
GfxSelectFont( "Tahoma", 12, 120 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );
if ( rsiresult1 =="cu")
{
GfxSelectSolidBrush( ColorRGB(0,120,0) );
}
else
if ( rsiresult2 =="cd")
{
GfxSelectSolidBrush( ColorRGB(120,0,0));
}
else
if ( rsiresult2 =="")
{
GfxSelectSolidBrush( colorDarkTeal );
}
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorBlue );
GfxCircle( 100,100,60 );
_SECTION_END();
_SECTION_BEGIN("rsi");
//HT=ParamColor("HT", colorRed );
rsidn=RSI(7) <30;
rsiup=RSI(7) >70;
rsiresult1 = WriteIf( rsiup,"cu", "");
rsiresult2 = WriteIf( rsidn,"cd", "");
RequestTimedRefresh( 0 );
GfxSelectFont( "Tahoma", 12, 120 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );
if ( rsiresult1 =="cu")
{
GfxSelectSolidBrush( ColorRGB(0,150,0) );
}
else
if ( rsiresult2 =="cd")
{
GfxSelectSolidBrush( ColorRGB(150,0,0));
}
else
if ( rsiresult2 =="")
{
GfxSelectSolidBrush( colorDarkTeal );
}
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorBlue );
GfxCircle( 100,100,50 );
_SECTION_END();
_SECTION_BEGIN("Rays");
//FT=ParamColor("FT", colorRed );
Pp1=3;
Pp2=2;
CS33=HHV(LLV(flowerHigh,Pp1)-ATR(Pp2),4);
CR33=HHV(LLV(flowerHigh,Pp1)-ATR(Pp2),5);
AtrupTrendCond1 = flowerClose> CS33 ;
AtrdnTrendCond1 =CS33>flowerClose ;
ATRup = WriteIf(AtrupTrendCond1,"atrup", "");
ATRdown= WriteIf( AtrdnTrendCond1,"atrdn", "");
if ( ATRup =="atrup")
{
GfxSelectSolidBrush( ColorRGB(0,180,0) );
}
else
if (ATRdown =="atrdn")
{
GfxSelectSolidBrush( ColorRGB(180,0,0));
}
else
if ( ATRdown =="")
{
GfxSelectSolidBrush( colorDarkTeal );
}
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorBlue );
GfxSelectPen( colorBlue, 1 ); // broader color
GfxCircle( 100,100,40 );
_SECTION_END();
_SECTION_BEGIN("Exit_Beast-3");
//GT=ParamColor("GT", colorRed );
EntrylookbackPeriod=10;
EntryATRperiod=1.9;
EntrySig = C > ( LLV( flowerLow, EntrylookbackPeriod ) + EntryATRperiod * ATR( 10 ) );
ExitSig = C < ( HHV( flowerHigh, EntrylookbackPeriod ) -EntryATRperiod * ATR( 10 ) );
RequestTimedRefresh( 0 );
GfxSelectFont( "Tahoma", 12, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );
EntryB = WriteIf( EntrySig,"eu", "");
ExitB = WriteIf( ExitSig,"ed", "");
if ( EntryB =="eu")
{
GfxSelectSolidBrush( ColorRGB(0,210,0) ); //
}
else
if ( ExitB =="ed")
{
GfxSelectSolidBrush( ColorRGB(210,0,0)); //
}
else
if ( ExitB =="")
{
GfxSelectSolidBrush( colorDarkTeal );
}
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorBlue );
GfxSelectPen( colorBlue, 1 ); // broader color
GfxCircle( 100,100,30 );// changing the value of x,y,rad x-70, y-90, rad-24
_SECTION_END();
_SECTION_BEGIN("CCI9-2");
//HT=ParamColor("HT", colorRed );
ccidn=CCI(8) < 0;
cciup=CCI(9) > 0;
ccresult1 = WriteIf( cciup,"cu", "");
ccresult2 = WriteIf( ccidn,"cd", "");
RequestTimedRefresh( 0 );
GfxSelectFont( "Tahoma", 12, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );
if ( ccresult1 =="cu")
{
GfxSelectSolidBrush( ColorRGB(0,240,0) );
}
else
if ( ccresult2 =="cd")
{
GfxSelectSolidBrush( ColorRGB(240,0,0));
}
else
if ( ccresult2 =="")
{
GfxSelectSolidBrush( colorDarkTeal );
}
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorBlue );
GfxSelectPen( colorBlue, 1 ); // broader color
GfxCircle( 100,100,20);
_SECTION_END();
_SECTION_BEGIN("%BB7-1");
//IT=ParamColor("IT", colorRed );
p=7;
x=((C+2*StDev(C,p)-MA(C,p))/(4*StDev(C,p)))*100;
bbdown= x < 40;
bbup= x > 40;
bbresult1 = WriteIf( bbup,"bu", "");
bbresult2 = WriteIf( bbdown,"bd", "");
bbresult3 = WriteIf( C,"bearishrevers", "");
RequestTimedRefresh( 0 );
GfxSelectFont( "Tahoma", 12, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );
if ( bbresult1 =="bu")
{
GfxSelectSolidBrush( ColorRGB(62,255,62) );
}
else
if ( bbresult2 =="bd")
{
GfxSelectSolidBrush( ColorRGB(255,62,62) );
}
else
if ( bbresult2 =="")
{
GfxSelectSolidBrush( colorDarkTeal );
}
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorBlue );
GfxSelectPen( colorBlue, 1 ); // broader color
GfxCircle( 100,100,10 );
_SECTION_END();
_SECTION_BEGIN("MACDHIGHBULLISH");
r1 = Param( "Fast avg", 12, 2, 200, 1 );
r2 = Param( "Slow avg", 26, 2, 200, 1 );
r3 = Param( "Signal avg", 9, 2, 200, 1 );
r4 = Param( "Wk slow", 17, 2, 200, 1 );
r5 = Param( "Wk fast", 8, 2, 200, 1 );
m1=MACD(r1,r2);
s1=Signal(r1,r2,r3);
rsidn=m1>0 AND m1>s1;
rsiresult2 = WriteIf( rsidn,"cd", "");
if ( rsiresult2 =="cd")
{
GfxSelectSolidBrush( ColorRGB(0,147,0));
}
else
if ( rsiresult2 =="")
{
GfxSelectSolidBrush( colorDarkTeal );
}
RequestTimedRefresh( 0 );
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorBlue );
GfxSelectPen( colorBlue, 1 );
// broader color
GfxRectangle(80,220,120,280);
_SECTION_END();
_SECTION_BEGIN("MACDLOWHBULLISH");
r1 = Param( "Fast avg", 12, 2, 200, 1 );
r2 = Param( "Slow avg", 26, 2, 200, 1 );
r3 = Param( "Signal avg", 9, 2, 200, 1 );
r4 = Param( "Wk slow", 17, 2, 200, 1 );
r5 = Param( "Wk fast", 8, 2, 200, 1 );
m1=MACD(r1,r2);
s1=Signal(r1,r2,r3);
rsidn=m1<0 AND m1>s1;
rsiresult2 = WriteIf( rsidn,"cd", "");
if ( rsiresult2 =="cd")
{
GfxSelectSolidBrush( ColorRGB(0,147,0));
}
else
if ( rsiresult2 =="")
{
GfxSelectSolidBrush( colorDarkTeal );
}
RequestTimedRefresh( 0 );
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorBlue );
GfxSelectPen( colorBlue, 1 );
// broader color
GfxRectangle(120,315,180,280);
_SECTION_END();
_SECTION_BEGIN("MACDLOWHBEARISH");
r1 = Param( "Fast avg", 12, 2, 200, 1 );
r2 = Param( "Slow avg", 26, 2, 200, 1 );
r3 = Param( "Signal avg", 9, 2, 200, 1 );
r4 = Param( "Wk slow", 17, 2, 200, 1 );
r5 = Param( "Wk fast", 8, 2, 200, 1 );
m1=MACD(r1,r2);
s1=Signal(r1,r2,r3);
rsidn=m1>0 AND m1<s1;
rsiresult2 = WriteIf( rsidn,"cd", "");
if ( rsiresult2 =="cd")
{
GfxSelectSolidBrush( ColorRGB(225,0,0));
}
else
if ( rsiresult2 =="")
{
GfxSelectSolidBrush( colorDarkTeal );
}
RequestTimedRefresh( 0 );
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorBlue );
GfxSelectPen( colorBlue, 1 );
// broader color
GfxRectangle(20,315,80,280);
_SECTION_END();
_SECTION_BEGIN("MACDHIGHHBEARISH");
r1 = Param( "Fast avg", 12, 2, 200, 1 );
r2 = Param( "Slow avg", 26, 2, 200, 1 );
r3 = Param( "Signal avg", 9, 2, 200, 1 );
r4 = Param( "Wk slow", 17, 2, 200, 1 );
r5 = Param( "Wk fast", 8, 2, 200, 1 );
m1=MACD(r1,r2);
s1=Signal(r1,r2,r3);
rsidn=m1<0 AND m1<s1;
rsiresult2 = WriteIf( rsidn,"cd", "");
if ( rsiresult2 =="cd")
{
GfxSelectSolidBrush( ColorRGB(225,0,0));
}
else
if ( rsiresult2 =="")
{
GfxSelectSolidBrush( colorDarkTeal );
}
RequestTimedRefresh( 0 );
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorBlue );
GfxSelectPen( colorBlue, 1 );
// broader color
GfxRectangle(80,375,120,315);
_SECTION_END();
_SECTION_BEGIN("bearishline");
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorRed );
GfxSelectPen( colorRed, 1 );
GfxMoveTo( 25,320 );
GfxLineTo( 75, 370 );
_SECTION_END();
_SECTION_BEGIN("bullishline");
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorGreen );
GfxSelectPen( colorGreen, 1 );
GfxMoveTo( 125,225 );
GfxLineTo( 175, 275 );
_SECTION_END();
_SECTION_BEGIN("volume1");
GfxSelectSolidBrush( colorDarkTeal );
GfxRoundRect(90,555,110,405,20,20);
_SECTION_END();
_SECTION_BEGIN("volume2");
GfxSelectSolidBrush( colorDarkTeal );
GfxCircle( 100,550,23 );
_SECTION_END();
_SECTION_BEGIN("spiker");
C1 = Ref(C, -1);
uc = C > C1; dc = C <= C1;
ud = C > O; dd = C <= O;
green = 1; blue = 2; yellow = 3; red = 4; white = 5;
VType = IIf(ud,
IIf(uc, green, yellow),
IIf(dd,
IIf(dc, red, blue), white));
/* green volume: up-day and up-close*/
gv = IIf(VType == green, V, 0);
/* yellow volume: up-day but down-close */
yv = IIf(VType == yellow, V, 0);
/* red volume: down-day and down-close */
rv = IIf(VType == red, V, 0);
/* blue volume: down-day but up-close */
bv = IIf(VType == blue, V, 0);
uv = gv + bv; uv1 = Ref(uv, -1); /* up volume */
dv = rv + yv; dv1 = Ref(dv, -1); /* down volume */
VolPer = Param("Adjust Vol. MA per.", 10, 1, 255, 1);
ConvPer = Param("Adjust Conv. MA per.", 4, 1, 255, 1);
MAuv = TEMA(uv, VolPer ); mauv1 = Ref(mauv, -1);
MAdv = TEMA(dv, VolPer ); madv1 = Ref(madv, -1);
MAtv = TEMA(V, VolPer );//total volume
Converge = (TEMA(MAuv - MAdv, ConvPer));
Converge1 = Ref(Converge, -1);
ConvergeUp = Converge > Converge1;
ConvergeOver = Converge > 0;
rising = ConvergeUp AND ConvergeOver;
falling = !ConvergeUp AND ConvergeOver;
_SECTION_END();
_SECTION_BEGIN("vol30");
rsiup=rising;
rsidn=falling;
down=Converge > 0;
rsiresult1 = WriteIf( rsiup,"ab", "");
rsiresult2 = WriteIf( rsidn,"cd", "");
rsiresult3 = WriteIf( down,"ef", "");
RequestTimedRefresh( 0 );
if ( rsiresult1 =="ab")
{
GfxSelectSolidBrush( ColorRGB(0,147,0) );
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorGreen );
GfxSelectPen( colorGreen, 1 );
}
else
if ( rsiresult2 =="cd")
{
GfxSelectSolidBrush( ColorRGB(0,85,0) );
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorDarkGreen );
GfxSelectPen( colorDarkGreen, 1 );
}
else
{
GfxSelectSolidBrush( ColorRGB(255,0,0) );
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorRed );
GfxSelectPen( colorRed, 1 );
}
GfxRectangle(91,550,109,430);
_SECTION_END();
_SECTION_BEGIN("vol31");
rsiup=rising;
rsidn=falling;
down=Converge > 0;
rsiresult1 = WriteIf( rsiup,"ab", "");
rsiresult2 = WriteIf( rsidn,"cd", "");
rsiresult3 = WriteIf( down,"ef", "");
RequestTimedRefresh( 0 );
if ( rsiresult1 =="ab")
{
GfxSelectSolidBrush( ColorRGB(0,147,0) );
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorGreen );
GfxSelectPen( colorGreen, 1 );
}
else
if ( rsiresult2 =="cd")
{
GfxSelectSolidBrush( ColorRGB(0,85,0) );
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorDarkGreen );
GfxSelectPen( colorDarkGreen, 1 );
}
else
{
GfxSelectSolidBrush( ColorRGB(255,0,0) );
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorRed );
GfxSelectPen( colorRed, 1 );
}
GfxCircle( 100,550,22 );
_SECTION_END();
_SECTION_BEGIN("Average 0");
//Average_switch = ParamToggle("Candle On/off", "Off|On");
P = HaClose;
Type = ParamList("Type", "Weighted,Lagless-21,Hull-26,Linear
Regression-45,Exponential,Double Exponential,Tripple
Exponential,Wilders,Simple");
Periods = Param("Periods", 20, 2, 200 );
Displacement = Param("Displacement", 1, -50, 50 );
m = 0;
if( Type == "Weighted" ) m= WMA( P, Periods );
if( Type == "Lagless-21" ) m= 2*EMA(P, Periods)-EMA(EMA(P, Periods), Periods);
if( Type == "Hull-26" ) m= WMA(2*(WMA(P, Periods/2))-WMA(P, Periods) ,4 );
if( Type == "Linear Regression-45" ) m= LinearReg( P, Periods );
if( Type == "Exponential" ) m = EMA( P, Periods );
if( Type == "Double Exponential" ) m = DEMA( P, Periods );
if( Type == "Tripple Exponential" ) m = TEMA( P, Periods );
if( Type == "Wilders" ) m = Wilders( P, Periods );
if( Type == "Simple" ) m = MA( P, Periods );
Plot( m, _DEFAULT_NAME(), ParamColor("Color", colorLightGrey),ParamStyle("Style",styleLine |styleThick|styleNoTitle ,maskAll),Displacement );
_SECTION_END();
_SECTION_BEGIN("Average 1");
//Average_switch = ParamToggle("Candle On/off", "Off|On");
P = HaClose;
Type = ParamList("Type", "Weighted,Lagless-21,Hull-26,Linear
Regression-45,Exponential,Double Exponential,Tripple
Exponential,Wilders,Simple");
Periods = Param("Periods", 60, 2, 200 );
Displacement = Param("Displacement", 1, -50, 50 );
m = 0;
if( Type == "Weighted" ) m= WMA( P, Periods );
if( Type == "Lagless-21" ) m= 2*EMA(P, Periods)-EMA(EMA(P, Periods), Periods);
if( Type == "Hull-26" ) m= WMA(2*(WMA(P, Periods/2))-WMA(P, Periods) ,4 );
if( Type == "Linear Regression-45" ) m= LinearReg( P, Periods );
if( Type == "Exponential" ) m = EMA( P, Periods );
if( Type == "Double Exponential" ) m = DEMA( P, Periods );
if( Type == "Tripple Exponential" ) m = TEMA( P, Periods );
if( Type == "Wilders" ) m = Wilders( P, Periods );
if( Type == "Simple" ) m = MA( P, Periods );
Plot( m, _DEFAULT_NAME(), ParamColor("Color", colorGrey50),ParamStyle("Style",styleLine |styleNoTitle ,maskAll),Displacement );
_SECTION_END();
_SECTION_BEGIN("Average 5");
P = HaClose;
Type = ParamList("Type", "Weighted,Lagless-21,Hull-26,Linear
Regression-45,Exponential,Double Exponential,Tripple
Exponential,Wilders,Simple");
Periods = Param("Periods", 120 ,2, 200 );
Displacement = Param("Displacement", 1, -50, 50 );
m = 0;
if( Type == "Weighted" ) m= WMA( P, Periods );
if( Type == "Lagless-21" ) m= 2*EMA(P, Periods)-EMA(EMA(P, Periods), Periods);
if( Type == "Hull-26" ) m= WMA(2*(WMA(P, Periods/2))-WMA(P, Periods) ,4 );
if( Type == "Linear Regression-45" ) m= LinearReg( P, Periods );
if( Type == "Exponential" ) m = EMA( P, Periods );
if( Type == "Double Exponential" ) m = DEMA( P, Periods );
if( Type == "Tripple Exponential" ) m = TEMA( P, Periods );
if( Type == "Wilders" ) m = Wilders( P, Periods );
if( Type == "Simple" ) m = MA( P, Periods );
Plot( m, _DEFAULT_NAME(), ParamColor("Color", colorGrey40),ParamStyle("Style",styleLine |styleNoTitle ,maskAll),Displacement );
_SECTION_END();
_SECTION_BEGIN("Sell Average 3");
P = HaClose;
Type = ParamList("Type", "Weighted,Lagless-21,Hull-26,Linear
Regression-45,Exponential,Double Exponential,Tripple
Exponential,Wilders,Simple");
Periods = Param("Periods", 180, 2, 800 );
Displacement = Param("Displacement", 1, -50, 50 );
m = 0;
if( Type == "Weighted" ) m= WMA( P, Periods );
if( Type == "Lagless-21" ) m= 2*EMA(P, Periods)-EMA(EMA(P, Periods), Periods);
if( Type == "Hull-26" ) m= WMA(2*(WMA(P, Periods/2))-WMA(P, Periods) ,4 );
if( Type == "Linear Regression-45" ) m= LinearReg( P, Periods );
if( Type == "Exponential" ) m = EMA( P, Periods );
if( Type == "Double Exponential" ) m = DEMA( P, Periods );
if( Type == "Tripple Exponential" ) m = TEMA( P, Periods );
if( Type == "Wilders" ) m = Wilders( P, Periods );
if( Type == "Simple" ) m = MA( P, Periods );
Plot( m, _DEFAULT_NAME(), ParamColor("Color", ColorRGB(40,40,40)),ParamStyle("Style",styleLine |styleNoTitle ,maskAll),Displacement );
_SECTION_END();
_SECTION_BEGIN("trendline");
farback=Param("How Far back to go",100,50,5000,10);
nBars = Param("Number of bars", 12, 5, 40);
aHPivs = H - H;aLPivs = L - L;
aHPivHighs = H - H;aLPivLows = L - L;aHPivIdxs = H - H;aLPivIdxs = L - L;
nHPivs = 0;nLPivs = 0;lastHPIdx = 0;lastLPIdx = 0;lastHPH = 0;lastLPL = 0;
curPivBarIdx = 0;
aHHVBars = HHVBars(H, nBars);aLLVBars = LLVBars(L, nBars);
aHHV = HHV(H, nBars);aLLV = LLV(L, nBars);
aVisBars = Status("barvisible");nLastVisBar = LastValue(Highest(IIf(aVisBars, BarIndex(), 0)));
_TRACE("Last visible bar: " + nLastVisBar);
curBar = (BarCount-1);curTrend = "";if (aLLVBars[curBar] < aHHVBars[curBar]) {
curTrend = "D";}else {curTrend = "U";}
for (i=0; i<farback; i++) {curBar = (BarCount - 1) - i;
if (aLLVBars[curBar] < aHHVBars[curBar]) {
if (curTrend == "U") {curTrend = "D";
curPivBarIdx = curBar - aLLVBars[curBar];aLPivs[curPivBarIdx] = 1;aLPivLows[nLPivs] = L[curPivBarIdx];
aLPivIdxs[nLPivs] = curPivBarIdx;nLPivs++;}
} else {if (curTrend == "D") {curTrend = "U";curPivBarIdx = curBar - aHHVBars[curBar];
aHPivs[curPivBarIdx] = 1;aHPivHighs[nHPivs] = H[curPivBarIdx];
aHPivIdxs[nHPivs] = curPivBarIdx;nHPivs++;}} }
curBar = (BarCount-1);candIdx = 0;candPrc = 0;lastLPIdx = aLPivIdxs[0];lastLPL = aLPivLows[0];
lastHPIdx = aHPivIdxs[0];lastHPH = aHPivHighs[0];if (lastLPIdx > lastHPIdx) {
candIdx = curBar - aHHVBars[curBar];candPrc = aHHV[curBar];
if (lastHPH < candPrc AND candIdx > lastLPIdx AND candIdx < curBar) {
aHPivs[candIdx] = 1;
for (j=0; j<nHPivs; j++) {aHPivHighs[nHPivs-j] = aHPivHighs[nHPivs-(j+1)];
aHPivIdxs[nHPivs-j] = aHPivIdxs[nHPivs-(j+1)];}aHPivHighs[0] = candPrc ;
aHPivIdxs[0] = candIdx;nHPivs++;}} else {
candIdx = curBar - aLLVBars[curBar];candPrc = aLLV[curBar];if (lastLPL > candPrc AND
candIdx > lastHPIdx AND candIdx < curBar) {
aLPivs[candIdx] = 1;
for (j=0; j<nLPivs; j++) {aLPivLows[nLPivs-j] = aLPivLows[nLPivs-(j+1)];
aLPivIdxs[nLPivs-j] = aLPivIdxs[nLPivs-(j+1)];}aLPivLows[0] = candPrc;
aLPivIdxs[0] = candIdx;nLPivs++;}}
for (k=0; k<nHPivs; k++) {_TRACE("High pivot no. " + k
+ " at barindex: " + aHPivIdxs[k] + ", "
+ WriteVal(ValueWhen(BarIndex()==aHPivIdxs[k],
DateTime(), 1), formatDateTime)+ ", " + aHPivHighs[k]);}
a1=ahpivs==1;a2=alpivs==1;
x = Cum(1);s1=L;s11=H;pS = a2 == 1;
endt= SelectedValue(ValueWhen( pS, x, 1 ));
startt=SelectedValue(ValueWhen( pS, x, 2 ));dtS =endt-startt;
endS = SelectedValue(ValueWhen( pS, s1, 1 ) );
startS = SelectedValue( ValueWhen( pS, s1, 2 ));aS = (endS-startS)/dtS;
bS = endS;trendlineS = aS * ( x -endt ) + bS;
g3= IIf(x>startt-10,trendlineS,-1e10);
pR = a1== 1;endt1= SelectedValue(ValueWhen( pR, x, 1 ));
startt1=SelectedValue(ValueWhen( pR, x, 2 ));
dtR =endt1-startt1;endR = SelectedValue(ValueWhen( pR, s11, 1 ) );
startR = SelectedValue( ValueWhen( pR, s11, 2 ));
aR = (endR-startR)/dtR;bR = endR;
trendlineR = aR * ( x -endt1 ) + bR;
g4= IIf(x>startT1-10,trendlineR,-1e10);
_SECTION_END();
_SECTION_BEGIN("trendlineA");
dn=g3>C;
up=g3<C;
bbresult1 = WriteIf( dn,"dn", "");
bbresult2 = WriteIf( up,"up", "");
RequestTimedRefresh( 0 );
if ( bbresult1 =="dn")
{
GfxSelectSolidBrush( ColorRGB(255,0,0) );
}
else
if ( bbresult2 =="up")
{
GfxSelectSolidBrush( ColorRGB(0,147,0) );
}
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );
GfxSelectPen( colorWhite, 1 );
GfxCircle( 30,229,8 );
_SECTION_END();
_SECTION_BEGIN("trendlineA");
dn=g3>C;
up=g3<C;
bbresult1 = WriteIf( dn,"dn", "");
bbresult2 = WriteIf( up,"up", "");
RequestTimedRefresh( 0 );
if ( bbresult1 =="dn")
{
GfxSelectSolidBrush( ColorRGB(255,0,0) );
}
else
if ( bbresult2 =="up")
{
GfxSelectSolidBrush( ColorRGB(0,147,0) );
}
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );
GfxSelectPen( colorWhite, 1 );
GfxCircle( 168,367,8 );
_SECTION_END();
_SECTION_BEGIN("TRENDLINEline");
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );
GfxSelectPen( colorWhite, 1 );
GfxMoveTo( 35,234 );
GfxLineTo( 163, 362 );
_SECTION_END();
_SECTION_BEGIN("traing sl");
function vstop_func(trBull,trBear)
{
trailArray[ 0 ] = C[ 0 ]; // initialize
for( i = 1; i < BarCount; i++ )
{
prev = trailArray[ i - 1 ];
if (C[ i ] > prev AND C[ i - 1 ] > prev)
{
trailArray[ i ] = Max(prev,C[ i ] - trBull[ i ]);
}
else if (C[ i ] < prev AND C[ i - 1 ] < prev)
{
trailArray[ i ] = Min(prev,C[ i ] + trBear[ i ]);
}
else if (C[ i ] > prev)
{
trailArray[ i ] = C[ i ] - trBull[ i ];
}
else
{
trailArray[ i ] = C[ i ] + trBear[ i ];
}
}
return trailArray;
}
per = Param("per",20, 1, 150, 1);
multBull = Param("multBull",2, 1, 4, 0.05);
multBear = Param("multBear",2, 1, 4, 0.05);
trBull = multBull * ATR(per);
trBear = multBear * ATR(per);
trailArray = vstop_func(trBull,trBear);
s0=trailArray;
s1= s0 > C ;
s2= s0 <C ;
ccresult1 = WriteIf( s1,"cu", "");
ccresult2 = WriteIf( s2,"cd", "");
GfxSelectFont("arial", 13, 700 ); GfxSetBkMode( colorRed);
GfxSetTextColor( ParamColor("Color",colorRed) );
Hor=Param("Horizontal Position",30,10,1200,1);
Ver=Param("Vertical Position",185,100,50,50);
if ( ccresult1 =="cu")
{
GfxTextOut(""+s0,Hor , Ver );
}
else
GfxSelectFont("arial", 13, 700 ); GfxSetBkMode( colorGreen );
GfxSetTextColor( ParamColor("Color",colorGreen) );
Hor=Param("Horizontal Position",75,10,1200,1);
Ver=Param("Vertical Position",185,100,50,50);
if ( ccresult2 =="")
{
GfxTextOut(""+s0,Hor , Ver );
}
_SECTION_END();
_SECTION_BEGIN("traing s2");
s0=trailArray;
s1= s0 > C ;
s2= s0 <C ;
ccresult1 = WriteIf( s1,"cu", "");
ccresult2 = WriteIf( s2,"cd", "");
GfxSelectFont("arial", 13, 700 ); GfxSetBkMode( colorBrightGreen );
GfxSetTextColor( ParamColor("Color",colorBrightGreen) );
Hor=Param("Horizontal Position",30,10,1200,1);
Ver=Param("Vertical Position",185,100,50,50);
if ( ccresult2 =="cd")
{
GfxTextOut(""+s0,Hor , Ver );
}
else
GfxSelectFont("arial", 13, 700 ); GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorWhite) );
Hor=Param("Horizontal Position",75,10,1200,1);
Ver=Param("Vertical Position",185,100,50,50);
if ( ccresult1 =="")
{
GfxTextOut(""+s0,Hor , Ver );
}
_SECTION_END();
_SECTION_BEGIN("CMP");
GfxSelectFont("arial", 13, 700 ); GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorWhite) );
Hor=Param("Horizontal Position",120,10,1200,1);
Ver=Param("Vertical Position",185,100,50,50);
GfxTextOut(""+C,Hor , Ver );
_SECTION_END();
_SECTION_BEGIN("buycircle");
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorBlue );
GfxSelectPen( colorBlue, 1 );
if ( ccresult2 =="cd")
{
GfxSelectSolidBrush( ColorRGB(0,255,0) );
}
else
{
GfxSelectSolidBrush( ColorRGB(0,0,94) );
}
GfxCircle( 20,40,7 );
_SECTION_END();
_SECTION_BEGIN("sellcircle");
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorBlue );
GfxSelectPen( colorBlue, 1 );
if ( ccresult1 =="cu")
{
GfxSelectSolidBrush( ColorRGB(255,0,0) );
}
else
{
GfxSelectSolidBrush( ColorRGB(0,0,94) );
}
GfxCircle( 180,40,7 );
_SECTION_END();
Subscribe to:
Posts (Atom)