/* Done by Rajandran R */
/* Author of
www.marketcalls.in */
_SECTION_BEGIN("Trend Magic hourly chart");
SetBarsRequired(100000,0);
GraphXSpace = 15;
SetChartOptions(0,chartShowArrows|chartShowDates);
SetChartBkColor(ParamColor("bkcolor",ColorRGB(0,0, 0)));
GfxSetBkMode(0);
GfxSetOverlayMode(1);
SetBarFillColor(IIf(C>O,ParamColor("Candle UP Color", colorGreen),IIf(C<=O,ParamColor("Candle Down Color", colorRed),colorLightGrey)));
Plot(C,"\nPrice",IIf(C>O,ParamColor("Wick UP Color", colorDarkGreen),IIf(C<=O,ParamColor("Wick Down Color", colorDarkRed),colorLightGrey)),64,0,0,0,0);
//SetTradeDelays(1,1,1,1);
SetPositionSize(100,spsShares);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
iCCI=Param("CCI Period",50,1,100,1);
Multiplier = Param("Multiplier",2,1,10,1);
Pd=Param("ATR Periods",5,1,10,1);
price = (O+H+L)/3;
iATR = ATR(Pd);
CCIvalue = CCIa(price,iCCI);
for (i = 0; i <iCCI+1; i++) {
TrendUp
= Null;
TrendDown = Null;
}
TrendUp[BarCount-1]=Null;
TrendDown[BarCount-1]=Null;
for (i = iCCI+1; i <BarCount-1; i++) {
TrendUp = Null;
TrendDown = Null;
// if (CCIvalue>=0 && CCIvalue[i-1]<0) {
// TrendUp[i-1]=TrendDown[i-1];
// }
// if (CCIvalue<=0 && CCIvalue[i-1]>0) {
// TrendDown[i-1]=TrendUp[i-1];
// }
if (CCIvalue >= 0)
{
TrendUp = (High+Low)/2 - Multiplier*iATR;
if (TrendUp < TrendUp[i- 1])
TrendUp = TrendUp[i- 1];
}
else
{
if (CCIvalue <= 0)
{
TrendDown = (High+Low)/2 + Multiplier*iATR;
if (TrendDown > TrendDown[i-1])
TrendDown = TrendDown[i-1];
}
}
} //end for loop
Plot(TrendUp,"Trend",colorGreen,stylethick);
Plot(TrendDown,"Down",colorRed,stylethick);
Buy = IsNull(TrendDown) AND !IsNull(TrendUP);
Sell = IsNull(TrendUp) AND !IsNull(TrendDown);
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
Short=Sell;
Cover=Buy;
BuyPrice=ValueWhen(Buy,C);
SellPrice=ValueWhen(Sell,C);
ShortPrice=ValueWhen(Short,C);
CoverPrice=ValueWhen(Cover,C);
Title = EncodeColor(colorWhite)+ "Trend Magic code from www.marketcalls.in" + " - " + Name() + " - " + EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorWhite) +
" - " + Date() +" - "+"\n" +EncodeColor(colorRed) +"Op-"+O+" "+"Hi-"+H+" "+"Lo-"+L+" "+
"Cl-"+C+" "+ "Vol= "+ WriteVal(V)+"\n"+
EncodeColor(colorLime)+
WriteIf (Buy , " GO LONG / Reverse Signal at "+C+" ","")+
WriteIf (Sell , " EXIT LONG / Reverse Signal at "+C+" ","")+"\n"+EncodeColor(colorYellow)+
WriteIf(Sell , "Total Profit/Loss for the Last Trade Rs."+(C-BuyPrice)+"","")+
WriteIf(Buy , "Total Profit/Loss for the Last trade Rs."+(SellPrice-C)+"","");
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45);
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);
PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);
_SECTION_END();
_SECTION_BEGIN("Time Left");
function GetSecondNum()
{
Time = Now( 4 );
Seconds = int( Time % 100 );
Minutes = int( Time / 100 % 100 );
Hours = int( Time / 10000 % 100 );
SecondNum = int( Hours * 60 * 60 + Minutes * 60 + Seconds );
return SecondNum;
}
RequestTimedRefresh( 1 );
TimeFrame = Interval();
SecNumber = GetSecondNum();
Newperiod = SecNumber % TimeFrame == 0;
SecsLeft = SecNumber - int( SecNumber / TimeFrame ) * TimeFrame;
SecsToGo = TimeFrame - SecsLeft;
x=Param("xposn",50,0,1000,1);
y=Param("yposn",380,0,1000,1);
GfxSelectSolidBrush( ColorRGB( 230, 230, 230 ) );
GfxSelectPen( ColorRGB( 230, 230, 230 ), 2 );
if ( NewPeriod )
{
GfxSelectSolidBrush( colorYellow );
GfxSelectPen( colorYellow, 2 );
Say( "New period" );
}
//GfxRoundRect( x+45, y+40, x-3, y-2, 0, 0 );
//GfxSetBkMode(1);
GfxSelectFont( "Arial", 14, 700, False );
GfxSetTextColor( colorRed );
GfxTextOut( "Time Left :"+SecsToGo+"", x, y );
_SECTION_END();