Live World Indices are Powered by Investing.com - The Leading Financial Portal.
Welcome to www.blueeyeforum.com - India's online discussion forum for Stocks, Commodities and Forex.You are currently viewing our board as a guest, which gives you limited access to view most discussions and other features. By joining our free community you will have access to read all posts, reply to different topics, communicate privately with other members(PM), respond to polls, subscribe topics, upload content and access many other special features. Also as a guest you do not have full access to all the forums and specially, the interactive chat room. Registration is fast, simple and absolutely free. Join today and start sharing your views...Get yourself registered here! ;

Amibroker

Members can post and discuss general topics related to share market in this section. Market related views, News related to Market, Companies and Policy Matters may be discussed here.

Moderators: SOMU, Blueeye Moderator


Amibroker

Postby vpukken » Tue Dec 13, 2011 9:40 am

This thread is dedicated to Amibroker lovers. Please contribute what ever you can. Thanks.
VOLATILITY ALWAYS EQUALS OPPORTUNITY

For this message the author vpukken has received thanks: 4
manish midha (Wed Dec 14, 2011 12:44 am), mirpurig (Wed Jan 25, 2012 1:31 pm), NIHAA (Tue Dec 13, 2011 10:56 pm), SOMU (Sat Dec 17, 2011 8:42 pm)
Rating: 11%
 
User avatar
vpukken
MODERATOR
MODERATOR
 
Posts: 3737
Cash on hand: 5,786.00
Bank: 0.00
Joined: Sat May 21, 2011 9:27 am
Has thanked: 1347 times
Have thanks: 1585 times
Blog: View Blog (1)
Karma: 25

Re: Amibroker

Postby manish midha » Thu Jun 14, 2012 11:58 pm

Code: Select all
//Shared By ************
SetChartBkColor(ParamColor("BackGround Color", ColorRGB( 234,234,234 )));
SetChartOptions(0,chartShowArrows|chartShowDates);
//Settings for Backtester

SetBacktestMode( backtestRegular);
SetOption("InitialEquity", 100000);
SetOption("MaxOpenPositions", 4 ); // This sets maximum number of open positions to 4
SetPositionSize(33, spsPercentOfEquity );
SetOption("AllowSameBarExit", False);
SetOption("AllowPositionShrinking", False);
SetOption("FuturesMode", False);
SetOption("InterestRate",0);
SetOption("PriceBoundChecking",False);
SetOption("CommissionMode",2);
SetOption("CommissionAmount",0.30);
SetOption("ReverseSignalForcesExit",True);
SetOption("UsePrevBarEquityForPosSizing",True);
SetOption("GenerateReport",1);
SetOption("RefreshWhenCompleted",True);


ShortEntryPeriod = Optimize("ShortEntryPeriod",Param("Short Entry ATR Period", 20,1,25,1),1,25,1);
ShortExitPeriod = Optimize("ShortExitPeriod",Param("Short Exit ATR Period", 10,1,20,1),1,20,1);
LongEntryPeriod = Param("Long Entry ATR Period", 55,1,200,1);
LongExitPeriod = Param("Long Exit ATR Period", 20,1,200,1);
mode =ParamToggle("20 Period Entry Used","Yes|No",0);

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");

pctFluctation = 1;

ShortPeakValue = Ref(HHV(H, ShortEntryPeriod), -1);
ShortTroughValue = Ref(LLV(L, ShortEntryPeriod), -1);
ShortLongSL = Ref(LLV(L, ShortExitPeriod), -1);
ShortShortSL = Ref(HHV(H, ShortExitPeriod), -1);
Plot(ShortPeakValue, "Short Peak",colorRed, styleLine);
Plot(ShortTroughValue, "Short Trough",colorBlue, styleLine);
Plot(ShortLongSL, "",colorViolet, styleLine | styleDashed);
Plot(ShortShortSL, "",colorViolet, styleLine | styleDashed);
LongPeakValue = Ref(HHV(H, LongEntryPeriod), -1);
LongTroughValue = Ref(LLV(L, LongEntryPeriod), -1);
LongLongSL = Ref(LLV(L, LongExitPeriod), -1);
LongShortSL = Ref(HHV(H, LongExitPeriod), -1);
Plot(LongPeakValue, "Long Peak",colorDarkRed, styleDashed | styleDots);
Plot(LongTroughValue, "Long Trough",colorDarkBlue, styleDashed | styleDots);
Plot(LongLongSL, "",colorIndigo, styleLine | styleDashed);
Plot(LongLongSL, "",colorIndigo, styleLine | styleDashed);
Plot( C, "Price", colorBlack, styleCandle | styleThick );

Title = EncodeColor(colorBlue)+ FullName() + " - " + Interval(2) + "  - " + Date() +
"\n" +EncodeColor(colorRed) +"Open-"+O+"  "+"High-"+H+"  "+"Low-"+L+"  "+"Close-"+C+"  "+ "Volume= "+ WriteVal(V);

if (mode == 0)

{
Buy = H > ShortPeakValue;
Sell = L < ShortLongSL;
Short = L < ShortTroughValue;
Cover = H > ShortShortSL;

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

N = ATR(ShortEntryPeriod);

}

if (mode == 1)

{
Buy = H > LongPeakValue;
Sell = L < LongLongSL;
Short = L < LongTroughValue;
Cover = H > LongShortSL;

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

N = ATR(LongEntryPeriod);

}

ApplyStop(stopTypeLoss, stopModePoint, 2* N, 0);

PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-25);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-35);                     
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-30);
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorRed, 0, H, Offset=25);
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorOrange, 0,H, Offset=35);                     
PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-30);
PlotShapes(IIf(Sell, shapeStar, shapeNone),colorGold, 0, L, Offset=-15);
PlotShapes(IIf(Cover, shapeStar, shapeNone),colorGold, 0,L, Offset=-15);

GfxSetBkMode( 1 );
GfxSelectFont("Tahoma", Status("pxheight")/C13 );
GfxSetTextAlign( 6 );
GfxSetTextColor( ColorRGB (103,103,103));
GfxTextOut( "Turtle Trading System", Status("pxwidth")/C14, Status("pxheight")/C15 );
GfxSelectFont("Tahoma", Status("pxheight")/C13*0.5 );
GfxSetTextColor( ColorRGB (103,103,103));
GfxTextOut( "By", Status("pxwidth")/C14, Status("pxheight")/C15*2.5 );
GfxSelectFont("Tahoma", Status("pxheight")/C13*0.5 );
GfxSetTextColor( ColorRGB (103,103,103));
GfxTextOut( "www.stockmaniacs.net", Status("pxwidth")/C14, Status("pxheight")/C15*4 );
GfxSelectFont("MS Sans Serif", 10, 500, False, False, 0);

SetTradeDelays(0,0,0,0);
BuyPrice = Close;
SellPrice = Close;
ShortPrice = Close;
CoverPrice = Close;
EARNING MONEY NEVER MAKES ME HAPPY, BUT SPENDING IT DOES!

For this message the author manish midha has received thanks:
nilopra (Fri Jun 15, 2012 1:08 pm)
Rating: 3%
 
User avatar
manish midha
VIP MEMBER
VIP MEMBER
 
Posts: 945
Cash on hand: 738.00
Joined: Mon May 23, 2011 12:43 pm
Has thanked: 836 times
Have thanks: 480 times
Blog: View Blog (0)
Karma: 15

Re: Amibroker

Postby manish midha » Fri Jun 15, 2012 12:01 am

trading the divergence, open it with a price chart.



bear with my illiteracy be members

 ! SOMU wrote:
Post moderated. Don't post stock Call providers link. Plesae take permission from moderators or admins before posting such link in blueeyeforum. Keep the forum clean
EARNING MONEY NEVER MAKES ME HAPPY, BUT SPENDING IT DOES!
User avatar
manish midha
VIP MEMBER
VIP MEMBER
 
Posts: 945
Cash on hand: 738.00
Joined: Mon May 23, 2011 12:43 pm
Has thanked: 836 times
Have thanks: 480 times
Blog: View Blog (0)
Karma: 15

Re: Amibroker

Postby urs_buddy7 » Mon Aug 27, 2012 1:26 am

Can Some one please upload working setup for amibroker?
Thanks in advance for ur gesture.
urs_buddy7
NEWBIE
NEWBIE
 
Posts: 1
Cash on hand: 11.00
Joined: Mon Aug 27, 2012 1:23 am
Has thanked: 0 time
Have thanks: 0 time
Blog: View Blog (0)
Karma: 0

Re: Amibroker

Postby akhan » Thu Aug 30, 2012 7:47 pm

This system utilizes Dual time-frame Momentum and EMA Crossovers ( 5/13 ) on a 5 Minute Chart and is best suited to trade Nifty Futures, though any stock can be traded with this system over any time frame.

I added some signal filter & included Market Profile, Essential Trader Tool, VSA Analysis on the AFL.

Bollinger Band is provided as a guide to get overview of Volatility & 100/200 DMA lines provided as an additional guide to your trading.

Entry Strategy
======
1. In the 30 Minute Chart, the Stochastic should be bullish.
(That is, the fast stochastic line should have crossed over the slow line. It does not matter how long ago the crossover took place, it should just be above the slow line and should be going upwards).

2. In the 5 Minute Chart, the Stochastic should be bullish as well.
(Fast stochastic line should have crossed over the slow line and should be moving upwards. It should not be in overbought condition yet, that is, it should not have crossed 80 yet).

3. The 5 Period EMA crossed over the 13 Period EMA from below and moves upwards.

When all three conditions are met, we buy, placing stop loss at the low of the last bar or the bar to the left of the last bar, whichever is lower.

Stochastic Setting is 8,3,4 for this system.

Exit Strategy
=====
1. When fast Stochastic reverses from it’s upward move, curves downwards and crosses the slow line from above, sell half of the units.

2. If the next bar goes below the low of the previous bar, exit completely, otherwise keep a tight trailing stop loss and enjoy the continuing bull market.

Code: Select all
SetChartOptions(0,chartShowArrows|chartShowDates);
SetChartBkColor(ParamColor("Outer panel",colorDarkOliveGreen)); // color of outer border
SetChartBkGradientFill( ParamColor("Inner panelupper",colorDarkGrey), ParamColor("Inner panel lower",colorDarkOliveGreen));
Plot(C,"Price",IIf(O>C,32,34),64);// bary - swiece
SetBarFillColor(IIf(O>C,24,19));
 
_SECTION_BEGIN("MID MA");
P = ParamField("Price field",-1);
Periods = Param("Periods", 100, 2, 400, 1 );
Plot( MA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style", styleLine | styleNoLabel ) | styleNoRescale );
_SECTION_END();
 
_SECTION_BEGIN("Long MA");
P = ParamField("Price field",-1);
Periods = Param("Periods", 200, 2, 400, 1 );
Plot( MA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style", styleLine | styleNoLabel ) | styleNoRescale );
_SECTION_END();
 
_SECTION_BEGIN("BBands");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 100, 1 );
Width = Param("Width", 2, 0, 10, 0.05 );
Color = ParamColor("Color", colorLightGrey );
Style = ParamStyle("Style", styleLine | styleNoLabel ) | styleNoRescale;;
Plot( bbt = BBandTop( P, Periods, Width ), "BBTop" + _PARAM_VALUES(), Color, Style );
Plot( bbb = BBandBot( P, Periods, Width ), "BBBot" + _PARAM_VALUES(), Color, Style );
PlotOHLC( bbt, bbt, bbb, bbb, "", ColorBlend( Color, colorDarkGrey, 0.9 ), styleNoLabel | styleCloud | styleNoRescale, Null, Null, Null, -1 );
_SECTION_END();
 
_SECTION_BEGIN("Magnified Price");
FS=Param("Font Size",30,11,100,1);
GfxSelectFont("Times New Roman", FS, 700, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorYellow) );
Hor=Param("Horizontal Position",550,1,1200,1);
Ver=Param("Vertical Position",1,1,830,1);
GfxTextOut(""+C, Hor , Ver );
YC=TimeFrameGetPrice("C",inDaily,-1);
DD=Prec(C-YC,2);
xx=Prec((DD/YC)*100,2);
GfxSelectFont("Times New Roman", 11, 700, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor(ParamColor("Color",colorYellow) );
GfxTextOut(""+DD+"  ("+xx+"%)", Hor , Ver+45 );
_SECTION_END();
 
_SECTION_BEGIN("5DMA - Stop & Reverse");
FS=Param("Font Size",30,11,100,1);
GfxSelectFont("Times New Roman", FS, 700, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorBlue) );
 
Hor=Param("Horizontal Position",700,1,1200,1);
Ver=Param("Vertical Position",1,1,830,1);
 
TC=TimeFrameGetPrice("C",inDaily,0);
YYC=TimeFrameGetPrice("C",inDaily,-1);
DFYC=TimeFrameGetPrice("C",inDaily,-2);
DFYC1=TimeFrameGetPrice("C",inDaily,-3);
DFYC2=TimeFrameGetPrice("C",inDaily,-4);
SAR1=Prec((TC+YYC+DFYC+DFYC1+DFYC2)/5,5);
GfxTextOut("SAR="+SAR1, Hor , Ver );
 
SaaR = ParamToggle("SAR","Show|Hide",1);
if(SaaR==1)
{
    Plot (SAR1,"",colorBlue,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
}
_SECTION_END();
 
_SECTION_BEGIN("Pride System");
 
periods = Param( "Periods", 8, 1, 200, 1 );
Ksmooth = Param( "%K avg", 4, 1, 200, 1 );
Dsmooth = Param( "%D avg", 3, 1, 200, 1 );
 
TimeFrameSet(in1Minute * 30);
k30 = StochK( periods , Ksmooth);
d30 = StochD( periods , Ksmooth, DSmooth );
TimeFrameRestore();
 
K = TimeFrameExpand(k30, in1Minute * 30);
D = TimeFrameExpand(d30, in1Minute * 30);
 
Hi = IIf(k > d, k, d);
Lo = IIf(k < d, k, d);
 
periods1 = Param( "Periods1", 8, 1, 200, 1 );
Ksmooth1 = Param( "%K avg", 4, 1, 200, 1 );
Dsmooth1 = Param( "%D avg", 3, 1, 200, 1 );
 
U = StochK( periods1 , Ksmooth1);
T = StochD( periods1 , Ksmooth1, DSmooth1 );
 
x = EMA(Close,5);
y = EMA(Close,13);
 
Buy=((K > D) AND (U > T) AND (U < 75 AND T < 75) AND (x>=y));
Sell=Cross(T,U) OR (T>=U);
 
Longa = Flip(Buy,Sell);
shrta = Flip(Sell,Buy);
 
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
 
Filter = Buy OR Sell;
 
AddTextColumn(FullName(),"Name");
AddColumn( Buy, "BUY" );
AddColumn( Sell, "SELL" );
 
t1= Flip(Buy,Sell);
t2= Flip(Sell,Buy);
 
BPrice=ValueWhen(t1 AND Ref(t1,-1)==0,C,1);
SPrice=ValueWhen(t2 AND Ref(t2,-1)==0,C,1);
 
Short=((D > K) AND (T > U) AND (U > 25 AND T > 25) AND (y>=x));
Cover=Cross(U,T) OR (T<=U);
 
Short = ExRem(Short,Cover);
Cover = ExRem(Cover,Short);
 
PlotShapes(IIf(Short, shapeHollowSmallCircle, shapeNone),colorBrightGreen, 0,H, Offset=30);
PlotShapes(IIf(Cover, shapeHollowSmallCircle, shapeNone),colorRed, 0,L, Offset=-30);
 
GraphXSpace = 5;
 
dist = 2*ATR(10);
dist1 = 3*ATR(10);
 
for( i = 0; i < BarCount; i++ )
{
    if( Buy[i] )
    {
        // PlotText( "\nBuy:" + L[ i ] + "\nT= " + (L[i]*1.005) + "\nSL= " + (L[i]*0.9975), i, L[ i ]-dist[i], colorGreen, colorWhite );
       
        // Signal Display Panel //
 
        BuyStop2 = L[i]*0.9975;
        BuyTP1 = L[i]*1.005;
 
        GfxSetOverlayMode( mode = 0 );
        GfxSelectPen( colorBlue, 3 );
        GfxSelectSolidBrush( colorWhite );
        GfxRoundRect( 05, 210, 185, 265, 15, 15 );
        GfxSetBkMode(1);
        GfxSelectFont( "Arial", 10, 700, False );
        GfxSetTextColor( colorDarkBlue );
        GfxSetTextAlign(0);
 
        GfxTextOut( WriteIf(L[ i ], "Buy Above: "+L[ i ],""), 30, 215);
        GfxTextOut( WriteIf(BuyTP1, "Buy Target: "+(BuyTP1),""), 30, 230);
        GfxTextOut( WriteIf(BuyStop2, "Long SL: "+(BuyStop2),""), 30, 245);
        // END of Signal Display Panel //
    }
    if( Sell[i] )
    {
        // PlotText( "Sell:" + H[ i ] + "\nT= " + (H[i]*0.995) + "\nSL= " + (H[i]*1.0025), i, H[ i ]+dist1[i], colorRed, colorWhite );
       
        // Signal Display Panel //
        SellStop2 = H[i]*1.0025;
        SellTP1 = H[i]*0.995;
       
        GfxSetOverlayMode( mode = 0 );
        GfxSelectPen( colorRed, 3 );
        GfxSelectSolidBrush( colorPink );
        GfxRoundRect( 05, 210, 185, 265, 15, 15 );
        GfxSetBkMode(1);
        GfxSelectFont( "Arial", 10, 700, False );
        GfxSetTextColor( colorDarkBlue );
        GfxSetTextAlign(0);
        GfxTextOut( WriteIf(H[ i ], "Sell Below: "+H[ i ],""), 30, 215);
        GfxTextOut( WriteIf(SellTP1, "Short Target: "+(SellTP1),""), 30, 230);
        GfxTextOut( WriteIf(SellStop2, "Short SL: "+(SellStop2),""), 30, 245);
        // END of Signal Display Panel //
    }
 
}
 
 
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-10);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-20);
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-15);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=10);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=20);
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-15);
AlertIf( Buy, "SOUND C:\\Windows\\Media\\Ringin.wav", "Audio alert", 2 );
AlertIf( Sell, "SOUND C:\\Windows\\Media\\Ringin.wav", "Audio alert", 2 );
_SECTION_END();
 
_SECTION_BEGIN("VSA by Mr.Karthik");
DTL=Param("Linear regression period",60,10,100,10);
wbf=Param("WRB factor",1.5,1.3,2.5,.1);
nbf=Param("NRB factor",0.7,0.3,0.9,0.1);
TL=LinRegSlope(MA(C, DTL),2);
 Vlp=Param("Volume lookback period",30,20,300,10);
Vrg=MA(V,Vlp);
St = StDev(Vrg,Vlp);
Vp3 = Vrg + 3*st;
Vp2 = Vrg + 2*st;;
Vp1 = Vrg + 1*st;;
Vn1 = Vrg -1*st;
Vn2 = Vrg -2*st;
rg=(H-L);
arg=Wilders(rg,30);
wrb=rg>(wbf*arg);
nrb=rg<(nbf*arg);
Vl=V<Ref(V,-1) AND V<Ref(V,-2);
upbar=C>Ref(C,-1);
dnbar=C<Ref(C,-1);
Vh=V>Ref(V,-1) AND Ref(V,-1)>Ref(V,-2);
Cloc=C-L;
x=rg/Cloc;
x1=IIf(Cloc=0,arg,x);
Vb=V>Vrg OR V>Ref(V,-1);
ucls=x1<2;
dcls=x1>2;
mcls=x1<2.2 AND x1>1.8 ;
Vlcls=x1>4;
Vhcls=x1<1.35;
j=MA(C,5);
TLL=LinRegSlope(j,40) ;
Tlm=LinRegSlope(j,15) ;
tls=LinRegSlope(j,5);
mp=(H+L)/2;
 
