Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SetChartOptions(0,chartShowArrows|chartShowDates);
- SetChartBkGradientFill( ParamColor("Inner panel upper",colorBlack),ParamColor("Inner panel lower",colorBlack));
- Title =
- EncodeColor(colorWhite)+ Title = Name () + " | "
- +EncodeColor(colorYellow) + Date() +" | " + Interval( 2 )+ " | "
- +EncodeColor(colorTurquoise)+ "Op : "+ EncodeColor(colorLightGrey)+ O + " | "
- +EncodeColor(colorTurquoise)+ "Hi : "+ EncodeColor(colorLightGrey)+ H + " | "
- +EncodeColor(colorTurquoise)+ "Lo : "+ EncodeColor(colorLightGrey)+ L + " | "
- +EncodeColor(colorTurquoise)+ "Cls : "+ WriteIf(C> Ref(C, -1),EncodeColor(colorBrightGreen),EncodeColor(colorRed))+ C + " | "
- +EncodeColor(colorTurquoise)+ "Change : ("+ WriteIf(C> Ref(C, -1),EncodeColor(colorBrightGreen),EncodeColor(colorRed)) + WriteVal(C-Ref(C,-1))+" Rs."
- +EncodeColor(colorTurquoise)+ " /"+ WriteIf(C> Ref(C, -1),EncodeColor(colorBrightGreen),EncodeColor(colorRed))+ WriteVal( ROC( C, 1 ))+""+ " % "
- +EncodeColor(colorTurquoise)+ ") | Volume : " + WriteIf(V> Ref(V, -1),EncodeColor(colorBrightGreen),EncodeColor(colorRed))+ WriteVal(V,1);
- _SECTION_END();
- _SECTION_BEGIN( "STREND" );
- ZAMAN = Param( "ZAMAN", 29, 1, 2000, 1 );
- mtOpen = LinearReg( Open, ZAMAN ); // calculate moving trend from open
- mtHigh = LinearReg( High, ZAMAN ); // calculate moving trend from open
- mtLow = LinearReg( Low, ZAMAN ); // calculate moving trend from open
- mtClose = LinearReg( Close, ZAMAN ); // calculate moving trend from open
- // plot surrogate chart
- _SECTION_END();
- _SECTION_BEGIN("Heiken Ashi Smoothed");
- SetChartBkGradientFill( ParamColor("BgTop", colorBlack),ParamColor("BgBottom", colorBlack),ParamColor("Titleblock",colorBlack ));
- SetChartOptions(0,chartShowArrows|chartShowDates);
- GraphXSpace=5;
- p=Param("Period",8,2,30,1);
- Om=MA(O,p);
- hm=MA(H,p);
- lm=MA(L,p);
- Cm=MA(C,p);
- HACLOSE=(Om+Hm+Lm+Cm)/4;
- HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
- HaHigh = Max( Hm, Max( HaClose, HaOpen ) );
- HaLow = Min( Lm, Min( HaClose, HaOpen ) );
- PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "" + Name(), colorWhite, styleCandle | styleNoLabel );
- _SECTION_END();
- a=LinearReg(HaClose, 5 ) ;
- b=LinearReg( HaClose, 5 ) ;
- Plot( IIf(HaHigh>HaOpen,a,b), _DEFAULT_NAME(), colorRed, ParamStyle("Style") );
- Plot( LinearReg( HaOpen, 5 ), _DEFAULT_NAME(), colorWhite, ParamStyle("Style") );
- _SECTION_BEGIN("kgs 12 26 ma buy sell");
- a=MA(C,3) ;
- b=MA(C,15) ;
- Buy = Cross( a,b );
- Sell = Cross( b,a );
- //Short = Sell;
- //Cover = Buy;
- //AlertIf( Buy, "", "MA cross BUY", 1,1+2 );
- //AlertIf( Sell, "", "MA cross SELL", 2 ,1+2)
- AlertIf( Buy, "SOUND C:\\Windows\\Media\\Ding.wav", "Audio alert", 2 );
- AlertIf( Sell, "SOUND C:\\Windows\\Media\\Ding.wav", "Audio alert", 2 );
- _SECTION_END();
- _SECTION_BEGIN("TSKPMoMo");
- 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, shapeSmallCircle, shapeNone) ,colorRed, layer = 0, yposition = haHigh, offset = 17 );
- PlotShapes (IIf(aLPivs == 1, shapeSmallCircle, shapeNone) ,colorGreen, layer = 0, yposition = haLow, offset = -8 );
- AlertIf( Buy, "SOUND C:\\Windows\\Media\\Ding.wav", "Audio alert", 2 );
- AlertIf( Sell, "SOUND C:\\Windows\\Media\\Ding.wav", "Audio alert", 2 );
- _SECTION_END();
- _SECTION_BEGIN( "DESTEK D?RENÇ " );
- SetBarsRequired( sbrAll, sbrAll );
- xx = Cum( 1 );
- nbar = Param( "nbar", 5, 2, 50, 1 );
- PHigh = mtHigh > Ref( HHV( mtHigh, nbar ), -1 ) AND Ref( HHV( mtHigh, nbar ), nbar ) <= mtHigh;
- PHighPrice = ValueWhen( PHigh, mtHigh );
- PLow = mtLow < Ref( LLV( mtLow, nbar ), -1 ) AND Ref( LLV( mtLow, nbar ), nbar ) >= mtLow;
- PLowPrice = ValueWhen( PLow, mtLow );
- startval_L = ValueWhen( PLow, mtLow, 1 );
- endval_L = ValueWhen( PLow, mtLow, 0 );
- startbar_L = ValueWhen( PLow, xx, 1 );
- endbar_L = ValueWhen( PLow, xx, 0 );
- aa_L = ( endval_L - startval_L ) / ( endbar_L - startbar_L );
- bb_L = startval_L;
- trendline_L = aa_L * ( xx - startbar_L ) + bb_L;
- dtrendline_L = trendline_L - Ref( trendline_L, -1 );
- startval_L_extend = ValueWhen( PLow, mtLow, 2 );
- endval_L_extend = ValueWhen( PLow, mtLow, 1 );
- startbar_L_extend = ValueWhen( PLow, xx, 2 );
- endbar_L_extend = ValueWhen( PLow, xx, 1 );
- aa_L_extend = ( endval_L_extend - startval_L_extend ) / ( endbar_L_extend - startbar_L_extend );
- bb_L_extend = startval_L;
- trendline_L_extend = aa_L_extend * ( xx - startbar_L ) + endval_L_extend;
- dtrendline_L_extend = trendline_L_extend - Ref( trendline_L_extend, -1 );
- dtrendline_L_extend = IIf( PLow, Ref( dtrendline_L, -1 ), dtrendline_L_extend );
- startval_L_extend2 = ValueWhen( PLow, mtLow, 3 );
- endval_L_extend2 = ValueWhen( PLow, mtLow, 2 );
- startbar_L_extend2 = ValueWhen( PLow, xx, 3 );
- endbar_L_extend2 = ValueWhen( PLow, xx, 2 );
- aa_L_extend2 = ( endval_L_extend2 - startval_L_extend2 ) / ( endbar_L_extend2 - startbar_L_extend2 );
- bb_L_extend2 = endval_L_extend2;
- trendline_L_extend2 = aa_L_extend2 * ( xx - endbar_L_extend2 ) + endval_L_extend2;
- dtrendline_L_extend2 = trendline_L_extend2 - Ref( trendline_L_extend2, -1 );
- dtrendline_L_extend2 = IIf( PLow, Ref( dtrendline_L_extend, -1 ), dtrendline_L_extend2 );
- startval_H = ValueWhen( PHigh, mtHigh, 1 );
- endval_H = ValueWhen( PHigh, mtHigh, 0 );
- startbar_H = ValueWhen( PHigh, xx, 1 );
- endbar_H = ValueWhen( PHigh, xx, 0 );
- aa_H = ( endval_H - startval_H ) / ( endbar_H - startbar_H );
- bb_H = startval_H;
- trendline_H = aa_H * ( xx - startbar_H ) + bb_H;
- dtrendline_H = trendline_H - Ref( trendline_H, -1 );
- startval_H_extend = ValueWhen( PHigh, mtHigh, 2 );
- endval_H_extend = ValueWhen( PHigh, mtHigh, 1 );
- startbar_H_extend = ValueWhen( PHigh, xx, 2 );
- endbar_H_extend = ValueWhen( PHigh, xx, 1 );
- aa_H_extend = ( endval_H_extend - startval_H_extend ) / ( endbar_H_extend - startbar_H_extend );
- bb_H_extend = startval_H;
- trendline_H_extend = aa_H_extend * ( xx - startbar_H ) + endval_H_extend;
- dtrendline_H_extend = trendline_H_extend - Ref( trendline_H_extend, -1 );
- dtrendline_H_extend = IIf( PHigh, Ref( dtrendline_H, -1 ), dtrendline_H_extend );
- startval_H_extend2 = ValueWhen( PHigh, mtHigh, 3 );
- endval_H_extend2 = ValueWhen( PHigh, mtHigh, 2 );
- startbar_H_extend2 = ValueWhen( PHigh, xx, 3 );
- endbar_H_extend2 = ValueWhen( PHigh, xx, 2 );
- aa_H_extend2 = ( endval_H_extend2 - startval_H_extend2 ) / ( endbar_H_extend2 - startbar_H_extend2 );
- bb_H_extend2 = endval_H_extend2;
- trendline_H_extend2 = aa_H_extend2 * ( xx - endbar_H_extend2 ) + endval_H_extend2;
- dtrendline_H_extend2 = trendline_H_extend2 - Ref( trendline_H_extend2, -1 );
- dtrendline_H_extend2 = IIf( PHigh, Ref( dtrendline_H_extend, -1 ), dtrendline_H_extend2 );
- tld = ParamToggle( "All trendlines", "Show|Hide", 1 );
- if ( tld )
- {
- trendline_L = IIf( dtrendline_L > 0, trendline_L, Null );
- trendline_L_extend = IIf( dtrendline_L_extend > 0, trendline_L_extend, Null );
- trendline_L_extend2 = IIf( dtrendline_L_extend2 > 0, trendline_L_extend2, Null );
- trendline_H = IIf( dtrendline_H < 0, trendline_H, Null );
- trendline_H_extend = IIf( dtrendline_H_extend < 0, trendline_H_extend, Null );
- trendline_H_extend2 = IIf( dtrendline_H_extend2 < 0, trendline_H_extend2, Null );
- }
- trendline_L_extend2 = IIf( BarsSince( Plow ) <= nbar, trendline_L_extend2, Null );
- trendline_H_extend2 = IIf( BarsSince( PHigh ) <= nbar, trendline_H_extend2, Null );
- GraphXSpace = 5;
- SetChartOptions( 0, chartShowDates );
- chartflag = ParamToggle( "Heikin Ashi", "show|hide", 1 );
- if ( chartFlag )
- {
- }
- else
- {
- HaClose = ( O + H + L + C ) / 4;
- HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
- HaHigh = Max( mtHigh, Max( HaClose, HaOpen ) );
- HaLow = Min( mtLow, Min( HaClose, HaOpen ) );
- PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "Modified " + Name(), colorWhite, styleBar );
- }
- PlotShapes( shapeHollowStar*PLow, colorYellow, 0, mtLow, -10 );
- PlotShapes( shapeHollowStar*PHigh, colorRed, 0, mtHigh , 10 );
- Plot( trendline_L, "", colorBrightGreen, styleLine );
- Plot( IIf( BarsSince( Plow ) <= nbar, trendline_L_extend, Null ), "", colorLightGrey, styleNoLine | styleDots | styleThick );
- Plot( IIf( BarsSince( Plow ) > nbar, trendline_L_extend, Null ), "", colorBrightGreen, styleNoLine | styleDots | styleThick );
- Plot( IIf( BarsSince( Plow ) <= nbar, trendline_L_extend2, Null ), "", colorDarkGreen, styleNoLine | styleDots | styleThick );
- Plot( trendline_H, "", colorRed, styleLine );
- Plot( IIf( BarsSince( PHigh ) <= nbar, trendline_H_extend, Null ), "", colorLightGrey, styleNoLine | styleDots | styleThick );
- Plot( IIf( BarsSince( PHigh ) > nbar, trendline_H_extend, Null ), "", colorOrange, styleNoLine | styleDots | styleThick );
- _SECTION_BEGIN("Isfandi Technical Viewer");
- //Plot(C,"",ParamColor( "Color", colorBlue ),ParamStyle("Style") );
- //---- pivot points
- GfxSetBkColor(colorBlack);
- GfxSetTextColor( colorGrey50 );
- GfxSelectFont("Edwardian Script ITC", 25, 500, True );
- DayH = TimeFrameGetPrice("H", inDaily, -1);// yesterdays high
- DayL = TimeFrameGetPrice("L", inDaily, -1);//low
- DayC = TimeFrameGetPrice("C", inDaily, -1);//close
- DayO = TimeFrameGetPrice("O", inDaily);// current day open
- HiDay = TimeFrameGetPrice("H", inDaily);
- LoDay = TimeFrameGetPrice("L", inDaily);
- PP = (DayH + DayL + DayO + DayO) / 4 ;
- R1 = (2 * PP) - DayL;
- S1 = (2 * PP) - DayH;
- R2 = PP + R1 - S1;
- S2 = PP + S1 - R1;
- R3 = R2 + (R1 - PP);
- S3 = S2 - (PP - S1);
- radius = 0.1 * Status("pxheight"); // get pixel height of the chart and use 45% for pie chart radius
- textoffset = 0.1 * radius;
- //====================
- GfxSetOverlayMode(0);
- //-Paint Background
- GfxSelectSolidBrush( colorBlack);
- GfxSelectPen( colorPink);
- GfxRoundRect( 2, 14, 880, 33, 32, 32 );
- GfxSetBkMode( 1 );
- GfxSelectFont("Arial", 8, 900);
- // OTHER INDICATOR
- MOMETUM =RSI(14);
- radius = 0.1 * Status("pxheight"); // get pixel height of the chart and use 45% for pie chart radius
- textoffset = 0.1 * radius;
- GfxSelectFont("Arial", 9, 500, True );
- GfxSelectFont("Arial", 9 );
- GfxSetTextColor( colorLime);
- GfxTextOut( "R1 =" + R1, textoffset + 310, 17 );
- GfxSetTextColor( colorLime );
- GfxTextOut( "R2 = " +R2, textoffset + 410, 17 );
- GfxSetTextColor( colorWhite );
- GfxTextOut( "PP = " +PP, textoffset + 210, 17 );
- GfxSetTextColor( colorOrange );
- GfxTextOut( "S1 = " +S1, textoffset + 10, 17 );
- GfxSetTextColor( colorRed );
- GfxTextOut( "S2 = " +S2, textoffset + 110, 17 );
- GfxSelectFont("Arial", 9 );
- _SECTION_END();
- //-Paint Background
- GfxSelectSolidBrush( colorBlack);
- GfxSelectPen( colorBlue);
- GfxRoundRect( 2, 50, 880, 31, 32, 32 );
- GfxSetBkMode( 1 );
- GfxSelectFont("Arial", 8, 900);
- //////////////////////////////////////////////////////////////////////
- _SECTION_BEGIN("Elder Impulse");
- GfxSelectFont("Arial", 9, 500, True );
- ///////////////////////////////////////////////////
- SetChartOptions(0,chartShowArrows|chartShowDates);
- EnableTextOutput(False);
- // User-defined parameter for EMA periods
- EMA_Type = Param("EMA-1, TEMA-2, JMA-3", 2, 1, 3, 1);
- EMA_prds = Param("EMA_periods", 7, 1, 30, 1);
- Std_MACD = Param("Standard MACD? No-0, Yes-1", 1, 0, 1, 1);
- Plot_fashion = Param("Bar+Arrows-1, Impulse Bars-2", 2, 1, 2, 1);
- // Allow user to define Weekly and Monthly Ribbon Location and Height
- WR_P1 = Param("Weekly Ribbon Location", 5.2, -1000, 1000, 0.1);
- WR_P2 = Param("Weekly Ribbon Height", 199, -0.001, 500, 0.1);
- //MR_P1 = Param("Monthly Ribbon Location", 5.2, -1000, 1000, 0.1);
- //MR_P2 = Param("Monthly Ribbon Height", 199, -0.001, 500, 0.1);
- // Compute EMA and MACD Histogram
- if(EMA_Type == 1)
- {
- DayEMA = EMA(Close, EMA_prds);
- }
- if (EMA_Type == 2)
- {
- DayEMA = TEMA(Close, EMA_prds);
- }
- Histogram = MACD() - Signal();
- // Determine if we have an Impulse UP, DOWN or None
- Impulse_Up = DayEMA > Ref(DayEMA, -1) AND Histogram > Ref(Histogram, -1);
- Impulse_Down = DayEMA < Ref(DayEMA, -1) AND Histogram < Ref(Histogram, -1);
- Impulse_None = (NOT Impulse_UP) AND (NOT Impulse_Down);
- // Compute Weekly MACD and determine whether rising or falling
- TimeFrameSet(inWeekly);
- if (Std_MACD == 0)
- {
- MACD_val = MACD(5, Cool);
- Signal_val = Signal(5, 8, 5);
- }
- else
- {
- MACD_val = MACD(12, 26);
- Signal_val = Signal(12, 26, 9);
- }
- Hist_in_w = MACD_val - Signal_val;
- wh_rising = Hist_in_w > Ref(Hist_in_w, -1);
- wh_falling = Hist_in_w < Ref(Hist_in_w, -1);
- wh_none = (NOT wh_rising) AND (NOT wh_falling);
- TimeFrameRestore();
- // Now get Monthly MACD Histogram....
- TimeFrameSet(inMonthly);
- MACD_val = MACD(5, 8);
- Signal_val = Signal(5, 8, 5);
- Hist_in_m = MACD_val - Signal_val;
- mh_rising = Hist_in_m > Ref(Hist_in_m, -1);
- mh_falling = Hist_in_m < Ref(Hist_in_m, -1);
- TimeFrameRestore();
- wh_rising = TimeFrameExpand( wh_rising, inWeekly, expandLast );
- wh_falling = TimeFrameExpand( wh_falling, inWeekly, expandLast);
- wh_none = TimeFrameExpand( wh_none, inWeekly, expandLast);
- mh_rising = TimeFrameExpand(mh_rising, inMonthly, expandLast);
- mh_falling = TimeFrameExpand(mh_falling, inMonthly, expandLast);
- kol = IIf( wh_rising, colorBrightGreen, IIf(wh_falling, colorRed, IIf(wh_none, colorCustom11, colorLightGrey)));
- mkol = IIf( mh_rising, colorBlue, IIf(mh_falling, colorYellow, colorLightGrey));
- if (Plot_fashion == 1)
- {
- }
- else
- {
- bar_kol = IIf(impulse_UP, colorBrightGreen, IIf(impulse_Down, colorRed, colorCustom11));
- }
- Impulse_State = WriteIf(Impulse_Up, "Bulllish", WriteIf(Impulse_Down, "Bearish", "Neutral"));
- GfxSetTextColor( colorYellow );
- GfxTextOut( "IMPULSE STATE = " +Impulse_State, textoffset + 10, 33 );
- // Set the background color for Impulse Status Column
- Impulse_Col = IIf(Impulse_Up, colorGreen, IIf(Impulse_Down, colorRed, colorGrey40));
- // Determine Weekly Trend. Display as Text Column
- Weekly_Trend = WriteIf(wh_rising, "Rising", WriteIf(wh_falling, "Falling", "Flat!"));
- Weekly_Col = IIf(wh_rising, colorGreen, IIf(wh_falling, colorRed, colorLightGrey));
- GfxSetTextColor( colorPink );
- GfxTextOut( "WEEKLT TREND = " +Weekly_Trend, textoffset + 500, 17 );
- // Determine Monthly Trend. Display as Text Column
- Monthly_Trend = WriteIf(mh_rising, "Rising", WriteIf(mh_falling, "Falling", "Flat!"));
- Monthly_Col = IIf(mh_rising, colorGreen, IIf(mh_falling, colorRed, colorLightGrey));
- GfxSetTextColor( colorOrange );
- GfxTextOut( "MONTHLY TREND = " +Monthly_Trend, textoffset + 690, 17 );
- // Determine how many bars has the current state existed
- bars_in_bull = Min(BarsSince(impulse_none), BarsSince(impulse_down));
- bars_in_bear = Min(BarsSince(impulse_up), BarsSince(impulse_none));
- bars_in_neut = Min(BarsSince(impulse_down), BarsSince(impulse_up));
- // Set a single variable to show number of bars in current state depending upon
- // actual Impulse Status - Bullish, Bearish or Neutral
- bars_in_state = IIf(Impulse_Up, bars_in_bull, IIf(Impulse_down, bars_in_bear, bars_in_neut));
- //weekly pivot
- k1=-1;
- SetChartBkColor(16 ) ;
- k=IIf(ParamList("select type","daily|next day")=="daily",-1,0);
- k1=-1;
- TimeFrameSet(inDaily);
- day_h= LastValue(Ref(H,K));
- day_l= LastValue(Ref(L,K));
- day_c= LastValue(Ref(C,K));
- TimeFrameRestore();
- // day
- DH=Day_h;
- DL=Day_L;
- DC=Day_C;
- // DAY PIVOT Calculation
- pd = ( DH+ DL + DC )/3;
- sd1 = (2*pd)-DH;
- sd2 = pd -(DH - DL);
- sd3 = Sd1 - (DH-DL);
- rd1 = (2*pd)-DL;
- rd2 = pd +(DH -DL);
- rd3 = rd1 +(DH-DL);
- WriteVal( StochK(39) - StochK(12) );
- GfxSelectFont("Arial", 8 );
- _SECTION_END();
- _SECTION_BEGIN("STOCHASTIC");
- GfxSelectFont("Arial", 9, 500, True );
- periods = Param( "Periods", 15, 1, 200, 1 );
- Ksmooth = Param( "%K avg", 3, 1, 200, 1 );
- a = StochK( periods , Ksmooth);
- Dsmooth = Param( "%D avg", 3, 1, 200, 1 );
- b = StochD( periods , Ksmooth, DSmooth );
- Buy = Cross( a, b );
- Sell = Cross( b, a );
- STOCH =WriteIf(a>b , "Up","Down");
- GfxSetTextColor( colorYellow );
- GfxTextOut( "Stochastic = " +STOCH, textoffset + 200, 33 );
- GfxSelectFont("Arial", 8 );
- _SECTION_BEGIN("Van K Tharp Efficient Stocks");
- // Mark Keitel 12-05
- // Van K Tharp Efficient Stocks
- GfxSelectFont("Arial", 9, 500, True );
- ATRD180 = ATR(180);
- ATRD90 = ATR(90);
- ATRD45 = ATR(45);
- ATRD20 = ATR(20);
- ATRD5 = ATR(5);
- DifferenceD180 = Close - Ref(Close,-180);
- DifferenceD90 = Close - Ref(Close,-90);
- DifferenceD45 = Close - Ref(Close,-45);
- DifferenceD20 = Close - Ref(Close,-20);
- DifferenceD5 = Close - Ref(Close,-5);
- EfficiencyD180 = IIf(ATRD180!=0,DifferenceD180/ATRD180,1);
- EfficiencyD90 = IIf(ATRD90!=0,DifferenceD90/ATRD90,1);
- EfficiencyD45 = IIf(ATRD45!=0,DifferenceD45/ATRD45,1);
- EfficiencyD20 = IIf(ATRD20!=0,DifferenceD20/ATRD20,1);
- EfficiencyD5 = IIf(ATRD5!=0,DifferenceD5/ATRD5,1);
- Averageeff = (EfficiencyD180 + EfficiencyD90 + EfficiencyD45 +
- EfficiencyD20 ) / 4;
- //Plot( averageeff, "AvgEff", colorLightBlue, styleLine );
- x = Param ( "Add Results to a Watchlist? Yes = 1, No = 2" , 2 , 1 , 2 , 1 ) ; // select whether to add results to watchlist or not
- y = Param("Set Watchlist Number", 25, 2, 60,1); // sets the watchlist number, but reserves the first 2 and last 4 watchlists
- // -------- Parameter Variables for Exploration --------------------------------
- TCH = Param("High close value ", 20, 5, 300, 0.5);
- TCL = Param("Low close value " , 5, 1, 10, 0.25);
- AVP = Param("Period for Avg Vol " , 21, 10, 240, 1);
- SV = Param("Stock minimum Avg Vol " , 125000, 50000, 1000000, 500000);
- // -------------- Organize the exploration results ------------------------------------
- P = Param("Period for Price Delta Comparisons", 1, 1, 120, 1);
- P1 = Param("Period for Other Delta Comparisons", 3, 1, 120, 1);
- PATR = Param("Period for ATR", 5,1,21,1);
- PADX = Param("Period for ADX", 14, 3, 34,1);
- PRSI = Param("Period for RSI", 13, 3, 34,1);
- ADX_TREND =WriteIf(PDI(PADX)>MDI(PADX),"_ TREND UP","_TREND DOWN");
- GfxSetTextColor( colorYellow );
- GfxTextOut( "RSI(14) = " + MOMETUM + ADX_TREND , textoffset + 650,33);
- ADX_14 = ADX(14);
- GfxSetTextColor( colorYellow );
- GfxTextOut( "ADX_TREND = " +ADX_14+ ADX_TREND, textoffset + 380, 33 );
- _SECTION_END();
- _SECTION_BEGIN("Ribbon");
- uptrend=PDI()>MDI()AND Signal()<MACD();
- downtrend=MDI()>PDI()AND Signal()>MACD();
- Plot( 1, /*efines the height of the ribbon in percent of pane width */"ribbon",
- IIf( uptrend, colorGreen, IIf( downtrend, colorRed,IIf(Signal()<MACD(), colorWhite, colorWhite ))), /* choose color */
- styleOwnScale|styleArea|styleNoLabel, -60, 17 );
- _SECTION_END();
- // Supertrend - Translated from Kolier MQ4
- // see: http://kolier.li/indicator/kolier-supertrend-indi
- // translation in Amibroker AFL code by E.M.Pottasch, 2011
- 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];
- }
- }
- }
- }
- SetBarsRequired(sbrAll,sbrAll);
- TrendMode = ParamToggle("TrendMode","Off|On",0);
- ATR_Multiplier = Param("ATR_Multiplier",3,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);
- SetChartOptions(0,chartShowDates);
- Plot( 2,"",IIf(buffer_line_up,colorBrightGreen,colorRed),styleOwnScale|styleArea|styleNoLabel, -400, 80 );
- Plot( 4,"",IIf(buffer_line_down,colorRed,colorBrightGreen),styleOwnScale|styleArea|styleNoLabel, -390, 92 );
- _SECTION_BEGIN("Price Line");
- PriceLineColor=ParamColor("PriceLineColor",colorYellow);
- PriceLevel = ParamField("PriceField", field = 3 );
- Daysback = Param("Bars Back",500,10,900,1);
- FirstBar = BarCount - DaysBack;
- YY = IIf(BarIndex() >= Firstbar,EndValue(PriceLevel),Null);
- Plot(YY,"Current Price",PriceLineColor,ParamStyle("LineStyle",styleLine|styleDashed|styleNoTitle|styleNoLabel|styleThick,maskAll));
- side = Param("side",1,1,1000,2);
- dist = 0;
- for( i = 0; i < BarCount; i++ )
- {
- if(i+side== BarCount) PlotText( "\n " + PriceLevel[ i ], i, YY[ i ]-dist[i], colorRed );
- }
- _SECTION_END();
- _SECTION_BEGIN("Magfied Market Price");
- //Magfied Market Price
- FS=Param("Font Size",15,11,100,1);
- GfxSelectFont("Times New Roman", FS, 700, True );
- GfxSetBkMode( colorWhite );
- GfxSetTextColor( ParamColor("Color",colorBlue) );
- Hor=Param("Horizontal Position",500,1,1200,1);
- Ver=Param("Vertical Position",110,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", 8, 600, True );
- GfxSetBkMode( colorBlack );
- GfxSetTextColor(ParamColor("Color",colorYellow) );
- GfxTextOut(""+DD+" ("+xx+"%)", Hor , Ver+22 );
- _SECTION_END();
- _SECTION_BEGIN("system Ticker");
- 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",880,100,1000,1000);
- y=Param(" yposn",0,40,1000,1);
- GfxSelectSolidBrush( colorPink );
- GfxSelectPen( colorBlack, 2 );
- if ( NewPeriod )
- {
- GfxSelectSolidBrush( colorBlack );
- GfxSelectPen( colorBlack, 2 );
- Say( "New candle" );
- }
- GfxRoundRect( x+55, y+17, x-4, y-2, 0, 0 );
- GfxSetBkMode(1);
- GfxSelectFont( "Arial", 9, 700, False );
- GfxSetTextColor( colorBlack );
- GfxTextOut( "" +SecsToGo+" / "+NumToStr( TimeFrame, 1.0 ), x, y );
- _SECTION_END();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement