Hybrid Code
Hybrid Code
HaClose[0] = (Open[0]+High[0]+Low[0]+Close[0]) / 4;
HaOpen[0] = (HaClose[0] + Open[0]) / 2;
HaHigh[0] = Max( High[0], Max( HaClose[0], HaOpen[0] ) );
HaLow[0] = Min( Low[0], Min( HaClose[0], HaOpen[0] ) );
_SECTION_END();
// Heikin Ashi - Calculated Properly with no use of AMA
/* **********************************
Code to automatically identify pivots
********************************** */
// -- or current trend is up
}
else
{
if ( curTrend == "D" )
{
curTrend = "U";
curPivBarIdx = curBar - aHHVBars[curBar];
aHPivs[curPivBarIdx] = 1;
aHPivHighs[nHPivs] = H[curPivBarIdx];
aHPivIdxs[nHPivs] = curPivBarIdx;
nHPivs++;
}
// -- If curTrend is up...else...
}
candIdx = 0;
candPrc = 0;
lastLPIdx = aLPivIdxs[0];
lastLPL = aLPivLows[0];
lastHPIdx = aHPivIdxs[0];
lastHPH = aHPivHighs[0];
if (
lastHPH < candPrc AND
candIdx > lastLPIdx AND
candIdx < curBar )
{
// -- OK, we'll add this as a pivot...
aHPivs[candIdx] = 1;
// ...and then rearrange elements in the
// pivot information arrays
for ( j = 0; j < nHPivs; j++ )
{
aHPivHighs[nHPivs-j] = aHPivHighs[nHPivs- ( j+1 )];
aHPivIdxs[nHPivs-j] = aHPivIdxs[nHPivs-( j+1 )];
}
aHPivHighs[0] = candPrc ;
aHPivIdxs[0] = candIdx;
nHPivs++;
}
}
else
{
// -- Bar and price info for candidate pivot
candIdx = curBar - aLLVBars[curBar];
candPrc = aLLV[curBar];
if (
lastLPL > candPrc AND
candIdx > lastHPIdx AND
candIdx < curBar )
{
// -- OK, we'll add this as a pivot...
aLPivs[candIdx] = 1;
// ...and then rearrange elements in the
// pivot information arrays
aLPivLows[0] = candPrc;
aLPivIdxs[0] = candIdx;
nLPivs++;
}
}
// volume spike ( check stocks whose volume for the day is at least 10% greater
than its 30 day ave volume )
Volume_to = Sum(Volume, 31);
Volume_to = Volume_to - Volume;
Volume30 = Volume_to / 30;
percentage = ( abs( Volume30 - Volume ) ) / Volume30;
percentage = percentage * 100;
Filter = Volume > Volume30 AND percentage > 10;
// volume spike
Filter=Buy OR Sell;
Sell=ExRem(Sell,Buy); Buy=ExRem(Buy,Sell);
AddColumn(Buy,"Buy");
AddColumn(Sell,"Sell");
AddColumn(V*C, "Value");
AddColumn(BuyPrice,"BuyPrice", 1.4);
AddColumn(SellPrice,"SellPrice", 1.4);
AddColumn(O, "Opening");
AddColumn(H, "High");
AddColumn(L, "Low");
AddColumn(C, "Close");
AddColumn(Volume30,"Ave 30 days Volume", 1, colorBlue);
AddColumn(Volume,"Volume Today", 1, colorBlue);
AddColumn(Percentage," % Increase", 1.2, colorBlue);
b = C < ( MA( H, n ) + MA( L, n ) ) / 2;// then Sell Short next bar at market;
Longs = state == 1;
shorts = state == 0;
//Chart
Colorbar = IIf( Longs, colorGreen, IIf( Shorts, colorRed, colorGrey40 ) );
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle |
ParamStyle("Style") | GetPriceStyle() );
H0 = H;
L0 = L;
C0 = C;
O0 = O;
Lookback = Param("LookBack", 10, 10, 50, 1); // Default for interday commodity
currency trading
shift = Param("Shift", 5, 1, 50, 1); // ?
x0 = LastValue(Cum(1));
x1 = x0 - shift;
H = Ref(H, - shift + 1);
L = Ref(L, - shift + 1);
H1 = LastValue(Ref(HHV(H, Lookback), - 1));
L1 = LastValue(Ref(LLV(L, Lookback), - 1));
H = H0;
L = L0;
C = C0;
O = O0;
WAD = Cum( ad );
MS = ExRem( MS, MB );
periodtm = 55;
ZLHa = ZeroLagTEMA( haClose, periodtm );
ZLTyp = ZeroLagTEMA( Avg, periodtm );
TMBuy = Cross( ZLTyp, ZLHa );
TMSell = Cross( ZLHa, ZLTyp );
TMBuy1 = ZLTyp > ZLHa ;
TMSell1 = ZLHa > ZLTyp ;
//============== RS ==============
p = ( H + L + C ) / 3;
r1 = ( 2 * p ) - L;
s1 = ( 2 * p ) - H;
r2 = p + ( r1 - s1 );
s2 = p - ( r2 - s1 );
R3 = P + ( R2 - S2 );
S3 = P - ( R3 - S2 );
Cg = Foreign("^PSEi", "C");
Cgo= Ref(Cg,-1);
//Longterm Bullish or Bearish
Bullg = Cg > WMA(Cg,200);
Bearg= Cg <WMA(Cg,200);
xChange1=Cg - Ref(Cg,-1);
Change1 = StrFormat("%1.2f% ",xChange1);
barche1= xChange1>=0;
Comche1= xChange1<0;
xperchange1 = xChange1/100;
perchange1 = StrFormat("%1.2f% ",xperchange1);
positivechange1 = xperchange1>0;
negativechange1 = xperchange1<0;
// VOLUME
-----------------------------------------------------------------------------------
_SECTION_BEGIN("Volume");
Color = ParamColor("Color", ColorRGB( 128, 128, 192 ) );
Plot( Volume, _DEFAULT_NAME(), ColorBlend( Color, GetChartBkColor(), 0.5 ),
styleNoTitle | ParamStyle( "Style", styleHistogram | styleOwnScale | styleThick |
styleNoLabel, maskHistogram ), 2 );
_SECTION_END();
// VOLUME
-----------------------------------------------------------------------------------
{
GfxSelectFont("Time news roman", Status("pxheight")/7 );
GfxSetTextAlign(6 );
GfxSetOverlayMode(1);
GfxSetTextColor(stockname);
GfxSetBkMode(0);
GfxTextOut(Name(),Status("pxwidth")/2, Status("pxheight")/18 );
}
_SECTION_END();
// STOCK NAME/MAGNIFIED MARKET PRICE
-----------------------------------------------------------------------------------
//GraphXSpace=Param("GraphXSpace",5,-30,30,1);
///////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
of = 1;
n = Param( "N Pivot Bars", 31, 2, 500, 1 );
Hh = HHV( H, n );
Ll = LLV( L, n );
p1 = ll + ( hh - ll ) * 0.5;
p2 = ll + ( hh - ll ) * 0.382;
p3 = ll + ( hh - ll ) * 0.618;
p4 = ll + ( hh - ll ) * 0.236;
p5 = ll + ( hh - ll ) * 0.786;
//BuyPrice =ValueWhen(Buy,C);
//SellPrice=ValueWhen(Sell,C);
//Buy = ExRem(Buy,Sell);
//Sell = ExRem(Sell,Buy);
//Buy1 = ExRem(Buy1,Sell1);
//Sell1 = ExRem(Sell1,Buy1);
//PlotShapes(shapeSmallUpTriangle*Buy2,ColorRGB(230, 0, 0 ), 0,L,-20);
//PlotShapes(shapeSmallDownTriangle*Sell2,colorBlue, 0,H,-20);
//Buy2 = ExRem(Buy2,Sell2);
//Sell2 = ExRem(Sell2,Buy2);
//Buy3 = Cross(C, p1) ;
//Sell3 = Cross(p1, C) ;
//PlotShapes(shapeSmallUpTriangle*Buy3,colorBrightGreen, 0,L,-30);
//PlotShapes(shapeSmallDownTriangle*Sell2,colorBrightGreen, 0,H,-20);
//Buy3 = ExRem(Buy3,Sell3);
//Sell3 = ExRem(Sell3,Buy3);
_SECTION_END();
///////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//=================================================================================
===================================================================================
==============
// ICHIMOKU
_SECTION_BEGIN("Ichimoku");
turn = Param( "Tenkan-Sen Line", 9, 1, 100 );
prds = Param( "Kijun-Sen Line", 26, 1, 26, 1 );
span = Param( "Spans Period", 52, 1, 52, 1 );
//SetChartOptions(0,chartShowArrows|chartShowDates);
+ "\n" + EncodeColor( ColorRGB( 111, 208, 255 ) ) + "RSI (14): " + WriteIf( RSI( 14
) > 30 AND RSI( 14 ) < 70, EncodeColor( colorGold ), WriteIf( RSI( 14 ) < 30 ,
EncodeColor( colorBlue ), EncodeColor( colorRed ) ) ) + WriteVal( RSI( 14 ), format
= 1.1 )
+ WriteIf( RSI( 14 ) > 30 AND RSI( 14 ) < 70, " Range" + EncodeColor( colorGold ),
WriteIf( RSI( 14 ) < 30 , " OverSold" + EncodeColor( colorBlue ), " OverBought" +
EncodeColor( colorRed ) ) )
+ "\n" + EncodeColor( ColorRGB( 111, 208, 255 ) ) + "CCI (14): " + WriteIf( CCI( 14
) > -100 AND CCI( 14 ) < 100, EncodeColor( colorGold ), WriteIf( CCI( 14 ) < -100 ,
EncodeColor( colorBlue ), EncodeColor( colorRed ) ) ) + WriteVal( CCI( 14 ), format
= 1.1 )
+ WriteIf( CCI( 14 ) > -100 AND CCI( 14 ) < 100, " Range" +
EncodeColor( colorGold ), WriteIf( CCI( 14 ) < -100 , " OverSold" +
EncodeColor( colorBlue ), " OverBought" + EncodeColor( colorRed ) ) )
+ "\n" + EncodeColor( ColorRGB( 111, 208, 255 ) ) + "Wm%R (14): " + WriteIf( WR >
-80 AND WR < -20, EncodeColor( colorGold ), WriteIf( WR < -80 ,
EncodeColor( colorBlue ), EncodeColor( colorRed ) ) ) + WriteVal( WR, format =
1.1 )
+ WriteIf( WR > -80 AND WR < -20, " Range" + EncodeColor(colorGold ), WriteIf( WR <
-80 , " OverSold" + EncodeColor( colorBlue ), " OverBought" + EncodeColor( colorRed
) ) )
//=================================================================================
===================================================================================
==============
// VOLUME AT PRICE
_SECTION_BEGIN("Volume At Price");
PlotVAPOverlay( Param("Lines", 300, 100, 1000, 1 ), Param("Width", 5, 1, 100, 1 ),
ParamColor("Color", colorCycle ), ParamToggle("Side", "Left|Right" ) |
4*ParamToggle("Z-order", "On top|Behind", 1 ) );
_SECTION_END();
//=================================================================================
===================================================================================
==============
//=================================================================================
===================================================================================
==============
// TREND LINES
//percent = 0.01 * 1; /* Adjust this percent as necessary, I use .01 because FOREX
is a 0.0000 number */
//firstpointL = 2;
//firstpointH = 2;
//
//y0=LastValue(Trough(L,percent,firstpointL));
//y1=LastValue(Trough(Ref(L,-1),percent,1));
//
//for( t = 1; t < BarCount AND y0 >= y1; t++ )
//{
// firstpointL++;
// y0=LastValue(Trough(L,percent,firstpointL));
//}
//
//x0=BarCount - 1 - LastValue(TroughBars(L,percent,firstpointL));
//x1=BarCount - 1 - LastValue(TroughBars(Ref(L,-1),percent,1));
//LineL = LineArray( x0, y0, x1, y1, 1 );
//
//Plot( LineL, " Support Trend line", colorWhite, 1 + 4 );
//
//yt0=LastValue(Peak(H,percent,firstpointH));
//yt1=LastValue(Peak(Ref(H,-1),percent,1));
//
//for(t = 1; t < BarCount AND yt0 <= yt1; t++ )
//{
// firstpointH++;
// yt0=LastValue(Peak(H,percent,firstpointH));
//}
//xt0=BarCount - 1 - LastValue(PeakBars(H,percent,firstpointH));
//xt1=BarCount - 1 - LastValue(PeakBars(Ref(H,-1),percent,1));
//LineH = LineArray( xt0, yt0, xt1, yt1, 1 );
//
//Plot( LineH, "Resistance Trend line", colorWhite,1 + 4 );
//
//=================================================================================
===================================================================================
==============
_SECTION_BEGIN("MA3");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 300, 1, 10 );
Plot( MA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ),
ParamStyle("Style") );
_SECTION_END();