Pp1=Param("NumberOfDays",30,1,200,1);
Pp2=Param("VolOfDays",15,1,200,1);
 
numDays = Pp1;
dwWideSpread = 1.8;
dwNarrowSpread = 0.8;
dwSpreadMiddle = 0.5;
dwHighClose = 0.7;
dwLowClose = 0.3;
 
volNumDays = Pp2;
dwUltraHighVol = 2;
dwVeryHighVol = 1.75; // was 1.8
dwHighVol = 1.75; // was 1.8
dwmoderateVol = 1.10; // was 1.8
dwLowVol = 0.75; // was 0.8
 
////////////////////////////////////////////////////////////////////////////////////
// Classify each bar...
///////////////////////////////////////////////////////////////////////////////////
 
upBar = C > Ref(C,-1);
downBar = C < Ref(C,-1);
spread = H-L;
avgRange = Sum(spread, numDays) / numDays;
wideRange = spread >= (dwWideSpread * avgRange);
narrowRange = spread <= (dwNarrowSpread * avgRange);
testHighClose = L + (spread * dwHighClose);
testLowClose = L + (spread * dwLowClose);
testCloseMiddle = L + (spread * dwSpreadMiddle);
 
upClose = C > testHighClose;
downClose = C < testLowClose;
middleClose = C >= testLowClose AND C <= testHighClose;
 
avgVolume = EMA(V, volNumDays);
 
highVolume = V > (avgVolume * dwHighVol);
moderateVol= V > (avgVolume * dwmoderateVol);
veryHighVolume = V > (avgVolume * dwVeryHighVol);
ultraHighVolume = V > (avgVolume * dwUltraHighVol);
LowVolume = V < (avgVolume * dwLowVol);
 
////////////////////////////////////////////////////////////////////////////////////
// direction and title
////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////
//
// Basic patterns...
//
////////////////////////////////////////////////////////////////////////////////////
 
upThrustBar = downClose AND H > Ref(H,-1) AND (C == L) AND downClose AND (NOT narrowRange);
noDemandBar = narrowRange AND LowVolume AND upBar AND (NOT upClose);
//noDemandBar = narrowRange AND LowVolume AND upBar AND (V < Ref(V,-1)) AND (V < Ref(V,-2));
noSupplyBar = narrowRange AND LowVolume AND downBar AND (V < Ref(V,-1)) AND (V < Ref(V,-2));
absorption = Ref(downbar, -1) AND Ref(highVolume, -1) AND upBar;
support = Ref(downBar,-1) AND (NOT Ref(downClose,-1)) AND Ref(highVolume,-1) AND upBar;
stoppingVolume = Ref(downBar,-1) AND Ref(highVolume,-1) AND C > testCloseMiddle AND (NOT downBar);
bullishsign=moderateVol+UpThrustBar;//OR moderateVol+upBar;
//rallyEnd = (Ref(highVolume,-1) AND Ref(upBar,-1) AND wideRange AND downBar) OR
// (narrowRange AND highVolume AND H > Ref(HHV(H, 250), -1));
 
 
////////////////////////////////////////////////////////////////////////////////////
//
// Strength and Weakness
//
////////////////////////////////////////////////////////////////////////////////////
 
weakness = upThrustBar OR noDemandBar OR (narrowRange AND (H > Ref(H,-1)) AND highVolume) OR (Ref(highVolume,-1) AND Ref(upBar,-1) AND downBar AND (H < Ref(H,-1)));
 
/////////////////////////////////////////////////////////////////////////////////////////////
 
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 */
 
/* create moving average period parameters */
VolPer = Param("Adjust Vol. MA per.", 34, 1, 255, 1);
ConvPer = Param("Adjust Conv. MA per.", 9, 1, 255, 1);
 
/* create triple exponential moving avearges of separate up and down volume
moving averages */
MAuv = TEMA(uv, VolPer ); mauv1 = Ref(mauv, -1);
MAdv = TEMA(dv, VolPer ); madv1 = Ref(madv, -1);
MAtv = TEMA(V, VolPer );//total volume
 
/* Switch for Horizontal lines indicating current level of positive and
negative volume for ease in comparing to past highs/lows - toggle via
parmameter window */
OscillatorOnly = Param("Show Oscillator Only", 0, 0, 1, 1);
CompareBullVolume = Param("Show Bull Level", 1, 0, 1, 1);
if(CompareBullvolume AND !OscillatorOnly){
//Plot(SelectedValue(MAuv), "", colorGreen, styleLine);
}
 
CompareBearVolume = Param("Show Bear Level", 1, 0, 1, 1);
if(CompareBearVolume AND !OscillatorOnly){
//Plot(SelectedValue(MAdv), "", colorRed, styleLine);
}
 
/* Volume Segment Switches - toggle via parameter window */
bullvolume = Param("Show Bull Volume", 1, 0, 1, 1);
bearvolume = Param("Show Bear Volume", 1, 0, 1, 1);
totalvolume = Param("Show Total Volume", 1, 0, 1, 1);
 
/* plot volume lines and histograms if toggled on: */
bearToFront = Param("Show Bear Vol in Front", 0, 0, 1, 1);
if(bearToFront AND !OscillatorOnly){
//Plot(MAdv, "", colorRed, styleHistogram|styleNoLabel);
}
if(bullvolume AND !OscillatorOnly){
//Plot(MAuv, "Average Bull Volume", colorGreen, styleHistogram|styleNoLabel);
}
if(bearvolume AND !OscillatorOnly){
//Plot(MAdv, "Average Bear Volume", colorRed, styleHistogram|styleNoLabel);
}
if(totalVolume AND !OscillatorOnly){
//Plot(MAtv, "Total Volume", colorWhite, styleHistogram|styleNoLabel);
//Plot(MAtv, "", colorWhite, styleLine);
}
if(bullvolume AND !OscillatorOnly){
//Plot(MAuv, "", colorGreen, styleLine);
}
if(bearvolume AND !OscillatorOnly){
//Plot(MAdv, "", colorRed, styleLine);
}
 
/* better visibility of zero line: */
//Plot(0, "", colorBlue, 1);
 
/* Rise/Fall Convergence variables:  */
Converge = (TEMA(MAuv - MAdv, ConvPer));
Converge1 = Ref(Converge, -1);
ConvergeUp = Converge > Converge1;
ConvergeOver = Converge > 0;
rising = ConvergeUp AND ConvergeOver;
falling = !ConvergeUp AND ConvergeOver;
 
/* Rise/Fall Convergence Oscillator Switch  - toggle via parameter window - (provides a better view of resulting combination of battling bull/bear volume forces) */
convergenceOscillator = Param("Show Oscillator", 0, 0, 1, 1);
if(convergenceOscillator OR OscillatorOnly){
//Plot(Converge, "Bull/Bear Volume Convergence/Divergence", colorViolet,1|styleLeftAxisScale|styleNoLabel|styleThick);
//Plot(0,"", colorYellow, 1|styleLeftAxisScale|styleNoLabel);
}
 
/********************************************************
 Convergence Rise/Fall Shadows:
 
 (provides a more easily visible display of rising and falling  bull/bear
volume convergence) - toggle via parameter window
 
-posiitive Volume exceeding negative Volume: Light shadow
-negative volume exceeding positive volume: dark shadow
-if you use standard gray background - best shadows are:
-my greys: 14 = (216, 216, 216); 15 = (168, 168, 168));
-best substitute? using AB color constants?
-light: colorpalegreen; dark: colorRose;?
-(depends on your color scheme - customize to your tastes)
**********************************************************/
 
/* uncomment if you use my custom color greys: */
riseFallColor = IIf(rising, 14,15); //my custom shadow greys
 
/* comment out if you use my custom color gray shadows: */
/* riseFallColor = IIf(rising, colorPaleGreen,colorRose); */
 
/* Rise/Fall Convergence Plot Switch - toggle via parameter window */
riseFallShadows = Param("Show RiseFallShadows", 0, 0, 1, 1);
if(riseFallShadows){
//Plot(IIf(rising OR falling, 1, 0), "", riseFallColor,styleHistogram|styleArea|styleOwnScale|styleNoLabel);
}
_SECTION_END();
 
_SECTION_BEGIN("Title");
 
dec = (Param("Decimals",2,0,7,1)/10)+1;
 
TimeFrameSet(inDaily);
DayH = LastValue(H);
DayL = LastValue(L);
TimeFrameRestore();
 
if( Status("action") == actionIndicator )
(Title = EncodeColor(colorYellow)+ "Pride System" + "     " + EncodeColor(55)+  Name() + "     " + EncodeColor(32) + Date() + "      " + EncodeColor(5) + "{{INTERVAL}}  " + EncodeColor(55)+ "    Volume = "+ EncodeColor(52)+ WriteVal(V,1) + "\n" +
   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) + "\n" +
   EncodeColor(55)+ "Today`s High= " + EncodeColor(colorBlue) + DayH + EncodeColor(55)+ "     Today`s Low= " + EncodeColor(colorBlue) + DayL +"\n"+
 
EncodeColor(colorPink)+"----------------------------------------"
+"\n"+EncodeColor(07)+"Volume: "+WriteIf(V>Vp2,EncodeColor(colorLime)+"Very High",WriteIf(V>Vp1,EncodeColor(colorLime)+" High",WriteIf(V>Vrg,EncodeColor(colorLime)+"Above Average",
WriteIf(V<Vrg AND V>Vn1,EncodeColor(colorRed)+"Less than Average",WriteIf(V<Vn1,EncodeColor(colorRed)+"Low","")))))
 
+"\n"+EncodeColor(colorYellow)+"Spread: "+WriteIf(rg >(arg*2),EncodeColor(colorLime)+" Wide",WriteIf(rg>arg,EncodeColor(colorLime)+" Above Average",EncodeColor(colorRed)+" Narrow"))
 
+"\n"+(EncodeColor(colorYellow)+"Close: ")+WriteIf(Vhcls,EncodeColor(colorLime)+"Very High",WriteIf(ucls,EncodeColor(colorLime)+"High",WriteIf(mcls,EncodeColor(colorYellow)+"Mid",
WriteIf(dcls,EncodeColor(colorRed)+"Down","Very Low"))))
 
+"\n"+EncodeColor(colorYellow) + "Zone : " +WriteIf(rising , EncodeColor(colorBrightGreen) + "Accumulation",WriteIf(falling , EncodeColor(colorCustom12) + "Distirbution",EncodeColor(colorAqua) + "Flat")) + " "
+"\n"+
EncodeColor(colorYellow) + "Status : " +
WriteIf(Weakness , EncodeColor(colorRed) + "Weak",
WriteIf(stoppingVolume , EncodeColor(colorCustom12) + "StoppingVol",
WriteIf(noSupplyBar , EncodeColor(colorLightOrange) + "NoSupply",
WriteIf(support , EncodeColor(colorLightBlue) + "SupportVol",
WriteIf(noDemandBar , EncodeColor(colorPink) + "NoDemand",
WriteIf(absorption, EncodeColor(colorSkyblue) + "Absorption",
WriteIf(upThrustBar, EncodeColor(colorBlue) + "Upthrust",
WriteIf(bullishsign, EncodeColor(colorPaleGreen) + "STRONG",
EncodeColor(colorTan) + "Neutral")))))))) + " "
+"\n"+EncodeColor(colorPink)+"----------------------------------------"+"\n"+
 
   EncodeColor(colorLime)+WriteIf (Buy , "GO LONG / Reverse Signal at "+C+"  ","")+
   EncodeColor(colorRed)+WriteIf (Sell , "EXIT LONG / Reverse Signal at "+C+"  ","")+"\n"+
   EncodeColor(colorWhite)+WriteIf(Sell , "Total Profit/Loss for the Last Trade Rs."+(C-BPrice)+"","")+
   WriteIf(Buy  , "Total Profit/Loss for the Last trade Rs."+(SPrice-C)+"","")+"\n"+
   WriteIf(Longa AND NOT Buy, "Trade : Long - Entry price Rs."+(BPrice),"")+
   WriteIf(shrta AND NOT Sell, "Trade : Short - Entry price Rs."+(SPrice),"")+"\n"+
   WriteIf(Longa AND NOT Buy, "Current Profit/Loss Rs."+(C-BPrice)+"","")+
   WriteIf(shrta AND NOT Sell, "Current Profit/Loss Rs."+(SPrice-C)+"",""));
 
_SECTION_END();
 
_SECTION_BEGIN("Linear Regression");
Lrc = ParamToggle("Linear Regression Channel","Show|Hide",0);
if(Lrc==1) {
//====================================Start of Linear Regression Code==================================================================================
   
P = ParamField("Price field",-1);
   
Length = 150;
   
Daysback = Param("Period for Liner Regression Line",Length,1,240,1);
shift = Param("Look back period",0,0,240,1);
   
//=============================== Math Formula ========================================================================================================
   
x = Cum(1);
lastx = LastValue( x ) - shift;
aa = LastValue( Ref(LinRegIntercept( p, Daysback), -shift) );
bb = LastValue( Ref(LinRegSlope( p, Daysback ), -shift) );
y = Aa + bb * ( x - (Lastx - DaysBack +1 ) );
   
//==================Plot the Linear Regression Line ====================================================================================================
   
LRColor = ParamColor("LR Color", colorCycle );
LRStyle = ParamStyle("LR Style");
   
LRLine =  IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y, Null );
   
LRStyle = ParamStyle("LR Style");
Angle = Param("Angle", 0.05, 0, 1.5, 0.01);// A slope higher than 0.05 radians will turn green, less than -0.05 will turn red and anything in between will be white.
   
LRLine = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y, Null );
   
Pi = 3.14159265 * atan(1); // Pi
SlopeAngle = atan(bb)*(180/Pi);
   
LineUp = SlopeAngle > Angle;
LineDn = SlopeAngle < - Angle;
   
if(LineUp)
{
Plot(LRLine, "Lin. Reg. Line Up", IIf(LineUp, colorBrightGreen, colorWhite), LRStyle);
}
else
{
Plot(LRLine, "Lin. Reg. Line Down", IIf(LineDn, colorDarkRed, colorWhite), LRStyle);
}
   
//==========================  Plot 1st SD Channel ======================================================================================================
   
SDP = Param("Standard Deviation", 1.5, 0, 6, 0.1);
SD = SDP/2;
   
width = LastValue( Ref(SD*StDev(p, Daysback),-shift) ); //Set width of inside chanels here.
SDU = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y+width , Null ) ;
SDL = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y-width , Null ) ;
   
SDColor = ParamColor("SD Color", colorCycle );
SDStyle = ParamStyle("SD Style");
   
Plot( SDU , "\nUpper Lin Reg", colorWhite,SDStyle ); //Inside Regression Lines
Plot( SDL , "Lower Lin Reg", colorWhite,SDStyle ); //Inside Regression Lines
   
//==========================  Plot 2d SD Channel ========================================================================================================
   
SDP2 = Param("2d Standard Deviation", 2.0, 0, 6, 0.1);
SD2 = SDP2/2;
   
width2 = LastValue( Ref(SD2*StDev(p, Daysback),-shift) ); //Set width of outside chanels here.
SDU2 = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y+width2 , Null ) ;
SDL2 = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y-width2 , Null ) ;
   
SDColor2 = ParamColor("2 SD Color", colorCycle );
SDStyle2 = ParamStyle("2 SD Style");
   
Plot( SDU2 , "Upper Lin Reg", colorWhite,SDStyle2 ); //OutSide Regression Lines
Plot( SDL2 , "Lower Lin Reg", colorWhite,SDStyle2 ); //OutSide Regression Lines
   
Trend = IIf(LRLine > Ref(LRLine,-1),colorGreen,colorRed);//Changes LR line to green if sloping up and red if sloping down.
   
Plot( LRLine , "LinReg", Trend, LRSTYLE );
   
//============================ End Indicator Code ========================================================================================================
}
_SECTION_END();
 
_SECTION_BEGIN("Supertrend");
procedure calcTrend_proc(ATR_Period,tr,ATR_Multiplier,TrendMode,CalcPrice)
{
    global buffer_line_down;
    global buffer_line_up;
    buffer_line_down = Null;
    buffer_line_up = Null;
 
    PHASE_NONE = 0;
    PHASE_BUY = 1;
    PHASE_SELL = -1;
 
    phase=PHASE_NONE;
    band_upper = 0;
    band_lower = 0;
 
    for(i = ATR_Period + 1; i < BarCount; i++)
    {
        band_upper = CalcPrice[i] + ATR_Multiplier * tr[i];
        band_lower = CalcPrice[i] - ATR_Multiplier * tr[i];
 
        if(phase==PHASE_NONE)
        {
            buffer_line_up[i] = CalcPrice[i];
            buffer_line_down[i] = CalcPrice[i];
        }
        if(phase!=PHASE_BUY && Close[i]>buffer_line_down[i-1] && !IsEmpty(buffer_line_down[i-1]))
        {
            phase = PHASE_BUY;
            buffer_line_up[i] = band_lower;
            buffer_line_up[i-1] = buffer_line_down[i-1];
        }
        if(phase!=PHASE_SELL && Close[i]<buffer_line_up[i-1] && !IsEmpty(buffer_line_up[i-1]))
        {
            phase = PHASE_SELL;
            buffer_line_down[i] = band_upper;
            buffer_line_down[i-1] = buffer_line_up[i-1];
        }
        if(phase==PHASE_BUY && ((TrendMode==0 && !IsEmpty(buffer_line_up[i-2])) || TrendMode==1) )
        {
            if(band_lower>buffer_line_up[i-1])
            {
                buffer_line_up[i] = band_lower;
            }
            else
            {
                buffer_line_up[i] = buffer_line_up[i-1];
            }
        }
        if(phase==PHASE_SELL && ((TrendMode==0 && !IsEmpty(buffer_line_down[i-2])) || TrendMode==1) )
        {
            if(band_upper<buffer_line_down[i-1])
            {
                buffer_line_down[i] = band_upper;
            }
            else
            {
                buffer_line_down[i] = buffer_line_down[i-1];
            }
        }
    }
}
 
TrendMode = ParamToggle("TrendMode","Off|On",1);
ATR_Multiplier = Param("ATR_Multiplier",2,0.1,10,0.1);
ATR_Period = Param( "ATR_Period",5,1,20,1);
tr = ATR(ATR_Period);
 
CalcPrice = (H+L)/2;
calcTrend_proc(ATR_Period,tr,ATR_Multiplier,TrendMode,CalcPrice);
 
//Plot(buffer_line_up,"\nUpTrend",ColorRGB(28,134,238),styleThick);
//Plot(buffer_line_down,"\nDownTrend",ColorRGB(205,51,51),styleThick);
 
Plot( 2,"UP Trend",IIf(buffer_line_up,colorGreen,colorDarkOliveGreen),styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );
Plot( 4,"DOWN Trend",IIf(buffer_line_down,colorRed,colorDarkOliveGreen),styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );
_SECTION_END();
 
_SECTION_BEGIN("ESSENTIAL TRADER TOOLS");
 
DayHigh = LastValue(H);
DayLow = LastValue(L);
 
numbars = LastValue(Cum(Status("barvisible")));
hts  = -33.5;
 
// Current Days Hi Lo //
THL = ParamToggle("Todays Hi Lo","Show|Hide",0);
if(THL==1)  {
  isRth = TimeNum() >= 084500 & TimeNum() <= 085959;
  isdRth = TimeNum() >= 084500 & TimeNum() <= 160000;
  aRthL = IIf(isRth, L, 1000000);
  aRthH = IIf(isdRth, H, Null);
  aRthLd = IIf(isdRth, L, 1000000);
  DayH = TimeFrameCompress( aRthH, inDaily, compressHigh );
  DayH = TimeFrameExpand( DayH, inDaily, expandFirst );
  DayL = TimeFrameCompress( aRthLd, inDaily, compressLow );
  DayL = TimeFrameExpand( DayL, inDaily, expandFirst );
  Bars = BarsSince(TimeNum() >= 94500 AND TimeNum() < 095959);//,BarIndex(),1); // AND DateNum()==LastValue(DateNum());
  x0 = BarCount-LastValue(Bars);
  x1 = BarCount-1;
  DayHline=LineArray(x0,LastValue(DayH),x1,LastValue (DayH),0);
  DayLline=LineArray(x0,LastValue(DayL),x1,LastValue (DayL),0);
  DayHlineI = LastValue (DayHline,1);
  DayLlineI = LastValue (DayLline,1);
  Plot(DayHline,"DayH",colorYellow,styleBar|styleNoRescale|styleNoTitle);
  Plot(DayLline,"DayL",colorYellow,styleBar|styleNoRescale|styleNoTitle);
  PlotText(" Day Hi " ,     LastValue(BarIndex())-(numbars/Hts), DayHlineI  +0.05, colorYellow);
  PlotText(" Day Lo " ,     LastValue(BarIndex())-(numbars/Hts), DayLlineI  +0.05, colorYellow);
}
 
//Previous Days HI LO //
 
DayH = TimeFrameGetPrice("H", inDaily, -1);  DayHI = LastValue (DayH,1);// yesterdays high
DayL = TimeFrameGetPrice("L", inDaily, -1);  DayLI = LastValue (DayL,1);    // yesterdays low
DayC = TimeFrameGetPrice("C", inDaily, -1);     // yesterdays close
DayO = TimeFrameGetPrice("O", inDaily);         // current day open
DayH2= TimeFrameGetPrice("H", inDaily, -2);  DayH2I = LastValue (DayH2,1); // Two days before high
DayL2= TimeFrameGetPrice("L", inDaily, -2);  DayL2I = LastValue (DayL2,1);  // Two days before low
DayH3= TimeFrameGetPrice("H", inDaily, -3);  DayH3I = LastValue (DayH3,1);  // Three days before high
DayL3= TimeFrameGetPrice("L", inDaily, -3);  DayL3I = LastValue (DayL3,1);  // Three days before low
 
YHL = ParamToggle("Yesterday HI LO","Show|Hide",0);
if(YHL==1) {
  Plot(DayL,"YL",colorTurquoise,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
  Plot(DayH,"YH",colorTurquoise,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
  PlotText(" YH " ,     LastValue(BarIndex())-(numbars/Hts), DayHI, colorTurquoise);
  PlotText(" YL " ,     LastValue(BarIndex())-(numbars/Hts), DayLI, colorTurquoise);
}
 
TDBHL = ParamToggle("2/3Days before HI LO","Show|Hide",0);
if(TDBHL==1) {
  Plot(DayL2,"2DBL",colorTurquoise,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
  Plot(DayH2,"2DBH",colorTurquoise,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
  Plot(DayL3,"3DBL",colorTurquoise,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
  Plot(DayH3,"3DBH",colorTurquoise,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
  PlotText(" 2DBH " ,   LastValue(BarIndex())-(numbars/Hts), DayH2I, colorTurquoise);
  PlotText(" 2DBL " ,   LastValue(BarIndex())-(numbars/Hts), DayL2I, colorTurquoise);
  PlotText(" 3DBH " ,   LastValue(BarIndex())-(numbars/Hts), DayH3I, colorTurquoise);
  PlotText(" 3DBL " ,   LastValue(BarIndex())-(numbars/Hts), DayL3I, colorTurquoise);
}
 
// Pivot Levels //
PP = (DayL + DayH + DayC)/3;  PPI = LastValue (PP,1);   // Pivot
R1  =  (PP * 2) - DayL;       R1I = LastValue (R1,1);   // Resistance 1
S1  =  (PP * 2)  - DayH;      S1I = LastValue (S1,1);   // Support 1
R2  =  PP + R1 - S1;          R2I = LastValue (R2,1);   // Resistance 2
S2  =  PP - R1 + S1;          S2I = LastValue (S2,1);   // Support 2
R3  =  PP + R2 - S1;          R3I = LastValue (R3,1);   // Resistance 3
S3  =  PP - R2 + S1;          S3I = LastValue (S3,1);   // Support 3
 
ppl = ParamToggle("Pivot Levels","Show|Hide",0);
if(ppl==1)  {
  Plot(PP, "PP",colorYellow,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
  Plot(R1, "R1",colorOrange,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
  Plot(S1, "S1",colorLime,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
  Plot(R2, "R2",colorOrange,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
  Plot(S2, "S2",colorLime,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
  Plot(R3, "R3",colorOrange,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
  Plot(S3, "S3",colorLime,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
 
  PlotText(" Pivot ",  LastValue(BarIndex())-(numbars/Hts), PPI, colorYellow);
  PlotText(" R1 " ,    LastValue(BarIndex())-(numbars/Hts), R1I, colorOrange);
  PlotText(" S1 " ,    LastValue(BarIndex())-(numbars/Hts), S1I, colorLime);
  PlotText(" R2 " ,    LastValue(BarIndex())-(numbars/Hts), R2I, colorOrange);
  PlotText(" S2 " ,    LastValue(BarIndex())-(numbars/Hts), S2I, colorLime);
  PlotText(" R3 " ,    LastValue(BarIndex())-(numbars/Hts), R3I, colorOrange);
  PlotText(" S3 " ,    LastValue(BarIndex())-(numbars/Hts), S3I, colorLime);
}
 
// Mid pivots
 
MIDR1 = (PP+R1)/2;  MIDR1I = LastValue (MIDR1,1);   // Mid Resistance 1
MIDR2 = (R1+R2)/2;  MIDR2I = LastValue (MIDR2,1);   // Mid Resistance 2
MIDR3 = (R2+R3)/2;  MIDR3I = LastValue (MIDR3,1);   // Mid Resistance 3
MIDS1 = (PP+S1)/2;  MIDS1I = LastValue (MIDS1,1);   // Mid Support 1
MIDS2 = (S1+S2)/2;  MIDS2I = LastValue (MIDS2,1);   // Mid Support 2
MIDS3 = (S2+S3)/2;  MIDS3I = LastValue (MIDS3,1);   // Mid Support 3
 
mp = ParamToggle("Mid Pivots","Show|Hide",0);
if(mp==1)  {
  Plot(PP, "PP",colorYellow,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
  Plot(MIDR1, "MIDR1",colorOrange,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
  Plot(MIDR2, "MIDR2",colorOrange,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
  Plot(MIDR3, "MIDR3",colorOrange,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
  Plot(MIDS1, "MIDS1",colorLime,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
  Plot(MIDS2, "MIDS2",colorLime,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
  Plot(MIDS3, "MIDS3",colorLime,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
 
  PlotText(" Pivot" ,    LastValue(BarIndex())-(numbars/Hts), PPI, colorYellow);
  PlotText(" MIDR1" ,    LastValue(BarIndex())-(numbars/Hts), MIDR1I, colorOrange);
  PlotText(" MIDR2" ,    LastValue(BarIndex())-(numbars/Hts), MIDR2I, colorOrange);
  PlotText(" MIDR3" ,    LastValue(BarIndex())-(numbars/Hts), MIDR3I, colorOrange);
  PlotText(" MIDS1" ,    LastValue(BarIndex())-(numbars/Hts), MIDS1I, colorLime);
  PlotText(" MIDS2" ,    LastValue(BarIndex())-(numbars/Hts), MIDS2I, colorLime);
  PlotText(" MIDS3" ,    LastValue(BarIndex())-(numbars/Hts), MIDS3I, colorLime);
}
 
// Camerilla Levels //
 
rg = (DayH - DayL);
 
H5=DayC+1.1*rg;     H5I = LastValue (H5,1);
H4=DayC+1.1*rg/2;   H4I = LastValue (H4,1);
H3=DayC+1.1*rg/4;   H3I = LastValue (H3,1);
H2=DayC+1.1*rg/6;   H2I = LastValue (H2,1);
H1=DayC+1.1*rg/12;  H1I = LastValue (H1,1);
L1=DayC-1.1*rg/12;  L1I = LastValue (L1,1);
L2=DayC-1.1*rg/6;   L2I = LastValue (L2,1);
L3=DayC-1.1*rg/4;   L3I = LastValue (L3,1);
L4=DayC-1.1*rg/2;   L4I = LastValue (L4,1);
L5=DayC-1.1*rg;     L5I = LastValue (L5,1);
 
pcl = ParamToggle("Camerilla Levels","Show|Hide",0);
if(pcl==1)  {
   Plot(H5,"",colorOrange,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
   Plot(H4,"",colorOrange,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
   Plot(H3,"",colorOrange,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
   Plot(H2,"",colorOrange,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
   Plot(H1,"",colorOrange,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
   Plot(L1,"",colorLime,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
   Plot(L2,"",colorLime,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
   Plot(L3,"",colorLime,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
   Plot(L4,"",colorLime,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
   Plot(L5,"",colorLime,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
   PlotText(" H5" ,  LastValue(BarIndex())-(numbars/Hts), H5I, colorOrange);
   PlotText(" H4" ,  LastValue(BarIndex())-(numbars/Hts), H4I, colorOrange);
   PlotText(" H3" ,  LastValue(BarIndex())-(numbars/Hts), H3I, colorOrange);
   PlotText(" H2" ,  LastValue(BarIndex())-(numbars/Hts), H2I, colorOrange);
   PlotText(" H1" ,  LastValue(BarIndex())-(numbars/Hts), H1I, colorOrange);
   PlotText(" L1" ,  LastValue(BarIndex())-(numbars/Hts), L1I, colorLime);
   PlotText(" L2" ,  LastValue(BarIndex())-(numbars/Hts), L2I, colorLime);
   PlotText(" L3" ,  LastValue(BarIndex())-(numbars/Hts), L3I, colorLime);
   PlotText(" L4" ,  LastValue(BarIndex())-(numbars/Hts), L4I, colorLime);
   PlotText(" L5" ,  LastValue(BarIndex())-(numbars/Hts), L5I, colorLime);
}
 
_SECTION_END();
 
_SECTION_BEGIN("MPLite");
//PlotOHLC(O,H,L,C,"Price",IIf(C>O,colorGreen,colorRed),styleCandle);
//Muratt's heikin Treasure!
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 ) );
xDiff = (HaHigh - Halow) * 10000;
barcolor = IIf(HaClose >= HaOpen,colorGreen,colorRed);
//PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "", barcolor, styleCandle );
 
function Lastthursday()
{
 Daysinmonth=IIf(Month()==1 OR Month()==3 OR Month()==5 OR Month()==7 OR Month()==8 OR Month()==10 OR Month()==12,31,30);
 Daysinmonthfeb=IIf(Year()%4 == 0 AND Year()%100!=0,29,28);
 Daysinmonthfinal=IIf(Month()==2,Daysinmonthfeb,Daysinmonth);
 returnvalue=IIf(Daysinmonthfinal-Day()<7 AND DayOfWeek()==4,1,IIf(Daysinmonthfinal-Day()<8 AND DayOfWeek()==3 AND Ref(DayOfWeek(),1)!=4,1,0));
 return returnvalue;
}
 
FirstVisibleBar = Status( "FirstVisibleBar" );
Lastvisiblebar = Status( "LastVisibleBar" );
 
totalVisible=Lastvisiblebar-FirstVisibleBar;
//if(totalVisible<1500){
 
//Den = Param("Density", 1, 0.1, 10, 0.1);
percent=Param("Value Area", 70, 1, 100, 1);
Type=ParamList("Type","Price Profile|Volume Profile");
Period= ParamList("Base","Hourly|Daily|Weekly|Monthly|Lastthursday|Yearly",1);
x_scale=Param("Horizontal_scale", 2, 0, 10, 0.1);
EnMP2= ParamStyle("Style",styleLine|styleNoLabel,maskAll);
styleLines=styleDots;
ViewYvalues= ParamToggle("Show Yesterdays Values", "No|Yes",1);
ViewVlines= ParamToggle("Show Vertical Base Lines", "No|Yes",1);
Viewvalues= ParamToggle("Show Values", "No|Yes",0);
ViewVpoc= ParamToggle("Show Virgin POC", "No|Yes",1);
ViewTPO=ParamToggle("Show TPO Count", "No|Yes",0);
 
if(Period=="Hourly"){
BarsInDay = BarsSince(Hour() != Ref(Hour(), -1));Bot = TimeFrameGetPrice("L", inHourly, 0);Top = TimeFrameGetPrice("H", inHourly, 0);Vol = TimeFrameGetPrice("V", inHourly, 0);
}
if(Period=="Daily" ){//OR Interval()==3600
BarsInDay = BarsSince(Day() != Ref(Day(), -1));Bot = TimeFrameGetPrice("L", inDaily, 0);Top = TimeFrameGetPrice("H", inDaily, 0);Vol = TimeFrameGetPrice("V", inDaily, 0);
}
if(Period=="Weekly" OR Interval()==24 * 3600 ){
BarsInDay = BarsSince(DayOfWeek() < Ref( DayOfWeek(), -1 ));Bot = ValueWhen(Ref(BarsInDay,1)==1 OR BarIndex()>BarCount-2 ,LLV(L,BarsInDay),0);Top =ValueWhen(Ref(BarsInDay,1)==1 OR BarIndex()>BarCount-2,HHV(H,BarsInDay),0);Vol = TimeFrameGetPrice("V", inWeekly, 0);
}
if(Period=="Monthly"  ){
BarsInDay = BarsSince(Month() != Ref(Month(), -1));Bot = TimeFrameGetPrice("L", inMonthly, 0);Top = TimeFrameGetPrice("H", inMonthly, 0);Vol = TimeFrameGetPrice("V", inMonthly, 0);
}
 
if(Period=="Lastthursday"  ){
BarsInDay = BarsSince(Lastthursday()==1 AND Ref(Lastthursday(), -1)==0);Bot = ValueWhen(Ref(BarsInDay,1)==1 OR BarIndex()>BarCount-2 ,LLV(L,BarsInDay),0);Top =ValueWhen(Ref(BarsInDay,1)==1 OR BarIndex()>BarCount-2,HHV(H,BarsInDay),0);Vol = TimeFrameGetPrice("V", inMonthly, 0);
}
 
if(Period=="Yearly"  ){
BarsInDay = BarsSince(Year() != Ref(Year(), -1));Bot = TimeFrameGetPrice("L", inYearly, 0);Top = TimeFrameGetPrice("H", inYearly, 0);Vol = TimeFrameGetPrice("V", inYearly, 0);
}
 
Range =  Top-Bot;
coverage=LastValue(ATR(10));
 
den=(coverage/10);
 
//multiplier=IIf(round(totalVisible)>500,IIf(round(totalVisible)>1000,3,2),1);
 
multiplier=IIf(round(totalVisible)/300<1,1,round(totalVisible)/300);
 
 
if(ViewVlines==1)
{
Plot(BarsInDay==0, "", ParamColor("Base Line Color",colorDarkGrey), styleHistogram | styleOwnScale | styleLine | styleNoLabel);
}
 
 
relTodayRange = 0;
x=0;
basey=0;
basex=0;
newday=0;
total=0;
shiftup=0;
shiftdn=0;
Line=Null;
Voloumeunit=0;
 
 
for (  i = FirstVisibleBar; i <Lastvisiblebar AND i<BarCount-1 ; i++  )
{
    if(BarsInDay[i]==0)
    {t=BarsInDay[i-1];
 
 
 
        //////////////////////////////////
poc=0;pocj=0;
midrange = int(relTodayRange/2)+1;
 
 
for (j=1; j<= relTodayRange+1 ; j++)
    {
        if(poc < x[j])
        {
        poc=x[j]; pocj=j;}
        else if(poc == x[j])
            {
            if (abs(midrange-j)< abs(midrange-pocj)){
            poc = x[j]; pocj = j;
            }
        }
   
    }
 
for ( n = 1; n <= relTodayRange; n++ )
    {
        total[n]=x[n]+total[n-1];
    }
 
Value_area=(total[relTodayRange]*percent)/100;
 
 
for ( a = 1; a <= relTodayRange; a++ )
{
    if(pocj-a>0 AND pocj+a<relTodayRange)
    {
        if(poc+total[pocj+a]-total[pocj]+(total[pocj]-poc)-total[pocj-(a+1)]>=Value_area) {shiftup=a; shiftdn=a; break;}
        }   
        else if(pocj-a<1 )
        {
        if(poc+total[pocj+a]-total[pocj]+(total[pocj]-poc)>=Value_area){shiftup=a; shiftdn=pocj; break;}     
        }
        else if(pocj+a>relTodayRange )
        {
        if(poc+total[relTodayRange]-total[pocj]+(total[pocj]-poc)-total[pocj-(a+1)] >=Value_area){shiftup=floor(relTodayRange)-pocj; shiftdn=a+1; break;}       
    }
}
 
 
if(ViewVpoc==1)
{
Virginpoc=basey+pocj*den;
newi=0;
for( j = i+1; j <= (BarCount - 1) ; j++ )
if( L[j] < Virginpoc AND H[j]>Virginpoc )
{newi=j;break;}
else{newi=BarCount;}
vishycolor=IIf(BarCount%2==0,colorRed,colorBlue);
Plot(LineArray(basex[i],basey+pocj*den,newi,basey+pocj*den),"",vishycolor,styleLine|styleNoRescale);
//Plot(LineArray(basex[i],basey+pocj*den,newi,basey+pocj*den),"",colorYellow,styleLine|styleNoRescale);
}
 
Vah = LineArray(baseX[i], baseY+(pocj+shiftup)*den, i, baseY+(pocj+shiftup)*den);
Val = LineArray(baseX[i], baseY+(pocj-shiftdn)*den, i, baseY+(pocj-shiftdn)*den);
pocline=LineArray(basex,basey+pocj*den,basex[i]+poc,basey+pocj*den);
 
//Plot(Vah,"",ParamColor("Color_VAH_Line", colorBlueGrey),styleLine|styleNoRescale);
//Plot(Val,"",ParamColor("Color_VAL_Line", colorBlueGrey),styleLine|styleNoRescale);
 
Vahn = LineArray(i, baseY+(pocj+shiftup)*den, i+t, baseY+(pocj+shiftup)*den);
pocn = LineArray(i, baseY+(pocj)*den, i+t, baseY+(pocj)*den);
Valn = LineArray(i, baseY+(pocj-shiftdn)*den, i+t, baseY+(pocj-shiftdn)*den);
 
Plot(pocline,"",ParamColor("Color_POC_Line",colorYellow),styleLine|styleNoRescale|styleNoLabel);
 
if(ViewYvalues==1)
{
Plot(Vahn,"",ParamColor("YVAH",colorBrightGreen),styleDashed|styleNoRescale);
Plot(Valn,"",ParamColor("YVAL",colorYellow),styleDashed|styleNoRescale);
Plot(pocn,"",ParamColor("YPOC",colorDarkRed),styleDashed|styleNoRescale);
 
}
//PlotOHLC(Vahn,Vahn,Valn,Valn,"",colorPink,styleCloud|styleOwnScale);
 
 
if(ViewTPO==1)
{
nnn=HHV(H,BarsInDay);
PlotText(""+(total[relTodayRange]-total[pocj]),basex[i],nnn[i],colorLightGrey);
PlotText(""+(total[pocj-1]),basex[i],basey-den,colorLightGrey);
}
 
if(Viewvalues==1)
{
PlotText(""+((basey+pocj*den)),baseX[i],basey+pocj*den,colorWhite,colorDarkGrey);
PlotText(""+((baseY+(pocj+shiftup)*den)),baseX[i],baseY+(pocj+shiftup)*den,colorWhite,colorDarkGrey);
PlotText(""+((baseY+(pocj-shiftdn)*den)),baseX[i],baseY+(pocj-shiftdn)*den,colorWhite,colorDarkGrey);
}
 
 
for (p = 0; p <= relTodayRange+1; p=p+multiplier)
{
    if(P>0){
    line = LineArray(baseX, baseY+(p)*Den, baseX+x[p], baseY+(p)*Den);
 
    }
     
    Plot(line,"",IIf(p>(pocj+shiftup),ParamColor("Color_Above_VA",  colorDarkRed),IIf(p<=(pocj+shiftup)AND p>=(pocj-shiftdn),ParamColor("Color_VA", colorDarkBlue),ParamColor("Color_Below_VA",   colorDarkRed))) , EnMP2);
 
     
}
 
Plot(pocline,"",ParamColor("Color_POC_Line",colorDarkRed),styleLine|styleNoRescale);
 
///////////////////
 
basex=0;
        x=0;
        Basex=i;
        baseY=Bot[i];
        relTodayRange=Range[i]/Den;
        Voloumeunit=Vol[i]/LastValue(BarsInDay);
 
    }
 
    for (j=0; j<= relTodayRange ; j++)
    {   
        if (L[i] <= Bot[i]+j*Den AND H[i] >= Bot[i]+j*Den  )
        {
            if(Type=="Price Profile"){x[j]=(x[j])+x_scale;}
            else if(Type=="Volume Profile"){x[j]=x[j]+round(V[i]/Voloumeunit)+1;}
        }
    }
}
 
     
//////////////////////////////////
poc=0;pocj=0;
midrange = int(relTodayRange/2)+1;
 
for (j=1; j<= relTodayRange+1 ; j++)
    {
        if(poc < x[j])
        {
        poc=x[j]; pocj=j;}
        else if(poc == x[j])
            {
            if (abs(midrange-j)< abs(midrange-pocj)){
            poc = x[j]; pocj = j;
            }
        }
   
    }
 
for ( n = 1; n <= relTodayRange; n++ )
    {
        total[n]=x[n]+total[n-1];
    }
 
Value_area=(total[relTodayRange]*percent)/100;
 
 
for ( a = 1; a <= relTodayRange; a++ )
{
    if(pocj-a>0 AND pocj+a<relTodayRange)
    {
        if(poc+total[pocj+a]-total[pocj]+(total[pocj]-poc)-total[pocj-(a+1)]>=Value_area) {shiftup=a; shiftdn=a; break;}
        }   
        else if(pocj-a<1 )
        {
        if(poc+total[pocj+a]-total[pocj]+(total[pocj]-poc)>=Value_area){shiftup=a; shiftdn=pocj; break;}     
        }
        else if(pocj+a>relTodayRange )
        {
        if(poc+total[relTodayRange]-total[pocj]+(total[pocj]-poc)-total[pocj-(a+1)] >=Value_area){shiftup=floor(relTodayRange)-pocj; shiftdn=a+1; break;}       
    }
}
 
Vah = LineArray(baseX[i], baseY+(pocj+shiftup)*den, i, baseY+(pocj+shiftup)*den);
Val = LineArray(baseX[i], baseY+(pocj-shiftdn)*den, i, baseY+(pocj-shiftdn)*den);
pocline=LineArray(basex,basey+pocj*den,basex[i]+poc,basey+pocj*den);
 
if(ViewTPO==1)
{
PlotText(""+(total[relTodayRange]-total[pocj]),basex[i],top[i],colorLightGrey);
PlotText(""+(total[pocj-1]+x_scale),basex[i],basey-den,colorLightGrey);
}
 
if(Viewvalues==1)
{
PlotText(""+((basey+pocj*den)),baseX[i],basey+pocj*den,colorWhite,colorDarkGrey);
PlotText(""+((baseY+(pocj+shiftup)*den)),baseX[i],baseY+(pocj+shiftup)*den,colorWhite,colorDarkGrey);
PlotText(""+((baseY+(pocj-shiftdn)*den)),baseX[i],baseY+(pocj-shiftdn)*den,colorWhite,colorDarkGrey);
}
 
for (p = 0; p <= relTodayRange+1; p=p+multiplier)
{
    line = LineArray(baseX, baseY+p*Den, baseX+x[p], baseY+p*Den);
 
    Plot(line,"",IIf(p>(pocj+shiftup),ParamColor("Color_Above_VA",  colorGrey40),IIf(p<=(pocj+shiftup)AND p>=(pocj-shiftdn),ParamColor("Color_VA", colorBlueGrey),ParamColor("Color_Below_VA",colorGrey40))),EnMP2);
     
    Plot(pocline,"",ParamColor("Color_POC_Line",colorYellow),styleLine|styleNoRescale|styleNoLabel);
}
_SECTION_END();
Ignore whatever tries 2 stop U & move on,keep faith on your Lord for ur success!
User avatar
akhan
MODERATOR
MODERATOR
 
Posts: 1658
Images: 0
Cash on hand: 1,916.00
Bank: 0.00
Joined: Sat Dec 17, 2011 2:27 pm
Has thanked: 27 times
Have thanks: 170 times
Blog: View Blog (1)
Real Name: AKHAN
Gender: Male
Karma: 3

Re: Amibroker

Postby akhan » Thu Aug 30, 2012 8:11 pm

101 % Profit formula check this out!
Code: Select all
SetChartOptions(2,chartShowArrows|chartShowDates|chartWrapTitle);
SetChartOptions(0,chartShowArrows|chartShowDates);
 
 
//GfxGradientRect( 180, 30, 1759, 735, ColorRGB(40,40,40), ColorRGB(0,0,40) );
GfxSetOverlayMode(1);
GfxSelectPen( ColorRGB(150,0,0), 1 );
GfxSelectSolidBrush( ColorRGB(0,0,40) );
GfxRectangle( 0,750, 1807, 35 );
 
GfxSelectPen( ColorRGB(150,0,0), 2 );
GfxSelectSolidBrush( ColorRGB(65,65,65) );
GfxPolygon(250,200,200,250,250,20,200,50);
 
//GfxSelectPen( ColorRGB(125,0,0), 1 );
//GfxSelectSolidBrush( ColorRGB(0,0,40) );
//GfxRectangle( 10,100, 190, 160 );
 
GfxSelectPen( ColorRGB(0,0,0), 1 );
GfxSelectSolidBrush( ColorRGB(0,0,0) );
//GfxSetTextAlign( 250 );// center alignment
 
GfxSetOverlayMode(1);
GfxSelectFont("Times New Roman", 30, 400, True );
GfxSetTextColor( ColorRGB( 105, 105, 105 ) );
GfxSetBkMode(0); // transparent
GfxTextOut("Pathfinder", 15 , 35 );
 
 
_SECTION_BEGIN("Flower");
si=Param("Zoom/In Out",5,-50,100,1);
GraphXSpace=si; 
 
r1 = Param( "ColorFast avg", 5, 2, 200, 1 );
r2 = Param( "ColorSlow avg", 10, 2, 200, 1 );
r3 = Param( "ColorSignal avg", 5, 2, 200, 1 );
 
m1=MACD(r1,r2);
s1=Signal(r1,r2,r3);
mycolor=IIf(m1<0 AND m1>s1, ColorRGB(155,155,155),IIf(m1>0 AND m1>s1,ColorRGB(0,125,0),IIf(m1>0 AND m1<s1,ColorRGB(180,30,160),ColorRGB(100,0,0))));
 
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);
barColor=IIf(Close>Open,ColorRGB(0,245,0),ColorRGB(255,0,0));
 
//Ctmpl = E_TSKP_COLORTMPL(Open,High,Low,Close,Volume);
total = 0;
//total = total  + IIf(tskp_colortmplcnd0 > 0, 1, -1);
//total = total  + IIf(tskp_colortmplcnd1 > 0, 1, -1);
//total = total  + IIf(tskp_colortmplcnd2 > 0, 1, -1);
//total = total  + IIf(tskp_colortmplcnd3 > 0, 1, -1);
//total = total  + IIf(tskp_colortmplcnd4 > 0, 1, -1);
//total = total  + IIf(tskp_colortmplcnd5 > 0, 1, -1);
//total = total  + IIf(tskp_colortmplcnd6 > 0, 1, -1);
//total = total  + IIf(tskp_colortmplcnd7 > 0, 1, -1);
//total = total  + IIf(tskp_colortmplcnd8 > 0, 1, -1);
 
 
for( i = 0; i < BarCount; i++ )
{
 
    if( total[i] >= 5 )
        Color[i] = colorLime;
    else if(  total[i] <= -5 )
        Color[i] = colorRed;
    else
        Color[i] = colorWhite;
}
 
Candle=ParamList("Candle","Modified Candlestick,Modified Heikin Ashi,Normal Candlestick",1);
if(Candle=="Modified Candlestick")
{
ColorHighliter = myColor;
SetBarFillColor( ColorHighliter );
Plot (Close,"- Modified Candlestick", Color,ParamStyle( "Style", styleCandle|styleLine | styleThick, maskAll));
}
if(Candle=="Modified Heikin Ashi")
{
ColorHighliter = myColor;
SetBarFillColor( ColorHighliter );
PlotOHLC( IIf(flowerOpen<flowerClose, flowerOpen, flowerClose),flowerHigh,flowerLow,IIf(flowerOpen<flowerClose, flowerClose, flowerOpen), "Modified Heikin Ashi", Color, styleCandle|styleLine);
}
if(Candle=="Normal Candlestick")
{
//ColorHighliter = myColor;
//SetBarFillColor( ColorHighliter );
PlotOHLC(O,H,L,C,"Normal Candlestick",barcolor,styleCandle|styleLine);
}
 
 
_SECTION_END();
 
 
 
_SECTION_BEGIN("Resistance");
supres=ParamToggle("Sup_Res","No|Yes",1);
if(supres)
{
 
Prd1=Param("Res_Period1",2,0,200,1);
                   
test   = TEMA  ( High , Prd1 ) ;   
 
PK = test > Ref(test,-1) AND Ref(test,1) < High;//Peak
PKV0 = ValueWhen(PK,flowerHigh,0);//PeakValue0
PKV1 = ValueWhen(PK,flowerHigh,1);//PeakValue1
PKV2 = ValueWhen(PK,flowerHigh,2);//PeakValue2
 
MPK = PKV2 < PKV1 AND PKV1 > PKV0 ;//MajorPeak
 
RsColor=ParamColor("ResistColor",ColorRGB(225,0,0));
BrCount=Param("ResistBarLength",8,1,500,1);
for (i=0;i<BarCount-BrCount;i++) //hide the line except most recent 10 bars
{
    RsColor[i] = colorBlack;
}
 
 
 
MPKV = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, PKV1,1); //MajorPeakValue
MPKD = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, DateNum(),1); //MajorPeakDate
SD = IIf(DateNum() < LastValue(MPKD,lastmode = True ), Null, LastValue(MPKV,Lastmode = True));//SelectedDate
Plot(SD, "Resist1",  ColorRGB(200,0,0),ParamStyle("ResStyle1",styleDashed|styleNoTitle,maskAll));
 
RsColor2=ParamColor("Resist2Color",ColorRGB(225,0,0));
BrCount=Param("Resist2BarLength",8,1,500,1);
for (i=0;i<BarCount-BrCount;i++) //hide the line except most recent 10 bars
{
    RsColor2[i] = colorBlack;
}
 
MPKV2 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, PKV1,2); //MajorPeakValue
MPKD2 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, DateNum(),2); //MajorPeakDate
SD2 = IIf(DateNum() < LastValue(MPKD2,lastmode = True ), Null, LastValue(MPKV2,Lastmode = True));//SelectedDate
Plot(SD2, "Resist2", RsColor2,ParamStyle("ResStyle2",styleDashed|styleNoTitle,maskAll));
 
RsColor3=ParamColor("Resist3Color",ColorRGB(225,0,0));
BrCount=Param("Resist3BarLength",8,1,500,1);
for (i=0;i<BarCount-BrCount;i++) //hide the line except most recent 10 bars
{
    RsColor3[i] = colorBlack;
}
 
 
MPKV3 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, PKV1,3); //MajorPeakValue
MPKD3 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, DateNum(),3); //MajorPeakDate
SD3 = IIf(DateNum() < LastValue(MPKD3,lastmode = True ), Null, LastValue(MPKV3,Lastmode = True));//SelectedDate
Plot(SD3, "Resist3", RsColor3,ParamStyle("ResStyle3",styleThick|styleDots|styleNoTitle,maskAll));
 
 
 
_SECTION_END();
 
 
_SECTION_BEGIN("Support");
 
Prd2=Param("Sup_Period1",2,0,200,1);
                   
test2   = TEMA ( Low , Prd2 ) ;   
 
SP = Ref(test2,1) > Low AND test2 < Ref(test2,-1);//Peak
SPV0 = ValueWhen(SP,flowerLow,0);//PeakValue0
SPV1 = ValueWhen(SP,flowerLow,1);//PeakValue1
SPV2 = ValueWhen(SP,flowerLow,2);//PeakValue2
 
MSP = SPV2 > SPV1 AND SPV1 < SPV0 ;//MajorPeak
 
SpColor=ParamColor("SupColor",ColorRGB(0,225,0));
BrCount=Param("SupBarLength",8,1,500,1);
for (i=0;i<BarCount-BrCount;i++) //hide the line except most recent 10 bars
{
    SpColor[i] = colorBlack;
}
 
 
MSPV = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, SPV1,1);
MSPD = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, DateNum(),1);
SD = IIf(DateNum() < LastValue(MSPD,lastmode = True ), Null, LastValue(MSPV,Lastmode = True));
Plot(SD,"Support1",SpColor,ParamStyle("SupportLine1",styleDashed|styleNoTitle,maskAll));
 
SpColor2=ParamColor("SupColor2",ColorRGB(0,200,0));
BrCount=Param("Sup2BarLength",8,1,500,1);
for (i=0;i<BarCount-BrCount;i++) //hide the line except most recent 10 bars
{
    SpColor2[i] = colorBlack;
}
 
 
MSPV2 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, SPV1,2);
MSPD2 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, DateNum(),2);
SD2 = IIf(DateNum() < LastValue(MSPD2,lastmode = True ), Null, LastValue(MSPV2,Lastmode = True));
Plot(SD2,"Support2",Spcolor2,ParamStyle("SupportLine2",styleDashed|styleNoTitle,maskAll));
 
SpColor3=ParamColor("SupColor3",ColorRGB(0,175,0));
BrCount=Param("Sup3BarLength",8,1,500,1);
for (i=0;i<BarCount-BrCount;i++) //hide the line except most recent 10 bars
{
    SpColor3[i] = colorBlack;
}
 
 
MSPV3 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, SPV1,3);
MSPD3 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, DateNum(),3);
SD3 = IIf(DateNum() < LastValue(MSPD3,lastmode = True ), Null, LastValue(MSPV3,Lastmode = True));
Plot(SD3,"Support3",SpColor3,ParamStyle("SupportLine3",styleThick|styleDots|styleNoTitle,maskAll));
}
_SECTION_END();
 
 
_SECTION_BEGIN("TSKPPUSHDOTS");
if(Candle=="Modified Heikin Ashi")
{
//Combo = E_TSKPCOMBO(Open,High,Low,Close,Volume);
//NewUpDown = E_TSKPNEWUPDOWN(Open,High,Low,Close,Volume);
//UpDown7 = 0.5*(High+Low) - E_TSKPSTOPLINE(High,Low,Close);
//r=Param("Red",0,0,255,1);
//g=Param("Green",0,0,255,1);
//b=Param("Blue",0,0,255,1);
 
if(Candle=="Normal Candlestick" OR Candle=="Modified Candlestick")
{
PlotShapes( IIf( ((Combo>0) AND (NewUpDown > 0) AND (UpDown7 > 0)),shapeSmallCircle,shapeNone), ColorRGB(0,125,255),0, Low, -8);
PlotShapes( IIf( ((Combo<0) AND (NewUpDown < 0) AND (UpDown7 < 0)),shapeSmallCircle,shapeNone), ColorRGB(225,0,0),0, High, 8);
}
 
else
{
//PlotShapes( IIf( ((Combo>0) AND (NewUpDown > 0) AND (UpDown7 > 0)),shapeSmallCircle,shapeNone), ColorRGB(0,255,0),0, flowerlow, -12);
//PlotShapes( IIf( ((Combo<0) AND (NewUpDown < 0) AND (UpDown7 < 0)),shapeSmallCircle,shapeNone), ColorRGB(255,0,0),0, flowerhigh, 12);
}
}
_SECTION_END();
 
Title = StrFormat("\\c02 {{NAME}} | {{DATE}} | Open : %g | High : %g | Low : %g | Close : %g | Change = %.1f%% | Volume = " +WriteVal( V, 1.0 ) +", {{VALUES}}",
O, H, L, C, SelectedValue( ROC( C, 1 )) );
 
 
_SECTION_BEGIN("TSKPPIVOT");
 
if(Candle=="Modified Heikin Ashi")
{
CHiPr = 0;
CLoPr = 9999999;
blsLong = 0;
PrevCOBar = 0;
NumBars = 0;
PrePP = 0;
PrevLowVal = 9999999;
BuySig = 0;
blsShort = 0;
PrevHiVal = 0;
blsNewCO = 0;
BarDif   = 0;
 
//KPA900Val = E_TSKPA900(Close);
//KPAutoStopVal = E_TSKPAUTOSTOP(High,Low,Close);
 
// -- Create 0-initialized arrays the size of barcount
aHPivs = flowerHigh - flowerHigh;
aLPivs = flowerLow - flowerLow;
aHiVal = flowerHigh - flowerHigh;
aLoVal = flowerLow - flowerLow;
 
 
//Ctmpl = E_TSKPCOLORTMPL(Open,High,Low,Close,Volume);
sctotal = 0;
//sctotal = sctotal  + IIf(tskp_colortmplcnd0 > 0, 1, -1);
//sctotal = sctotal  + IIf(tskp_colortmplcnd1 > 0, 1, -1);
//sctotal = sctotal  + IIf(tskp_colortmplcnd2 > 0, 1, -1);
//sctotal = sctotal  + IIf(tskp_colortmplcnd3 > 0, 1, -1);
//sctotal = sctotal  + IIf(tskp_colortmplcnd4 > 0, 1, -1);
//sctotal = sctotal  + IIf(tskp_colortmplcnd5 > 0, 1, -1);
//sctotal = sctotal  + IIf(tskp_colortmplcnd6 > 0, 1, -1);
//sctotal = sctotal  + IIf(tskp_colortmplcnd7 > 0, 1, -1);
//sctotal = sctotal  + IIf(tskp_colortmplcnd8 > 0, 1, -1);
 
 
for (curBar=0; curBar < BarCount-1; curBar++)
{
 
    if ( curBar == 0 )
    {
        CHiPr = flowerHigh[curBar];
        CHiBar = curBar;
        CLoPr = flowerLow[curBar];
        CLoBar = curBar;
        blsLong = 0;
        blsShort = 0;
        blsNewCO = 0;
        PrePP = 0;
        PrevCOBar = 0;
        PrevHiVal = flowerHigh[curBar];
        PrevLowVal = flowerLow[curBar];
        BuySig = 0;
        SellSig = 0;
        blsLL  = 0;
    }
 
    if (flowerHigh[CurBar] >= CHiPr) {
        CHiPr = flowerHigh[CurBar];
        ChiBar = CurBar;
    }
 
    if (flowerLow[CurBar] <= CLoPr) {
        CLoPr = flowerLow[CurBar];
        CLoBar = CurBar;
    }
 
    //if ( (KPA900Val[curBar] >= KPAutoStopVal[curbar]) AND (PrePP != -1) AND (blsLong != 1) ){
        BarDif = CurBar - PrevCOBar;
        if (BarDif >= NumBars) {
            blsLong = 1;
            blsShort = 0;
            blsNewCO = 1;
            PrevCOBar = CurBar;
        }
    }
 
    //if ( (KPA900Val[curBar] <= KPAutoStopVal[curbar]) AND (PrePP != 1) AND (blsShort != 1) ){
        BarDif = CurBar - PrevCOBar;
        if (BarDif >= NumBars) {
            blsLong = 0;
            blsShort = 1;
            blsNewCO = 1;
            PrevCOBar = CurBar;
        }
    }
 
    if ( (blsNewCO == 1) AND (sctotal[CurBar] >= 5) AND (blsLong == 1) ) {
        LVal = CurBar - CLoBar;
        for (j= CLoBar-1; j <= CLoBar+1; j++)
        {
            if (j >=0) {
                aLPivs[j] = 1;
                aLoVal[j] = CLoPr;
            }
        }
        PrePP = -1;
        blsNewCO = 0;
        CHiPr = flowerHigh[CurBar];
        CHiBar = CurBar;
        CLoPr = flowerLow[Curbar];
        CLoBar = CurBar;
        }
       // else if ((blsNewCO == 1) AND (sctotal[CurBar] <= -5) AND (blsShort == 1) ) {
        HVal = CurBar - CHiBar;
        for (j= CHiBar-1; j <= CHiBar+1; j++)
        {       
            if (j >=0) {
                aHPivs[j] = 1;
                aHiVal[j] = CHiPr;
            }
        }
        PrePP = 1;
        blsNewCO = 0;
        CHiPr = flowerHigh[CurBar];
        CHiBar = CurBar;
        CLoPr = flowerLow[Curbar];
        CLoBar = CurBar;
        //}
//}
 
PlotShapes(IIf(aHPivs == 1, 21,shapeNone), ColorRGB(255,0,145),0,   aHiVal,Offset = 20);
PlotShapes(IIf(aHPivs == 1, 15,shapeNone), ColorRGB(200,50,75),0,   aHiVal,Offset = 20);
PlotShapes(IIf(aLPivs == 1, 21,shapeNone), ColorRGB(0,125,225),0, aLoVal, Offset = -20);
PlotShapes(IIf(aLPivs == 1, 15,shapeNone), ColorRGB(0,125,255),0, aLoVal, Offset = -20);
//}
 
 
_SECTION_END();
 
 
 
_SECTION_BEGIN("TSKPMoMo");
 
if(Candle=="Modified Heikin Ashi")
{
blsLong = 0;
//KPStopLine = E_TSKPSTOPLINE(High,Low,Close);
// tskp_upsell, tskp_triggerline, tskp_triggerlinevma
//sw = E_TSKPUPSELL(Open,High,Low,Close,Volume);
//KPTriggerLine = tskp_triggerline;
//KPFast3Val = IIf((E_TSKPFAST3(Open,High,Low,Close,Volume)> 0),1, -1);
//tskp_fast2val1, tskp_fast2val2
//dummy = E_TSKPFAST2(Open,High,Low,Close,Volume);
//KPFast2Val = IIf ((tskp_fast2val1 > 0),1,-1);
 
 
 
//Ctmpl = E_TSKPCOLORTMPL(Open,High,Low,Close,Volume);
sctotal = 0;
//sctotal = sctotal  + IIf(tskp_colortmplcnd0 > 0, 1, -1);
//sctotal = sctotal  + IIf(tskp_colortmplcnd1 > 0, 1, -1);
//sctotal = sctotal  + IIf(tskp_colortmplcnd2 > 0, 1, -1);
//sctotal = sctotal  + IIf(tskp_colortmplcnd3 > 0, 1, -1);
//sctotal = sctotal  + IIf(tskp_colortmplcnd4 > 0, 1, -1);
//sctotal = sctotal  + IIf(tskp_colortmplcnd5 > 0, 1, -1);
//sctotal = sctotal  + IIf(tskp_colortmplcnd6 > 0, 1, -1);
//sctotal = sctotal  + IIf(tskp_colortmplcnd7 > 0, 1, -1);
//sctotal = sctotal  + IIf(tskp_colortmplcnd8 > 0, 1, -1);
 
// tskp_mediumma,tskp_mediumup,tskp_mediumdown
//dummy = E_TSKPMEDIUM(Close);
//KPMediumUP = tskp_mediumup;
//KPMediumDwn = tskp_mediumdown;
//KPMediumMA = tskp_mediumma;
 
// -- Create 0-initialized arrays the size of barcount
aHPivs = H - H;
aLPivs = L - L;
aHiVal = H - H;
aLoVal = L - L;
 
 
for (curBar=5; curBar < BarCount-1; curBar++)
{
 
 
    if( (blsLong == -1) OR (blsLong == 0))
      {
       if ((sctotal[CurBar]  >= 5) AND (KPMediumUP[CurBar]  > KPMediumMA[CurBar] ) AND (KPFast3Val[CurBar]  == 1) AND
        (KPFast2Val[CurBar]  == 1) AND (KPTriggerLine[CurBar]  >= KPStopLine[CurBar] ))
       {
         blsLong = 1;
          aLPivs[CurBar] = 1;
          aLoVal[CurBar] = Low[CurBar];
       }
    }
 
    if( (blsLong == 1) OR (blsLong == 0))
      {
       if ((sctotal[CurBar]  <= -5) AND (KPMediumDwn[CurBar]  < KPMediumMA[CurBar] ) AND (KPFast3Val[CurBar]  == -1) AND
       (KPFast2Val[CurBar]  == -1) AND (KPTriggerLine[CurBar]  <= KPStopLine[CurBar] ))
       {
         blsLong = -1;
         aHPivs[Curbar] = 1;
          aHiVal[Curbar] = High[Curbar];
       }
    }
 
    if ((blsLong == 1) AND ((sctotal[CurBar]  < 5) OR (KPMediumUP[CurBar]  < KPMediumMA[CurBar] )  OR
       (KPFast2Val[CurBar]  < 1)  OR  (KPFast3Val[CurBar]  < 1) OR (KPTriggerLine[CurBar]  < KPStopLine[CurBar] )) )
       {
           blsLong= 0;
        }
           
      if ((blsLong == -1) AND ((sctotal[CurBar]  > -5)  OR  (KPMediumDwn[CurBar] > KPMediumMA[CurBar] )  OR
         (KPFast2Val[CurBar]  > -1)  OR (KPFast3Val[CurBar]  > -1)  OR
         (KPTriggerLine[CurBar]  > KPStopLine[CurBar] )) )
         {
            blsLong = 0;
         }
}
 
PlotShapes (IIf(aHPivs == 1, shapeHollowSmallSquare, shapeNone) ,colorRed, layer = 0, yposition = flowerHigh, offset = 12 );
PlotShapes (IIf(aLPivs == 1, shapeHollowSmallSquare, shapeNone) ,colorLime, layer = 0, yposition = flowerLow, offset = -12 );
 
}
_SECTION_END();
 
_SECTION_BEGIN("TSKPEBand");
/* Standard Error Bands */
Periods = Param("Standard Error", 20, 3, 200, 1);
Smooth  = Param("Smooth",12,2,100,1);
 
 
LRCurve = LinearReg( C, periods );
MALRCurve  = MA(LRCurve, Smooth);
SEValue = StdErr( C, periods );
SErrorAvg =  MA(SEValue, Smooth);
 
LowerBand = MALRCurve - SErrorAvg ;
UpperBand = MALRCurve + SErrorAvg ;
 
Plot( MALRCurve , "MidBand", ParamColor("ColorMB",ColorRGB(0,200,0))  , ParamStyle("StyleMB", style=styleDashed, Mask=maskDefault ));
Plot( UpperBand , "UpperBand", ParamColor("ColorUp",colorTeal)  , ParamStyle("StyleUp", style=styleDashed, Mask=maskDefault ));
Plot( LowerBand , "LowerBand", ParamColor("ColorLo",colorTeal), ParamStyle("StyleLo", style=styleDashed, Mask=maskDefault ));
_SECTION_END();
 
 
_SECTION_BEGIN("Cloud Setting");
//Cloud
ParmCloud = ParamToggle("Cloud", "No|Yes", 1);
 
CloudResColor=ParamColor("CloudResColor",ColorRGB(15,15,15));
CR=Upperband;
CS=Lowerband;
 
if(parmCloud == 1)
{
    PlotOHLC( CS, CS, CR,CR, "Band", CloudResColor, styleCloud | styleNoLabel|styleNoTitle);
}
 
_SECTION_END();
 
_SECTION_BEGIN("KPL Swing");
//Copyright Kamalesh Langote. Email:kpl@vfmdirect.com. More details at http://www.vfmdirect.com/kplswing
//Save indicator as "kplswing.afl" in C: program files > Amibroker > Formulas > Custom folder and then drap and drop on price chart
no=Param( "Swing", 20, 1, 55 );
tsl_col=ParamColor( "Color", colorCycle );
 
res=HHV(H,no);
sup=LLV(L,no);
avd=IIf(C>Ref(res,-1),1,IIf(C<Ref(sup,-1),-1,0));
avn=ValueWhen(avd!=0,avd,1);
tsl=IIf(avn==1,sup,res);
 
Plot(tsl, _DEFAULT_NAME(), tsl_col, styleStaircase); // or styleaArea
 
Buy=Cross(C,tsl);
Sell=Cross(tsl,C);
shape=Buy*shapeUpArrow + Sell*shapeDownArrow;
PlotShapes(shape,IIf(Buy,tsl_col,tsl_col),0,IIf(Buy,Low,High));
_SECTION_END();
 
 
///////////This system has kpl swing with ishimaku clouds and targets and stop loss
 
/////////////////////////////////// Programs Begins
 
//////////////////with near days high low scanner
 
 
 
////////////////////////////////////////////////////////////////////////////////////////////////
 
 
 
 
////////////////////////////////////////////////////////////////////////////////////////////
 
 
////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
 
messageboard = ParamToggle("Message Board","Show|Hide",0);
showsl = ParamToggle("Stop Loss Line", "Show|Hide", 0);
no=10;
res=HHV(H,no);
sup=LLV(L,no);
avd=IIf(C>Ref(res,-1),1,IIf(C<Ref(sup,-1),-1,0));
avn=ValueWhen(avd!=0,avd,1);
s5d=IIf(avn==1,sup,res);
 
if (showsl == 0)
//{Plot(s5d,"Stop Loss",colorCustom14,styleDots);}
exitlong = Cross(s5d, H);
PlotShapes(exitlong * shapeNone, colorBlack,0,H,-10);
exitshort = Cross(L, s5d);
PlotShapes(exitshort * shapeNone, colorBlack,0,L,-15);
 
Buy = exitshort;
Sell = exitlong;
//Short = Sell;
//Cover = Buy;
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
//Short = ExRem(Short, Cover);
//Cover = ExRem(Cover, Short);
AlertIf( Buy, "", "BUY @ " + C, 1 );
AlertIf( Sell, "", "SELL @ " + C, 2 );
 
for(i=BarCount-1;i>1;i--)
{
if(Buy[i] == 1)
{
entry = C[i];
sig = "BUY";
sl = s5d[i];
tar1 = entry + (entry * .0050);
tar2 = entry + (entry * .0092);
tar3 = entry + (entry * .0179);
 
bars = i;
i = 0;
}
if(Sell[i] == 1)
{
sig = "SELL";
entry = C[i];
sl = s5d[i];
tar1 = entry - (entry * .0050);
tar2 = entry - (entry * .0112);
tar3 = entry - (entry * .0212);
 
 
bars = i;
i = 0;
}
}
Offset = 20;
Clr = IIf(sig == "BUY", colorLime, colorRed);
ssl = IIf(bars == BarCount-1, s5d[BarCount-1], Ref(s5d, -1));
sl = ssl[BarCount-1];
 
Plot(LineArray(bars-Offset, tar1, BarCount, tar1,1), "", Clr, styleLine|styleDots, Null, Null, Offset);
Plot(LineArray(bars-Offset, tar2, BarCount, tar2,1), "", Clr, styleLine|styleDots, Null, Null, Offset);
Plot(LineArray(bars-Offset, tar3, BarCount, tar3,1), "", Clr, styleLine|styleDots, Null, Null, Offset);
 
Plot(LineArray(bars-Offset, sl, BarCount, sl,1), "", colorDarkRed, styleLine|styleLine, Null, Null, Offset);
Plot(LineArray(bars-Offset, entry, BarCount, entry,1), "", colorGreen, styleLine|styleLine, Null, Null, Offset);
 
for (i=bars; i <BarCount;i++)
{
PlotText(""+sig+"@"+entry, BarCount+1,entry,Null,colorBlue);
PlotText("T1@"+tar1,BarCount+3,tar1,Null,Clr);PlotText("T2@"+tar2,BarCount+3,tar2,Null,Clr);PlotText ("T3@"+tar3,BarCount+3,tar3,Null,Clr);
 
}
 
 
printf("Last " + sig + " Signal came " + (BarCount-bars) + " bars ago");
printf("\n" + sig + " @ : " + entry + "\nStop Loss : " + sl + " (" + WriteVal(IIf(sig == "SELL",entry-sl,sl-entry), 2.2) + ")"+ "\nTarget_1 : " + tar1 + "\nTarget_2 : " + tar2 + "\nTarget_3 : " + tar3);
printf("\nCurrent P/L : " + WriteVal(IIf(sig == "BUY",(C-entry),(entry-C)),2.2));
 
if (messageboard == 0 )
{
GfxSelectFont( "Tahoma", 13, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );
 
if ( sig =="BUY")
{
GfxSelectSolidBrush( colorBlue ); // this is the box background color
}
else
{
GfxSelectSolidBrush( colorRed ); // this is the box background color
}
pxHeight = Status( "pxchartheight" ) ;
xx = Status( "pxchartwidth");
Left = 1100;
width = 310;
x = 5;
x2 = 290;
 
y = pxHeight;
 
GfxSelectPen( colorGreen, 1); // broader color
 
GfxRoundRect( x, y - 163, x2, y , 7, 7 ) ;
GfxTextOut( ( " Trading System "),88,y-165);
GfxTextOut( (" "),27,y-160);
GfxTextOut( ("Last " + sig + " Signal came " + (BarCount-bars-1) * Interval()/60 + " mins ago"), 13, y-140) ; // The text format location
GfxTextOut( ("" + WriteIf(sig =="BUY",sig + " @ ",sig + " @") + " : " + entry), 13, y-120);
GfxTextOut( ("Trailing SL : " + sl + " (" + WriteVal(IIf(sig == "SELL",entry-sl,sl-entry), 2.2) + ")"), 13, y-100);
GfxTextOut( ("TGT:1 : " + tar1), 13, y -80);
GfxTextOut( ("TGT:2 : " + tar2), 13,y-60);
GfxTextOut( ("TGT:3 : " + tar3), 13,y-40);
GfxTextOut( ("Current P/L : " + WriteVal(IIf(sig == "BUY",(C-entry),(entry-C)),2.2)), 88, y-22);;
 
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////
 
 
 
//////////////////////////////////////////////////////////////////////////////////////////////////////////
 
_SECTION_BEGIN("Magnified Market Price");
FS=Param("Font Size",30,30,100,1);
GfxSelectFont("Arial", FS, 700, italic = False, underline = False, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorBlack) );
Hor=Param("Horizontal Position",750,800,800,800);
Ver=Param("Vertical Position",27,27,27,27);
GfxTextOut(""+C,Hor , Ver );
YC=TimeFrameGetPrice("C",inDaily,-1);
DD=Prec(C-YC,2);
xx=Prec((DD/YC)*100,2);
GfxSelectFont("Arial", 12, 700, italic = False, underline = False, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor(ParamColor("Color",colorYellow) );
GfxTextOut(""+DD+" ("+xx+"%)", Hor+5, Ver+45 );
_SECTION_END();
 
////////////////////////////////////////////////////////////////////////////////
 
 
 
 
/////////////////////////////////////////////////////////////////////////////////////
 
 
 
 
 
/*Plot EMA*/
Plot( EMA( Close,13), "13 EMA", colorRed,styleLine);
Plot( EMA( Close,34), "34 EMA", colorBlue,styleLine);
Plot( EMA( Close,55), "55 EMA", colorBlack,styleLine);
Plot( EMA( Close,89), "89 EMA", colorYellow,styleLine);
 
//////////////////////Clouds
_SECTION_BEGIN("Ichimoku Cloud Charts");
GraphXSpace =1;
prds = Param("Standard Line Periods?", 13,5,26,1);
prds1 = Param("Turning Line Periods?", 3,3,10,1);
prds2 = Param("Delayed Line Periods?", 12,4,25,1);
prds3 = Param("Spans Periods?", 16,10,52,1);
TL = ( HHV( H, prds1) + LLV( L, prds1) )/2;
SL = ( HHV( H, prds) + LLV( L, prds) )/2;
DL = Ref( C, prds2);
Sp1 = Ref( ( SL + TL )/2, -prds2);
Sp2 = Ref( (HHV( H, prds3) + LLV(L, prds3))/2, -prds2);
SetChartOptions( 0, chartShowDates | chartShowArrows | chartLogarithmic | chartWrapTitle );
_N( Title = StrFormat( "{{NAME}} - " + SectorID( 1 ) + " - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " + WriteVal( V, 1.0 ) + " {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ) );
if ( ParamToggle( "Tooltip shows", "All Values|Only Prices" ) )
{
ToolTip = StrFormat( "Open: %g\nHigh: %g\nLow: %g\nClose: %g (%.1f%%)\nVolume: " + NumToStr( V, 1 ), O, H, L, C, SelectedValue( ROC( C, 1 ) ) );
}
PlotOHLC (Sp1,Sp1,Sp2,Sp2,"Cloud",IIf(Sp1>Sp2,ParamColor("Span1 Color", ColorRGB(0,255,0)),ParamColor("Span2 Color",ColorRGB(255,104,32))),styleCloud);
 
_SECTION_END();
 
/////////////////////////////////////Kpl Swing
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//kpl swing formula here
//---- heikin ashi
HaClose = (O+H+L+C)/4;
HaOpen = AMA( Ref( HaClose, -1 ), .40);
HaHigh = Max( H, Max( HaClose, HaOpen ) );
HaLow = Min( L, Min( HaClose, HaOpen ) );
xDiff = (HaHigh - Halow) * IIf(StrFind(Name(),"JPY"),100,10000);
// Plot(EMA(HaClose,9),"",colorWhite, styleLine);
// Plot(EMA(HaClose,18),"",colorBlack, styleLine);
_SECTION_BEGIN("KPL Swing");
no=Param( "Swing", 10, 1, 55 );
tsl_col=ParamColor( "Color", colorCycle );
 
res=HHV(H,no);
sup=LLV(L,no);
avd=IIf(C>Ref(res,-1),1,IIf(C<Ref(sup,-1),-1,0));
avn=ValueWhen(avd!=0,avd,1);
tsl=IIf(avn==1,sup,res);
 
Plot(tsl, _DEFAULT_NAME(), tsl_col, styleStaircase); // or styleaArea
 
_SECTION_END();
 
 
 
 
 
////////////////////details of stock at the title
 
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
 
_SECTION_END();
 
 
 
/////////////////////weekly high low
 
_SECTION_BEGIN("weekly-H-L");
Hclose=HHV(H,5);
Lclose= LLV(L,5);
DH = EncodeColor(colorDarkBlue) + "weekly-H-L = " + Hclose + "\n";
DL = EncodeColor(colorDarkRed) + "weekly-H-L = " + Lclose + "\n";
_N(Title = StrFormat("{{NAME}} ({{INTERVAL}}), {{DATE}} ; {{OHLCX}}, V=%1.0f\n {{VALUES}}\n\n", V) + DH + DL);
 
_SECTION_END();
 
/////////////////Stock near days high and low scanner
TimeFrameSet(inHourly);
H1 = HHV(H, 1) ;
 
H2= (H1-C)< .001*C;
 
L1 = LLV(L,1) ;
 
 
L2 = (C-L1) < .001*C ;
 
TimeFrameRestore() ;
 
SetOption("NoDefaultColumns", True);
 
AddTextColumn(Name(), "Symbol");
AddColumn(DateTime(), "Date", formatDateTime);
AddColumn(C, "CMP", 1.2);
 
 
 
Filter = H2 OR L2 ;
 
Buy = H2 ;
Sell = L2 ;
 
 
///////////////////////////candle stick reader
 
 
_SECTION_BEGIN("Candle Identification");
O1 = Ref(O,-1);O2 = Ref(O,-2);
H1 = Ref(H,-1);H2 = Ref(H,-2);
L1 = Ref(L,-1);L2 = Ref(L,-2);
C1 = Ref(C,-1);C2 = Ref(C,-2);
function CandlePattern(P)
   {
   global PatternName;
   if(P == 0) { PatternName = "NearDoji"; Pv = (abs(O-C)<= ((H-L)*0.1)); }
   else if(P == 1) { PatternName = "BlackCandle"; Pv = (O>C); }
   else if(P == 2) { PatternName = "LongBlackCandle"; Pv = (O>C AND
(O-C)/(.001+H-L)>.6); }
   else if(P == 3) { PatternName = "SmallBlackCandle"; Pv = ((O>C) AND
((H-L)>(3*(O-C)))); }
   else if(P == 4) { PatternName = "WhiteCandle"; Pv = (C>O); }
   else if(P == 5) { PatternName = "LongWhiteCandle"; Pv = ((C>O) AND
((C-O)/(.001+H-L)>.6)); }
   else if(P == 6) { PatternName = "SmallWhiteCandle"; Pv = ((C>O) AND
((H-L)>(3*(C-O)))); }
   else if(P == 7) { PatternName = "BlackMaubozu"; Pv = (O>C AND H==O AND
C==L); }
   else if(P == 8) { PatternName = "WhiteMaubozu"; Pv = (C>O AND H==C AND
O==L); }
   else if(P == 9) { PatternName = "BlackClosingMarubozu"; Pv = (O>C AND
C==L); }
   else if(P == 10) { PatternName = "WhiteClosingMarubozu"; Pv = (C>O AND
C==H); }
   else if(P == 11) { PatternName = "BlackOpeningMarubozu"; Pv = (O>C AND
O==H); }
   else if(P == 12) { PatternName = "WhiteOpeningMarubozu"; Pv = (C>O AND
O==L); }
   else if(P == 13) { PatternName = "HangingMan"; Pv = (((H-L)>4*(O-C)) AND
((C-L)/(.001+H-L)>= 0.75) AND ((O-L)/(.001+H-L)>= 0.75)); }
   else if(P == 14) { PatternName = "Hammer"; Pv = (((H-L)>3*(O-C)) AND
((C-L)/(.001+H-L)>0.6) AND ((O-L)/(.001+H-L)>0.6)); }
   else if(P == 15) { PatternName = "InvertedHammer"; Pv = (((H-L)>3*(O-C))
AND ((H-C)/(.001+H-L)>0.6) AND ((H-O)/(.001+H-L)>0.6)); }
   else if(P == 16) { PatternName = "ShootingStar"; Pv = (((H-L)>4*(O-C))
AND ((H-C)/(.001+H-L)>= 0.75) AND ((H-O)/(.001+H-L)>= 0.75)); }
   else if(P == 17) { PatternName = "BlackSpinningTop"; Pv = ((O>C) AND
((H-L)>(3*(O-C))) AND (((H-O)/(.001+H-L))<.4) AND
(((C-L)/(.001+H-L))<.4)); }
   else if(P == 18) { PatternName = "WhiteSpinningTop"; Pv = ((C>O) AND
((H-L)>(3*(C-O))) AND (((H-C)/(.001+H-L))<.4) AND
(((O-L)/(.001+H-L))<.4)); }
   else if(P == 19) { PatternName = "BearishAbandonedBaby"; Pv = ((C1 == O1)
AND (C2>O2) AND (O>C) AND (L1>H2) AND (L1>H)); }
   else if(P == 20) { PatternName = "BearishEveningDojiStar"; Pv = ((C2>O2)
AND ((C2-O2)/(.001+H2-L2)>.6) AND (C2<O1) AND (C1>O1) AND
((H1-L1)>(3*(C1-O1))) AND (O>C) AND (O<O1)); }
   else if(P == 21) { PatternName = "DarkCloudCover"; Pv = (C1>O1 AND
((C1+O1)/2)>C AND O>C AND O>C1 AND C>O1 AND (O-C)/(.001+(H-L)>0.6)); }
   else if(P == 22) { PatternName = "BearishEngulfing"; Pv = ((C1>O1) AND
(O>C) AND (O>= C1) AND (O1>= C) AND ((O-C)>(C1-O1))); }
   else if(P == 23) { PatternName = "ThreeOutsideDownPattern"; Pv = ((C2>O2)
AND (O1>C1) AND (O1>= C2) AND (O2>= C1) AND ((O1-C1)>(C2-O2)) AND (O>C) AND
(C<C1)); }
   else if(P == 24) { PatternName = "BullishAbandonedBaby"; Pv = ((C1 == O1)
AND (O2>C2) AND (C>O) AND (L2>H1) AND (L>H1)); }
   else if(P == 25) { PatternName = "BullishMorningDojiStar"; Pv = ((O2>C2)
AND ((O2-C2)/(.001+H2-L2)>.6) AND (C2>O1) AND (O1>C1) AND
((H1-L1)>(3*(C1-O1))) AND (C>O) AND (O>O1)); }
   else if(P == 26) { PatternName = "BullishEngulfing"; Pv = ((O1>C1) AND
(C>O) AND (C>= O1) AND (C1>= O) AND ((C-O)>(O1-C1))); }
   else if(P == 27) { PatternName = "ThreeOutsideUpPattern"; Pv = ((O2>C2)
AND (C1>O1) AND (C1>= O2) AND (C2>= O1) AND ((C1-O1)>(O2-C2)) AND (C>O) AND
(C>C1)); }
   else if(P == 28) { PatternName = "BullishHarami"; Pv = ((O1>C1) AND (C>O)
AND (C<= O1) AND (C1<= O) AND ((C-O)<(O1-C1))); }
   else if(P == 29) { PatternName = "ThreeInsideUpPattern"; Pv = ((O2>C2)
AND (C1>O1) AND (C1<= O2) AND (C2<= O1) AND ((C1-O1)<(O2-C2)) AND (C>O) AND
(C>C1) AND (O>O1)); }
   else if(P == 30) { PatternName = "PiercingLine"; Pv = ((C1<O1) AND
(((O1+C1)/2)<C) AND (O<C) AND (O<C1) AND (C<O1) AND
((C-O)/(.001+(H-L))>0.6)); }
   else if(P == 31) { PatternName = "BearishHarami"; Pv = ((C1>O1) AND (O>C)
AND (O<= C1) AND (O1<= C) AND ((O-C)<(C1-O1))); }
   else if(P == 32) { PatternName = "ThreeInsideDownPattern"; Pv = ((C2>O2)
AND (O1>C1) AND (O1<= C2) AND (O2<= C1) AND ((O1-C1)<(C2-O2)) AND (O>C) AND
(C<C1) AND (O<O1)); }
   else if(P == 33) { PatternName = "ThreeWhiteSoldiers"; Pv = (C>O*1.01)
AND (C1>O1*1.01) AND (C2>O2*1.01) AND (C>C1) AND (C1>C2) AND (O<C1) AND
(O>O1) AND (O1<C2) AND (O1>O2) AND (((H-C)/(H-L))<.2) AND
(((H1-C1)/(H1-L1))<.2) AND (((H2-C2)/(H2-L2))<.2); }
   else if(P == 34) { PatternName = "DarkCloudCover"; Pv = (C1>O1*1.01) AND
(O>C) AND (O>H1) AND (C>O1) AND (((C1+O1)/2)>C) AND (C>O1) AND
(MA(C,13)-Ref(MA(C,13),-4)>0); }
   else if(P == 35) { PatternName = "ThreeBlackCrows"; Pv = (O>C*1.01) AND
(O1>C1*1.01) AND (O2>C2*1.01) AND (C<C1) AND (C1<C2) AND (O>C1) AND (O<O1)
AND (O1>C2) AND (O1<O2) AND (((C-L)/(H-L))<.2) AND (((C1-L1)/(H1-L1))<.2)
AND (((C2-L2)/(H2-L2))<.2); }
   else if(P == 36) { PatternName = "doji"; Pv = (O == C); }
   else if(P == 37) { PatternName = "GapUp"; Pv = GapUp(); }
   else if(P == 38) { PatternName = "GapDown"; Pv = GapDown(); }
   else if(P == 39) { PatternName = "BigGapUp"; Pv = L>1.01*H1; }
   else if(P == 40) { PatternName = "BigGapDown"; Pv = H<0.99*L1; }
   else if(P == 41) { PatternName = "HugeGapUp"; Pv = L>1.02*H1; }
   else if(P == 42) { PatternName = "HugeGapDown"; Pv = H<0.98*L1; }
   else if(P == 43) { PatternName = "DoubleGapUp"; Pv = GapUp() AND
Ref(GapUp(),-1); }
   else if(P == 44) { PatternName = "DoubleGapDown"; Pv = GapDown() AND
Ref(GapDown(),-1); }
   return Pv;
   }
 
PatternNameList = "";
for(Cp=0; Cp<=44; Cp++)
    {
    VarSet("Pattern"+NumToStr(Cp,1.0),CandlePattern(cP));
    PatternNameList = PatternNameList +PatternName+",";
    }
 
BI = BarIndex();
SelectedBar = SelectedValue(BI) -BI[0];
//Selectedbar = Status("lastvisiblebar")-1;
PStr="";
for(Cp=0; Cp<=44; Cp++)
    {
    Temp = VarGet("Pattern"+NumToStr(Cp,1.0));
    if(temp[SelectedBar]) Pstr=Pstr+"#"+NumToStr(Cp,1.0)+" - "+StrExtract(PatternNameList,Cp)+"\n";
    }
 
 
FS=Param("Font Size",11,11,100,1);
GfxSelectFont("Times New Roman", FS, 700, True );
GfxSetBkMode( colorWhite ); 
GfxSetTextColor( ParamColor("Color",colorWhite) );
Hor=Param("Horizontal Position",237,1,1200,1);
Ver=Param("Vertical Position",50,1,830,1);
GfxTextOut("Candle Reader= "+Pstr, Hor , Ver );
 
 
 
 
_SECTION_END();
Ignore whatever tries 2 stop U & move on,keep faith on your Lord for ur success!
User avatar
akhan
MODERATOR
MODERATOR
 
Posts: 1658
Images: 0
Cash on hand: 1,916.00
Bank: 0.00
Joined: Sat Dec 17, 2011 2:27 pm
Has thanked: 27 times
Have thanks: 170 times
Blog: View Blog (1)
Real Name: AKHAN
Gender: Male
Karma: 3

Re: Amibroker

Postby vpukken » Fri Nov 21, 2014 8:16 am

sosme more AFLs picked up from various sources.


http://www.4shared.com/rar/zdqqb28sba/ami_indi.html
VOLATILITY ALWAYS EQUALS OPPORTUNITY

For this message the author vpukken has received thanks:
nilopra (Tue Nov 25, 2014 10:43 am)
Rating: 3%
 
User avatar
vpukken
MODERATOR
MODERATOR
 
Posts: 3737
Cash on hand: 5,786.00
Bank: 0.00
Joined: Sat May 21, 2011 9:27 am
Has thanked: 1347 times
Have thanks: 1585 times
Blog: View Blog (1)
Karma: 25

Re: Amibroker

Postby rkkgs » Fri Jun 12, 2015 10:52 pm

manish midha wrote:
Code: Select all
_SECTION_BEGIN("Name");
GfxSetOverlayMode(1);
GfxSelectFont("Tahoma", Status("pxheight")/8 );
GfxSetTextAlign( 6 );// center alignment
GfxSetTextColor( ColorHSB( 42, 42, 42 ) );
GfxSetBkMode(0); // transparent
GfxTextOut( Name(), Status("pxwidth")/2, Status("pxheight")/12 );
GfxSelectFont("Tahoma", Status("pxheight")/18 );
GfxTextOut( IndustryID(1), Status("pxwidth")/2, Status("pxheight")/4 );

GfxSelectFont("Tahoma", Status("pxheight")/18 );
GfxSelectFont("Tahoma", Status("pxheight")/36 );
GfxTextOut( "", Status("pxwidth")/2, Status("pxheight")/3 );
_SECTION_END();

_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
rg=(H-L);
arg=Wilders(rg,30);
wrb=rg>(2.5*arg);
Cloc=C-L;
x=rg/Cloc;
x1=IIf(Cloc=0,arg,x);
dcls=x1>2;
j=MA(C,5);
tls=LinRegSlope(j,5);
utbar=wrb AND dcls AND tls>0 ;
//barcolor = IIf(utbar, colorRed, colorGreen);
//Plot( C, "Close", barcolor,styleBar );
//PlotShapes( shapeUpArrow *(utbar) , colorWhite, 0, H, 10 );
//Filter =utbar;
//AddColumn(utbar,"Trend Change",1,colorGreen,IIf(utbar,colorRed,colorGreen));

_SECTION_END();
_SECTION_BEGIN("Peak");
//Peak-Trough System + Auto ATR + Position sizing+Varible Sensitivity//
// Last Update 16 Oct 05 By Kook//

PctVlt=(ATR(14)/C)*100;//PercentVolatility

PK=IIf(PctVlt<0.5,Peak(Close,0.5,1),
IIf( PctVlt>=0.5 AND PctVlt< 1.0 ,Peak(Close,0.70,1),
IIf( PctVlt>=1.0 AND PctVlt< 1.5 ,Peak(Close,0.90,1),
IIf( PctVlt>=1.5 AND PctVlt< 2.0 ,Peak(Close,1.10,1),
IIf( PctVlt>=2.0 AND PctVlt< 2.5 ,Peak(Close,1.30,1),
IIf( PctVlt>=2.5 AND PctVlt< 3.0 ,Peak(Close,1.50,1),
IIf( PctVlt>=3.0 AND PctVlt< 3.5 ,Peak(Close,1.70,1),
IIf( PctVlt>=3.5 AND PctVlt< 4.0 ,Peak(Close,2.00,1),
Peak(Close,2.20,1) ))))))));

TGH=IIf(PctVlt<0.5,Trough(Close,0.5,1),
IIf( PctVlt>=0.5 AND PctVlt< 1.0 ,Trough(Close,0.75,1),
IIf( PctVlt>=1.0 AND PctVlt< 1.5 ,Trough(Close,1.00,1),
IIf( PctVlt>=1.5 AND PctVlt< 2.0 ,Trough(Close,1.25,1),
IIf( PctVlt>=2.0 AND PctVlt< 2.5 ,Trough(Close,1.50,1),
IIf( PctVlt>=2.5 AND PctVlt< 3.0 ,Trough(Close,1.75,1),
IIf( PctVlt>=3.0 AND PctVlt< 3.5 ,Trough(Close,2.00,1),
IIf( PctVlt>=3.5 AND PctVlt< 4.0 ,Trough(Close,2.25,1),
Trough(Close,2.50,1) ))))))));

Sens=IIf(PctVlt<0.5,0.5,
IIf( PctVlt>=0.5 AND PctVlt< 1.0 ,0.75,
IIf( PctVlt>=1.0 AND PctVlt< 1.5 ,1.00,
IIf( PctVlt>=1.5 AND PctVlt< 2.0 ,1.25,
IIf( PctVlt>=2.0 AND PctVlt< 2.5 ,1.50,
IIf( PctVlt>=2.5 AND PctVlt< 3.0 ,1.75,
IIf( PctVlt>=3.0 AND PctVlt< 3.5 ,2.00,
IIf( PctVlt>=3.5 AND PctVlt< 4.0 ,2.25,
2.50 ))))))));

Color=IIf(BarsSince(Cross(C,Ref(PK,-1)))<BarsSince(Cross(Ref(TGH,-1),C)),colorBrightGreen,colorRed);

Plot(C,"",Color,styleCandle);
//PlotShapes( Cross(C,Ref(PK,-1))*shapeUpArrow,colorYellow,0,L);
//PlotShapes( Cross(Ref(TGH,-1),C)*shapeDownArrow,colorPink,0,H);
PlotShapes( Cross(84,RSI(36))*shapeDownArrow,colorYellow,0,H,Offset=-28 );
//PlotShapes( Cross(67.4,RSI(171))*shapeDownArrow,colorYellow,0,H,Offset=-28 );
PlotShapes( Cross(27,RSI(95))*shapeUpArrow,colorYellow,0,L,Offset=-28 );

//PlotShapes(  Cross(95.9,StochD(4200))*shapeDownArrow,colorCustom12,0,H,Offset=-28 );
//PlotShapes(  Cross(0.50,StochD(4200))*shapeUpArrow,colorCustom12,0,H,Offset=-28 );


Pivot   =   ParamToggle("Pivot_day", "No|Yes", 1);

if(Pivot)
{
H1= TimeFrameGetPrice("H", inDaily, -1);      // yesterdays high
L1 = TimeFrameGetPrice("L", inDaily, -1);      //            low
C1= TimeFrameGetPrice("C", inDaily, -1);      //            close
Op = TimeFrameGetPrice("O", inDaily)-1;         // current day open

}
else
{
H1 = TimeFrameGetPrice("H", inDaily);      // yesterdays high
L1 = TimeFrameGetPrice("L", inDaily);      //            low
C1= TimeFrameGetPrice("C", inDaily);
Op = TimeFrameGetPrice("O", inDaily);         // current day open

}




// PIVOT Calculation
PP = (H1+ L1 +L1 + C1 )/4;


 
Plot(PP, "PP",colorWhite,4+8+2048 );
Plot( (H1),"HH",colorBrown,4+8+2048);
Plot( (L1),"LL",colorAqua,4+8+2048);

R  = (H1- L1);


R1 = PP + (R * 0.118);
R2 = PP + (R * 0.354);
R3 = PP + (R * 0.59);
R4 = PP + (R * 0.826);
R5 = PP + (R * 1.062);
R6 = PP + (R * 1.298);
R7 = PP + (R * 1.534);
R8 = PP + (R * 1.77);
R9 = PP + (R * 2.006);
R10 = PP + (R * 2.242);
R11 = PP +(R * 2.478);
R12 = PP +(R * 2.714);
R13 = PP +(R * 2.950);
R14 = PP +(R * 3.186);
R15 = PP +(R * 3.422);
R16 = PP +(R * 3.658);
R17 = PP +(R * 3.894);
R18 = PP +(R * 4.130);
R19 = PP +(R * 4.366);



S1 = PP - (R * 0.118);
S2 = PP - (R * 0.354);
S3 = PP - (R * 0.59);
S4 = PP - (R * 0.826);
S5 = PP - (R * 1.062);
S6 = PP - (R * 1.298);
S7 = PP - (R * 1.534);
S8 = PP - (R * 1.77);
S9 = PP - (R * 2.006);
S10 = PP - (R * 2.242);
S11 = PP -(R * 2.478);
S12 = PP -(R * 2.714);
S13 = PP -(R * 2.950);
S14 = PP -(R * 3.186);
S15 = PP -(R * 3.422);
S16 = PP -(R * 3.658);
S17 = PP -(R * 3.894);
S18 = PP -(R * 4.130);
S19 = PP -(R * 4.366);


base =(R2+S2)/2;















// woodies pivots
if ( False )
{
PP = ORBHigh- orblow;   
R1  =  (2 * PP) - DayL;
S1  =  (2 * PP) - DayH;
R2  =  PP + (DayH - DayL);
S2  =  PP - (DayH - DayL);

R3  =  R1 + (DayH - DayL);
S3  =  R2 - (DayH - DayL);

R4  =  R2 + (DayH - DayL);
S4  =  R3 - (DayH - DayL);



}

// regular pivots
if ( False )
{
PP = (DayL + DayH + DayC)/3 ;
R1  =  (2 * PP) - DayL;
S1  =  (2 * PP)  - DayH;
R2  =  (PP - S1) + R1;
S2  =  PP - (R1 - S1);
}
Plot(PP, "PP",colorBlack,4+8+2048);
Plot(R1, "R1",colorBrown,styleDashed+styleNoRescale);
Plot(S1, "S1",colorAqua,styleDashed+styleNoRescale);
Plot(R2, "R2",colorCustom12,styleDashed+styleNoRescale);
Plot(S2, "S2",colorRed,styleDashed+styleNoRescale);
Plot(R3, "R3",colorBlue,styleDashed+styleNoRescale);
Plot(S3, "S3",colorBlue,styleDashed+styleNoRescale);
Plot(R4, "R4",colorCustom4,styleDashed+styleNoRescale);
Plot(S4, "S4",colorCustom4,styleDashed+styleNoRescale);
Plot(R5, "R5",colorCustom1,styleDashed+styleNoRescale);
Plot(S5, "S5",colorCustom1,styleDashed+styleNoRescale);
Plot(R6, "R6",colorBlue,styleDashed+styleNoRescale);
Plot(S6, "S6",colorBlue,styleDashed+styleNoRescale);
Plot(R7, "R7",colorViolet,styleDashed+styleNoRescale);
Plot(S7, "S7",colorViolet,styleDashed+styleNoRescale);
Plot(R8, "R8",colorCustom16,styleDashed+styleNoRescale);
Plot(S8, "S8",colorCustom16,styleDashed+styleNoRescale);
Plot(R9, "R8",colorTan,styleDashed+styleNoRescale);
Plot(S9, "S8",colorTan,styleDashed+styleNoRescale);

Plot(R10, "R10",colorRed,styleDashed+styleNoRescale);
Plot(S10, "S10",colorDarkBlue,styleDashed+styleNoRescale);
Plot(R11, "R11",colorViolet,styleDashed+styleNoRescale);
Plot(S11, "S11",colorViolet,styleDashed+styleNoRescale);
Plot(R12, "R12",colorViolet,styleDashed+styleNoRescale);
Plot(S12, "S12",colorViolet,styleDashed+styleNoRescale);
Plot(R13, "R13",colorViolet,styleDashed+styleNoRescale);
Plot(S13, "S13",colorViolet,styleDashed+styleNoRescale);
Plot(R14, "R14",colorViolet,styleDashed+styleNoRescale);
Plot(S14, "S14",colorViolet,styleDashed+styleNoRescale);
Plot(R15, "R15",colorViolet,styleDashed+styleNoRescale);
Plot(S15, "S1",colorViolet,styleDashed+styleNoRescale);
Plot(R16, "R16",colorViolet,styleDashed+styleNoRescale);
Plot(S16, "S16",colorViolet,styleDashed+styleNoRescale);

Plot(R17, "R17",colorViolet,styleDashed+styleNoRescale);
Plot(S17, "S17",colorViolet,styleDashed+styleNoRescale);
Plot(R18, "R18",colorViolet,styleDashed+styleNoRescale);
Plot(S18, "S18",colorViolet,styleDashed+styleNoRescale);
Plot(R19, "R19",colorViolet,styleDashed+styleNoRescale);
Plot(S19, "S19",colorViolet,styleDashed+styleNoRescale);


_SECTION_END();
Plot(EMA(C,20), "EMA21", colorBlue , styleLine|styleThick  );
Plot(EMA(C,10), "EMA13",colorYellow , styleLine|styleThick );
Plot(Wilders(H,260.6), "WILDERS",colorCustom12 ,styleDashed|styleNoRescale);

_SECTION_BEGIN("RSI BUY SELL");
n=45;
per =9;
x = Cum(1);
s1=IIf(RSIa(L,n)>Min(RSIa(C,n),RSIa(O,n)),Min(RSIa(C,n),RSIa(O,n)),RSIa(L,n));
s11=IIf(RSIa(H,n)<Max(RSIa(C,n),RSIa(O,n)),Max(RSIa(C,n),RSIa(O,n)),RSIa(H,n));
pS = TroughBars( s1, per, 1 ) == 0;
endt= LastValue(ValueWhen( pS, x, 1 ));
startt=LastValue(ValueWhen( pS, x, 2 ));
dtS =endt-startt;
endS = LastValue(ValueWhen( pS, s1, 1 ) );
startS = LastValue( ValueWhen( pS, s1, 2  ));
aS = (endS-startS)/dtS;bS = endS;
trendlineS = aS * ( x  -endt ) + bS;
pR = PeakBars( s11, per, 1 ) == 0;
endt1= LastValue(ValueWhen( pR, x, 1 ));
startt1=LastValue(ValueWhen( pR, x, 2 ));
dtR =endt1-startt1;
endR = LastValue(ValueWhen( pR, s11, 1 ) );
startR = LastValue( ValueWhen( pR, s11, 2  ));
aR = (endR-startR)/dtR;
bR = endR;
trendlineR = aR * ( x  -endt1 ) + bR;
//Plot(ValueWhen( (S1==trendlineS ), L),"", colorGreen, styleDashed|styleNoRescale|styleThick);
//Plot(ValueWhen((S11==trendlineR ), H),"", colorRed, styleDashed|styleNoRescale|styleThick);
Buy =  (S1==trendlineS );
Sell =  (S11==trendlineR );
Buy = ExRem( Buy, Sell );
Sell = ExRem( Sell, Buy );
PlotShapes( Buy * shapeUpArrow + Sell * shapeDownArrow, IIf( Buy, colorRed, colorCustom12) );
dist = 0.9*ATR(10);
for( i = 0; i < BarCount; i++ )
{
if( Buy[i] ) PlotText( "Rsi45 Buy " + L[ i ], i, L[ i ]-dist[i], colorWhite);
if( Sell[i] ) PlotText( "Rsi45 Sell " + H[ i ], i, H[ i ]+dist[i], colorCustom12);
}







_SECTION_END();



////////////////////////////////////////////EXPLORATION

Filter= (Buy OR Sell);
AddColumn(Buy,"BUY CALL",1,-1);
AddColumn( Sell, "SELL CALL", 1,-1 );




///////////////////////EXPLORATION ENDS









//Topping Bar
//Range = H - L ;
//TPB = Volume > MA(Volume,9) AND Close < Low + Range/2 AND Range <= Ref(Range,-1);
//PlotShapes(shapeSmallCircle * TPB,colorYellow,0,H,20);

_SECTION_BEGIN("Advanced Trend Lines");
function GetXSupport(Lo, Percentage, Back)
{
 return ((BarCount - 1) - LastValue(TroughBars(Lo, Percentage,Back)));
}
function GetYSupport(Lo, Percentage, Back)
{
 return (LastValue(Trough(Lo, Percentage, back)));
}

function GetXResistance(Hi, Percentage, Back)
{
 return ((BarCount - 1) -LastValue(PeakBars(Hi, Percentage, Back)));
}
function GetYResistance(Hi, Percentage, Back)
{
 return (LastValue(Peak(Hi, Percentage, Back)));
}
function TD_Supply(P)
{
   return ( P > Ref(P, 1) AND P > Ref(P, -1) AND P > Ref(C, -2));
}
function TD_Demand(P)
{
   return ( P < Ref(P, 1) AND P < Ref(P, -1) AND P < Ref(C, -2));
}
////////////////////////////////////////////////////////////////////////
//Parameters
Percentage    = Param("Percentage", 5.55, 0.01, 100. ,0.01);
DrawAllLines    = ParamToggle("Draw All Lines?", "No|Yes", 1);
Lines          = Param("Lines?", 3, 1, BarCount-2);
DrawR          = ParamList("Resistance Points", "Off|High to High|High to Low", 1);
DrawS          = ParamList("Support Points", "Off|Low to Low|Low to High", 1);
ShowTDP       = ParamToggle("Show TD Pionts", "No|Yes", 0);
AllOrDownR    = ParamToggle("Resistance Direction", "All|Down");
AllOrUpS       = ParamToggle("Support Direction", "All|Up");
ShowSR         = ParamToggle("Show Vert S/R","No|Yes", 1);
SRPer         = Param("S/R Percentage", 1.618, 1);
SRBack         = Param("S/R Back", 1, 1);
str = "";
Res = Sup = 0;
Con = 1;
////////////////////////////////////////////////////////////////////////
Main = C;
Con = ConS = ConR = 1;
if(DrawS=="Low to Low")
{
   Support1 = L;
   Support2 = L;
}
else
{
   Support1 = L;
   Support2 = H;
}
if(DrawR=="High to High")
{
   Resistance1 = H;
   Resistance2 = H;
}
else
{
   Resistance1 = H;
   Resistance2 = L;
}
////////////////////////////////////////////////////////////////////////
//Plotting Area
Plot(Main, "", IIf(C>O,colorGreen, colorRed), styleBar);
if(DrawAllLines)
for(i = 2; i<=Lines+1; i++)
{
   if(DrawS!="Off")
   {
      x0 = GetXSupport(Support1, Percentage, i);
      x1 = GetXSupport(Support2, Percentage, i-1);
      y0 = GetYSupport(Support1, Percentage, i);
      y1 = GetYSupport(Support2, Percentage, i-1);
      x = LineArray(x0, y0, x1, y1, 1);
      if(AllOrUpS) ConS = StrToNum(NumToStr(y0 < y1));
      if(Con AND ConS)
         Plot(x, "", IIf(LastValue(C) < LastValue(x), colorBlue,colorYellow),4+8+2048);

   }
   if(DrawR!="Off")
   {
      x0 = GetXResistance(Resistance1, Percentage, i);
      x1 = GetXResistance(Resistance2, Percentage, i-1);
      y0 = GetYResistance(Resistance1, Percentage, i);
      y1 = GetYResistance(Resistance2, Percentage, i-1);
      x = LineArray(x0, y0, x1, y1, 1);
      if(AllOrDownR) ConR = y0 > y1;
      if(Con AND ConR)
         Plot(x, "",  IIf(LastValue(C) < LastValue(x), colorBlue,colorYellow),4+8+2048);

   }
}
else
{
   if(DrawS!="Off")
   {
      x0 = GetXSupport(Support1, Percentage, Lines+1);
      x1 = GetXSupport(Support2, Percentage, Lines);
      y0 = GetYSupport(Support1, Percentage, Lines+1);
      y1 = GetYSupport(Support2, Percentage, Lines);
      x = LineArray(x0, y0, x1, y1, 1 );
      Sup = LastValue(LinRegSlope(x, Lines+1));
      if(AllOrUpS) ConS = y0 < y1;
      if(Con AND ConS)
         Plot(x, "", IIf(LastValue(C) < LastValue(x), colorBlue,colorYellow),4+8+2048);

   }
   if(DrawR!="Off")
   {
      x0 = GetXResistance(Resistance1, Percentage, Lines+1);
      x1 = GetXResistance(Resistance2, Percentage, Lines);
      y0 = GetYResistance(Resistance1, Percentage, Lines+1);
      y1 = GetYResistance(Resistance2, Percentage, Lines);
      x = LineArray(x0, y0, x1, y1, 1 );
      Res = LastValue(LinRegSlope(x, Lines+1));
      if(AllOrDownR) ConR = y0 > y1;
      if(Con AND ConR)
         Plot(x, "",  IIf(LastValue(C) < LastValue(x), colorBlue,colorYellow),4+8+2048);

   }
str = "\nR Slope=("+Res+"), S Slope=("+Sup+")";
}

if(ShowTDP)
{
   PlotShapes(TD_Supply(H)*shapeSmallCircle, colorRed, 0, H, H*.001);
   PlotShapes(TD_Demand(L)*shapeSmallCircle, colorGreen, 0, L, -L*.001);
}
if(ShowSR)
{
   for(i=1; i<=SRBack; i++)
   {
      x0 = GetXSupport(L, SRPer, i);
      x1 = BarCount-1;
      y0 = GetYSupport(L, SRPer, i);
      x = LineArray(x0, y0, x1, y0, 0);
      //Plot(x, "", IIf(LastValue(C) > x, colorCustom13, colorCustom12), 4+8+2048);

      x0 = GetXResistance(H, SRPer, i);
      y0 = GetYResistance(H, SRPer, i);
      x = LineArray(x0, y0, x1, y0, 0);
      //Plot(x, "", IIf(LastValue(C) > x, colorCustom13, colorCustom12), 4+8+2048);


   }
}
Title =FullName()+" ({{NAME}})\n{{DATE}}\n"+"Open: "+O+", Hi: "+H+", Lo: "+L+", Close: "+C+StrFormat(" (%.2f  %.2f\%)", C-Ref(C, -1), SelectedValue(ROC(C, 1)))+str;




_SECTION_END();

_SECTION_BEGIN("Background");
   SetChartOptions(0,chartShowArrows|chartShowDates);
   SetChartBkColor(ParamColor("Outer panel",colorBlack)); // color of outer border
   SetChartBkGradientFill( ParamColor("Inner panel upper",colorBlack),ParamColor("Inner panel lower",colorBlack));
   tchoice=Param("Title Selection ",2,1,2,1);

//Plot(C, "", IIf(O>=C, colorOrange, colorGreen), ParamStyle("Price Style",styleBar,maskPrice));
//////////////////////////////////////////////////////////////////
_SECTION_BEGIN("Fib Retracements");
   fibs = ParamToggle("Plot Fibs","Off|On",1);
   pctH = Param ("Pivot Hi %", 1.618,0.001,2.0,0.002);
   HiLB = Param ("Hi LookBack",1,1,BarCount-1,1);
   pctL = Param ("Pivot Lo %", 1.618,0.001,2.0,0.002);
   LoLB = Param ("Lo LookBack",1,1,BarCount-1,1);
   Back = Param ("Extend Left = 2",1,1,500,1);
   Fwd  = Param("Plot Forward", 0, 0, 500, 1);
   text = ParamToggle("Plot Text","Off|On",1);
   hts  = Param ("Text Shift", -33.5,-50,50,0.10);
   style =ParamStyle("Line Style",styleLine,styleNoLabel);
x = BarIndex();
pRp  = PeakBars( H, pctH, 1) == 0;
yRp0 = SelectedValue(ValueWhen( pRp, H, HiLB));
xRp0 = SelectedValue(ValueWhen( pRp, x, HiLB));
pSp  = TroughBars( L, pctL, 1) == 0;
ySp0 = SelectedValue(ValueWhen( pSp, L, LoLB));
xSp0 = SelectedValue(ValueWhen( pSp, x, LoLB));
Delta = yRp0 - ySp0;

function fib(ret)
{
retval = (Delta * ret);
Fibval = IIf(ret < 1.0
AND xSp0 < xRp0, yRp0 - retval, IIf(ret < 1.0
AND xSp0 > xRp0, ySp0 + retval,IIf(ret > 1.0
AND xSp0 < xRp0, yRp0 - retval, IIf(ret > 1.0
AND xSp0 > xRp0, ySp0 + retval, Null))));
return FibVal;
}

x0 = Min(xSp0,xRp0)-Back;
x1 = (BarCount -1);
//////////////////////////////////////////////////////////////////
r236 = fib(0.236);   r236I = LastValue (r236,1);
r382 = fib(0.382);   r382I = LastValue (r382,1);
r050 = fib(0.50);      r050I = LastValue (r050,1);
r618 = fib(0.618);   r618I = LastValue (r618,1);
r786 = fib(0.786);   r786I = LastValue (r786,1);
e127 = fib(1.27);      e127I = LastValue (e127,1);
e162 = fib(1.62);      e162I = LastValue (e162,1);
e200 = fib(2.00);      e200I = LastValue (e200,1);
e262 = fib(2.62);      e262I = LastValue (e262,1);
e424 = fib(4.24);      e424I = LastValue (e424,1);
//////////////////////////////////////////////////////////////////
p00 = IIf(xSp0 > xRp0,ySp0,yRp0);    p00I = LastValue (p00,1);
p100 = IIf(xSp0 < xRp0,ySp0,yRp0);    p100I = LastValue (p100,1);
color00 =IIf(xSp0 > xRp0,colorLime,colorRed);
color100 =IIf(xSp0 < xRp0,colorLime,colorRed);
//////////////////////////////////////////////////////////////////
numbars = LastValue(Cum(Status("barvisible")));
fraction= IIf(StrRight(Name(),3) == "", 3.2, 3.2);
//////////////////////////////////////////////////////////////////
if(fibs==1)
{
//Plot(LineArray(xRp0-Fwd,yRp0,x1,yRp0,Back),"PR",32,8|styleNoRescale,Null, Null,Fwd);
//Plot(LineArray(xSp0-Fwd,ySp0,x1,ySp0,Back),"PS",27,8|styleNoRescale,Null, Null,Fwd);
//Plot(LineArray(x0-Fwd,r236,x1,r236,Back),"",45,style|styleNoRescale,Null, Null,Fwd);
//Plot(LineArray(x0-Fwd,r382,x1,r382,Back),"",44,style|styleNoRescale,Null, Null,Fwd);
//Plot(LineArray(x0-Fwd,r050,x1,r050,Back),"",41,style|styleNoRescale,Null, Null,Fwd);
//Plot(LineArray(x0-Fwd,r618,x1,r618,Back),"",43,style|styleNoRescale,Null, Null,Fwd);
//Plot(LineArray(x0-Fwd,r786,x1,r786,Back),"",42,style|styleNoRescale,Null, Null,Fwd);
//Plot(LineArray(x0-Fwd,e127,x1,e127,Back),"e127",47,style|styleNoRescale,Null, Null,Fwd);
//Plot(LineArray(x0-Fwd,e162,x1,e162,Back),"e162",47,style|styleNoRescale,Null, Null,Fwd);
//Plot(LineArray(x0-Fwd,e200,x1,e200,Back),"p200",47,style|styleNoRescale,Null, Null,Fwd);
//Plot(LineArray(x0-Fwd,e262,x1,e262,Back),"p262",47,style|styleNoRescale,Null, Null,Fwd);
//Plot(LineArray(x0-Fwd,e424,x1,e424,Back),"p424",25,style|styleNoRescale,Null, Null,Fwd);
}
//////////////////////////////////////////////////////////////////
if(text==1)
{
PlotText(" 0% = " + WriteVal(p00,fraction),    LastValue(BarIndex())-(numbars/hts), p00I  + 0.05, color00);
PlotText("23% = " + WriteVal(r236,fraction), LastValue(BarIndex())-(numbars/hts), r236I + 0.05, 45);
PlotText("38% = " + WriteVal(r382,fraction), LastValue(BarIndex())-(numbars/hts), r382I + 0.05, 44);
PlotText("50% = " + WriteVal(r050,fraction), LastValue(BarIndex())-(numbars/hts), r050I + 0.05, 41);
PlotText("62% = " + WriteVal(r618,fraction), LastValue(BarIndex())-(numbars/hts), r618I + 0.05, 43);
PlotText("78% = " + WriteVal(r786,fraction), LastValue(BarIndex())-(numbars/hts), r786I + 0.05, 42);
PlotText("100% = " + WriteVal(p100,fraction), LastValue(BarIndex())-(numbars/hts),p100I + 0.05, color100);
PlotText("127% = " + WriteVal(e127,fraction), LastValue(BarIndex())-(numbars/hts),e127I + 0.05, 47);
PlotText("162% = " + WriteVal(e162,fraction), LastValue(BarIndex())-(numbars/hts),e162I + 0.05, 47);
PlotText("200% = " + WriteVal(e200,fraction), LastValue(BarIndex())-(numbars/hts),e200I + 0.05, 47);
PlotText("262% = " + WriteVal(e262,fraction), LastValue(BarIndex())-(numbars/hts),e262I + 0.05, 47);
PlotText("424% = " + WriteVal(e424,fraction), LastValue(BarIndex())-(numbars/hts),e424I + 0.05, 25);
}
_SECTION_END();
//////////////////////////////////////////////////////////////////
if (tchoice==1 )
{
_N(Title = EncodeColor(colorWhite)+StrFormat(" {{NAME}} -   {{INTERVAL}}      {{DATE}}    Open:  %g,    High:  %g,     Low:  %g,     Close:  %g     {{VALUES}}",O, H, L, C, SelectedValue( ROC( C, 1   ) ) ));
}
//////////////////////////////////////////////////////////////////
if (tchoice==2 )
{
Title = EncodeColor(colorWhite)+  Date() + "   Tick = " + EncodeColor(5) + Interval()+
EncodeColor(colorWhite) + "     Open = " + EncodeColor(colorWhite) + O +
EncodeColor(colorWhite) + "     High = " + EncodeColor(5) + H +
EncodeColor(colorWhite) + "      Low = " + EncodeColor(colorRed) + L +
EncodeColor(colorWhite) + "     Close = " + EncodeColor(colorWhite) + C + "\n" +
EncodeColor( colorWhite) +"_______________"+"\n"+
EncodeColor( colorWhite)  + "424%   =  "   +    EncodeColor(25)+ e424 + " " +"\n"+
EncodeColor( colorWhite)  + "262%   =  "   +    EncodeColor(47)+ e262 + " " +"\n"+
EncodeColor( colorWhite)  + "200%   =  "   +    EncodeColor(47)+ e200 + " " +"\n"+
EncodeColor( colorWhite)  + "162%   =  "   +    EncodeColor(47)+ e162 + " " +"\n"+
EncodeColor( colorWhite)  + "127%   =  "   +    EncodeColor(47)+ e127 + " " +"\n"+
EncodeColor( colorYellow) + "  Res    =  "   +    EncodeColor(32)+ p100 + " " +"\n"+
EncodeColor( colorWhite)  + "  78%   =  "   +   EncodeColor(42)+ r786 + " " +"\n"+
EncodeColor( colorWhite)  + "  62%   =  "   +    EncodeColor(43)+ r618 + " " +"\n"+
EncodeColor( colorWhite)  + "  50%   =  "   +    EncodeColor(41)+ r050 + " " +"\n"+
EncodeColor( colorWhite)  + "  38%   =  "   +    EncodeColor(44)+ r382 + " " +"\n"+
EncodeColor( colorWhite)  + "  23%   =  "   +    EncodeColor(45)+ r236+ " " +"\n"+
EncodeColor( colorYellow) + "  Sup   =   "   +    EncodeColor(34)+ p00 + " " ;
}
GraphXSpace=5;


////////////////////////////////////////////////////volume with divider for the day in intra day

_SECTION_BEGIN("MPLite Kaka");
//PlotOHLC(O,H,L,C,"Price",IIf(C>O,colorGreen,colorRed),styleCandle);

function Lastthursday()
{
 Daysinmonth=IIf(Month()==1 OR Month()==3 OR Month()==5 OR Month()==7 OR Month()==8 OR Month()==10 OR Month()==12,31,30);
 Daysinmonthfeb=IIf(Year()%4 == 0 AND Year()%100!=0,29,28);
 Daysinmonthfinal=IIf(Month()==2,Daysinmonthfeb,Daysinmonth);
 returnvalue=IIf(Daysinmonthfinal-Day()<7 AND DayOfWeek()==4,1,IIf(Daysinmonthfinal-Day()<8 AND DayOfWeek()==3 AND Ref(DayOfWeek(),1)!=4,1,0));
 return returnvalue;
}

FirstVisibleBar = Status( "FirstVisibleBar" );
Lastvisiblebar = Status( "LastVisibleBar" );

totalVisible=Lastvisiblebar-FirstVisibleBar;
//if(totalVisible<1500){

//Den = Param("Density", 1, 0.1, 10, 0.1);
percent=Param("Value Area", 70, 1, 100, 1);
Type=ParamList("Type","Price Profile|Volume Profile");
Period= ParamList("Base","Hourly|Daily|Weekly|Monthly|Lastthursday|Yearly",1);
x_scale=Param("Horizontal_scale", 2, 0, 10, 0.1);
EnMP2= ParamStyle("Style",styleLine|styleNoLabel,maskAll);
styleLines=styleDots;
ViewYvalues= ParamToggle("Show Yesterdays Values", "No|Yes",1);
ViewVlines= ParamToggle("Show Vertical Base Lines", "No|Yes",1);
Viewvalues= ParamToggle("Show Values", "No|Yes",0);
ViewVpoc= ParamToggle("Show Virgin POC", "No|Yes",1);
ViewTPO=ParamToggle("Show TPO Count", "No|Yes",0);

if(Period=="Hourly"){
BarsInDay = BarsSince(Hour() != Ref(Hour(), -1));Bot = TimeFrameGetPrice("L", inHourly, 0);Top = TimeFrameGetPrice("H", inHourly, 0);Vol = TimeFrameGetPrice("V", inHourly, 0);
}
if(Period=="Daily" ){//OR Interval()==3600
BarsInDay = BarsSince(Day() != Ref(Day(), -1));Bot = TimeFrameGetPrice("L", inDaily, 0);Top = TimeFrameGetPrice("H", inDaily, 0);Vol = TimeFrameGetPrice("V", inDaily, 0);
}
if(Period=="Weekly" OR Interval()==24 * 3600 ){
BarsInDay = BarsSince(DayOfWeek() < Ref( DayOfWeek(), -1 ));Bot = ValueWhen(Ref(BarsInDay,1)==1 OR BarIndex()>BarCount-2 ,LLV(L,BarsInDay),0);Top =ValueWhen(Ref(BarsInDay,1)==1 OR BarIndex()>BarCount-2,HHV(H,BarsInDay),0);Vol = TimeFrameGetPrice("V", inWeekly, 0);
}
if(Period=="Monthly"  ){
BarsInDay = BarsSince(Month() != Ref(Month(), -1));Bot = TimeFrameGetPrice("L", inMonthly, 0);Top = TimeFrameGetPrice("H", inMonthly, 0);Vol = TimeFrameGetPrice("V", inMonthly, 0);
}

if(Period=="Lastthursday"  ){
BarsInDay = BarsSince(Lastthursday()==1 AND Ref(Lastthursday(), -1)==0);Bot = ValueWhen(Ref(BarsInDay,1)==1 OR BarIndex()>BarCount-2 ,LLV(L,BarsInDay),0);Top =ValueWhen(Ref(BarsInDay,1)==1 OR BarIndex()>BarCount-2,HHV(H,BarsInDay),0);Vol = TimeFrameGetPrice("V", inMonthly, 0);
}

if(Period=="Yearly"  ){
BarsInDay = BarsSince(Year() != Ref(Year(), -1));Bot = TimeFrameGetPrice("L", inYearly, 0);Top = TimeFrameGetPrice("H", inYearly, 0);Vol = TimeFrameGetPrice("V", inYearly, 0);
}

Range =  Top-Bot;
coverage=LastValue(ATR(10));

den=(coverage/10);

//multiplier=IIf(round(totalVisible)>500,IIf(round(totalVisible)>1000,3,2),1);

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 ) );
xDiff = (HaHigh - Halow) * 10000;
barcolor = IIf(HaClose >= HaOpen,colorGreen,colorRed);
PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "", barcolor, styleCandle );

multiplier=IIf(round(totalVisible)/300<1,1,round(totalVisible)/300);


if(ViewVlines==1)
{
Plot(BarsInDay==0, "", ParamColor("Base Line Color",colorDarkGrey), styleHistogram | styleOwnScale | styleLine | styleNoLabel);
}


relTodayRange = 0;
x=0;
basey=0;
basex=0;
newday=0;
total=0;
shiftup=0;
shiftdn=0;
Line=Null;
Voloumeunit=0;


for (  i = FirstVisibleBar; i <Lastvisiblebar AND i<BarCount-1 ; i++  )
{
   if(BarsInDay[i]==0)
   {t=BarsInDay[i-1];



      //////////////////////////////////
poc=0;pocj=0;
midrange = int(relTodayRange/2)+1;


for (j=1; j<= relTodayRange+1 ; j++)
   {
      if(poc < x[j])
      {
      poc=x[j]; pocj=j;}
      else if(poc == x[j])
         {
         if (abs(midrange-j)< abs(midrange-pocj)){
         poc = x[j]; pocj = j;
         }
      }
 
   }

for ( n = 1; n <= relTodayRange; n++ )
   {
      total[n]=x[n]+total[n-1];
   }

Value_area=(total[relTodayRange]*percent)/100;


for ( a = 1; a <= relTodayRange; a++ )
{
   if(pocj-a>0 AND pocj+a<relTodayRange)
   {
      if(poc+total[pocj+a]-total[pocj]+(total[pocj]-poc)-total[pocj-(a+1)]>=Value_area) {shiftup=a; shiftdn=a; break;}
       }   
      else if(pocj-a<1 )
      {
      if(poc+total[pocj+a]-total[pocj]+(total[pocj]-poc)>=Value_area){shiftup=a; shiftdn=pocj; break;}      
         }
      else if(pocj+a>relTodayRange )
      {
      if(poc+total[relTodayRange]-total[pocj]+(total[pocj]-poc)-total[pocj-(a+1)] >=Value_area){shiftup=floor(relTodayRange)-pocj; shiftdn=a+1; break;}      
      }
}


if(ViewVpoc==1)
{
Virginpoc=basey+pocj*den;
newi=0;
for( j = i+1; j <= (BarCount - 1) ; j++ )
if( L[j] < Virginpoc AND H[j]>Virginpoc )
{newi=j;break;}
else{newi=BarCount;}
vishycolor=IIf(BarCount%2==0,colorRed,colorBlue);
Plot(LineArray(basex[i],basey+pocj*den,newi,basey+pocj*den),"",vishycolor,styleLine|styleNoRescale);
//Plot(LineArray(basex[i],basey+pocj*den,newi,basey+pocj*den),"",colorYellow,styleLine|styleNoRescale);
}

Vah = LineArray(baseX[i], baseY+(pocj+shiftup)*den, i, baseY+(pocj+shiftup)*den);
Val = LineArray(baseX[i], baseY+(pocj-shiftdn)*den, i, baseY+(pocj-shiftdn)*den);
pocline=LineArray(basex,basey+pocj*den,basex[i]+poc,basey+pocj*den);

//Plot(Vah,"",ParamColor("Color_VAH_Line", colorBlueGrey),styleLine|styleNoRescale);
//Plot(Val,"",ParamColor("Color_VAL_Line", colorBlueGrey),styleLine|styleNoRescale);

Vahn = LineArray(i, baseY+(pocj+shiftup)*den, i+t, baseY+(pocj+shiftup)*den);
pocn = LineArray(i, baseY+(pocj)*den, i+t, baseY+(pocj)*den);
Valn = LineArray(i, baseY+(pocj-shiftdn)*den, i+t, baseY+(pocj-shiftdn)*den);

Plot(pocline,"",ParamColor("Color_POC_Line",colorDarkBlue),styleLine|styleNoRescale|styleNoLabel);

if(ViewYvalues==1)
{
Plot(Vahn,"",ParamColor("YVAH",colorBrightGreen),styleDashed|styleNoRescale);
Plot(Valn,"",ParamColor("YVAL",colorYellow),styleDashed|styleNoRescale);
Plot(pocn,"",ParamColor("YPOC",colorDarkRed),styleDashed|styleNoRescale);

}
//PlotOHLC(Vahn,Vahn,Valn,Valn,"",colorPink,styleCloud|styleOwnScale);


if(ViewTPO==1)
{
nnn=HHV(H,BarsInDay);
PlotText(""+(total[relTodayRange]-total[pocj]),basex[i],nnn[i],colorLightGrey);
PlotText(""+(total[pocj-1]),basex[i],basey-den,colorLightGrey);
}

if(Viewvalues==1)
{
PlotText(""+((basey+pocj*den)),baseX[i],basey+pocj*den,colorWhite,colorDarkGrey);
PlotText(""+((baseY+(pocj+shiftup)*den)),baseX[i],baseY+(pocj+shiftup)*den,colorWhite,colorDarkGrey);
PlotText(""+((baseY+(pocj-shiftdn)*den)),baseX[i],baseY+(pocj-shiftdn)*den,colorWhite,colorDarkGrey);
}


for (p = 0; p <= relTodayRange+1; p=p+multiplier)
{
   if(P>0){
   line = LineArray(baseX, baseY+(p)*Den, baseX+x[p], baseY+(p)*Den);

   }
   
   Plot(line,"",IIf(p>(pocj+shiftup),ParamColor("Color_Above_VA",  colorDarkRed),IIf(p<=(pocj+shiftup)AND p>=(pocj-shiftdn),ParamColor("Color_VA", colorDarkBlue),ParamColor("Color_Below_VA",   colorDarkRed))) , EnMP2);

   
}

Plot(pocline,"",ParamColor("Color_POC_Line",colorDarkRed),styleLine|styleNoRescale);

///////////////////

basex=0;
      x=0;
      Basex=i;
      baseY=Bot[i];
      relTodayRange=Range[i]/Den;
      Voloumeunit=Vol[i]/LastValue(BarsInDay);

   }

   for (j=0; j<= relTodayRange ; j++)
   {   
      if (L[i] <= Bot[i]+j*Den AND H[i] >= Bot[i]+j*Den  )
      {
         if(Type=="Price Profile"){x[j]=(x[j])+x_scale;}
         else if(Type=="Volume Profile"){x[j]=x[j]+round(V[i]/Voloumeunit)+1;}
      }
   }
}

   
//////////////////////////////////
poc=0;pocj=0;
midrange = int(relTodayRange/2)+1;

for (j=1; j<= relTodayRange+1 ; j++)
   {
      if(poc < x[j])
      {
      poc=x[j]; pocj=j;}
      else if(poc == x[j])
         {
         if (abs(midrange-j)< abs(midrange-pocj)){
         poc = x[j]; pocj = j;
         }
      }
 
   }

for ( n = 1; n <= relTodayRange; n++ )
   {
      total[n]=x[n]+total[n-1];
   }

Value_area=(total[relTodayRange]*percent)/100;


for ( a = 1; a <= relTodayRange; a++ )
{
   if(pocj-a>0 AND pocj+a<relTodayRange)
   {
      if(poc+total[pocj+a]-total[pocj]+(total[pocj]-poc)-total[pocj-(a+1)]>=Value_area) {shiftup=a; shiftdn=a; break;}
       }   
      else if(pocj-a<1 )
      {
      if(poc+total[pocj+a]-total[pocj]+(total[pocj]-poc)>=Value_area){shiftup=a; shiftdn=pocj; break;}      
         }
      else if(pocj+a>relTodayRange )
      {
      if(poc+total[relTodayRange]-total[pocj]+(total[pocj]-poc)-total[pocj-(a+1)] >=Value_area){shiftup=floor(relTodayRange)-pocj; shiftdn=a+1; break;}      
      }
}

Vah = LineArray(baseX[i], baseY+(pocj+shiftup)*den, i, baseY+(pocj+shiftup)*den);
Val = LineArray(baseX[i], baseY+(pocj-shiftdn)*den, i, baseY+(pocj-shiftdn)*den);
pocline=LineArray(basex,basey+pocj*den,basex[i]+poc,basey+pocj*den);

if(ViewTPO==1)
{
PlotText(""+(total[relTodayRange]-total[pocj]),basex[i],top[i],colorLightGrey);
PlotText(""+(total[pocj-1]+x_scale),basex[i],basey-den,colorLightGrey);
}

if(Viewvalues==1)
{
PlotText(""+((basey+pocj*den)),baseX[i],basey+pocj*den,colorWhite,colorDarkGrey);
PlotText(""+((baseY+(pocj+shiftup)*den)),baseX[i],baseY+(pocj+shiftup)*den,colorWhite,colorDarkGrey);
PlotText(""+((baseY+(pocj-shiftdn)*den)),baseX[i],baseY+(pocj-shiftdn)*den,colorWhite,colorDarkGrey);
}

for (p = 0; p <= relTodayRange+1; p=p+multiplier)
{
   line = LineArray(baseX, baseY+p*Den, baseX+x[p], baseY+p*Den);

   Plot(line,"",IIf(p>(pocj+shiftup),ParamColor("Color_Above_VA",  colorGrey40),IIf(p<=(pocj+shiftup)AND p>=(pocj-shiftdn),ParamColor("Color_VA", colorBlueGrey),ParamColor("Color_Below_VA",colorGrey40))),EnMP2);
   
   Plot(pocline,"",ParamColor("Color_POC_Line",colorYellow),styleLine|styleNoRescale|styleNoLabel);
}
_SECTION_END();

_SECTION_BEGIN("Volume");
Plot( Volume, _DEFAULT_NAME(), ParamColor("Color", colorDarkGreen), styleNoTitle | ParamStyle( "Style", styleHistogram | styleOwnScale | styleThick | styleNoLabel, maskHistogram  ), 2 );
_SECTION_END();


Image
Attachments
Error.jpg
(144.33 KiB) Not downloaded yet
rkkgs
NEWBIE
NEWBIE
 
Posts: 1
Cash on hand: 1.00
Joined: Wed Jul 03, 2013 4:55 pm
Has thanked: 0 time
Have thanks: 0 time
Blog: View Blog (0)
Karma: 0

Re: Amibroker

Postby vpukken » Thu Jun 18, 2015 9:51 am

Hi, Sorry I dont know how to rectify the problem.
VOLATILITY ALWAYS EQUALS OPPORTUNITY
User avatar
vpukken
MODERATOR
MODERATOR
 
Posts: 3737
Cash on hand: 5,786.00
Bank: 0.00
Joined: Sat May 21, 2011 9:27 am
Has thanked: 1347 times
Have thanks: 1585 times
Blog: View Blog (1)
Karma: 25

Re: Amibroker

Postby waktem » Wed Jul 08, 2015 4:57 pm

All the data are in real time I like that.
waktem
PREMIUM MEMBER
PREMIUM MEMBER
 
Posts: 109
Cash on hand: 119.00
Joined: Sat Mar 16, 2013 2:29 pm
Location: Indore
Has thanked: 0 time
Have thanks: 7 times
Blog: View Blog (0)
Karma: 0

Previous


  • SHARE TOPIC HERE

Return to MARKET VIEWS AND GENERAL MARKET RELATED DISCUSSION

Who is online

Users browsing this forum: No registered users and 2 guests

cron
Disclaimer: The messages and ideas posted on this website are users' own views. We do not own any responsibility for the information provided by the users. Its for learning purpose. No liability whatsoever lies with Blueeyeforum.com. All rights reserved.