عضو مميز
تاريخ التسجيل: Nov 2013
المشاركات: 801
| رد: معادلة الزجزاج اقتباس:
المشاركة الأصلية كتبت بواسطة bohaneen11
اذا خابرين للايمي بروكر نكون شاكرين لكم | كود PHP: _SECTION_BEGIN("ZIG-ZAG"); Z=Param("zig",1,0,10,0.1); Plot( z1 = Zig(C,z), "Zig-zag Indicator" + _PARAM_VALUES(), ParamColor("Zig-zag color", colorOrange ), ParamStyle("Zig-zag style") ); Buy = Cover = Zig(C,z)>Ref(Zig(C,z),-1) AND Ref(Zig(C,z),-2)>Ref(Zig(C,z),-1); Sell = Short = Zig(C,z)<Ref(Zig(C,z),-1) AND Ref(Zig(C,z),-2)<Ref(Zig(C,z),-1); Buy=ExRem(Buy,Sell); Sell=ExRem(Sell,Buy); Short=ExRem(Short,Cover); Cover=ExRem(Cover,Short); Filter = Buy OR Sell; PlotShapes(IIf(Buy, shapeCircle, shapeNone),colorGreen, 0,BuyPrice, 0); PlotShapes(IIf(Sell, shapeCircle, shapeNone),colorRed, 0,SellPrice, 0); dist = 1.5*ATR(10); for( i = 0; i < BarCount; i++ ) { if( Buy[i] ) PlotText( "BUY\n"+C[ i ], i, BuyPrice[i]-dist[i],colorWhite, colorGreen ); if( Sell[i] ) PlotText( "SELL\n"+C[ i ], i, SellPrice[i]+dist[i],colorWhite, colorRed ); //if( Short[i] ) PlotText( "Short\n@" + C[ i ], i, H[ i ]+dist[i], colorRed, colorYellow ); //if( Cover[i] ) PlotText( "Cover\n@" + C[ i ], i, L[ i ]-dist[i],colorGreen ); } و كود PHP: _SECTION_BEGIN("Reversal"); Reversal = Param( _DEFAULT_NAME(), 01.0,0.01,20,0.01); _SECTION_END(); ZigZArray = Avg; ZigZArray = Null; ValFromPro=0; ValToPro=0; ValRead=0; BarFromPro=0; BarToPro=0; BarRead=0; ProcessUndef = 10; ProcessIncrease = 11; ProcessDecrease = 12; Process = ProcessUndef; ValFromPro=Avg[0]; ValToPro=Avg[0]; BarFromPro=0; BarToPro=0; BarRead=0; function FillLine( startbar, startval, endbar, endval ) { for( j = startbar; j <= endbar; j++ ) { ZigZArray[ j ] = startval + (( j - startbar) * (endval-startval)/( endbar - startbar )); } } function TrtUndef( ) { if ( ValRead > ( ((100 + Reversal)/100 ) * ValFromPro ) )///If rupture Increase { Process = ProcessIncrease; ValToPro=ValRead; BarToPro=BarRead; } else { if ( ValRead < ( ((100- Reversal)/100 ) * ValFromPro ) ) // If rupture Decrease { Process = ProcessDecrease; ValToPro=ValRead; BarToPro=BarRead; } else { Process = ProcessUndef; } } } function TrtIncrease( ) { if ( ValRead > ValToPro ) // Still Increase { Process = ProcessIncrease; ValToPro=ValRead; BarToPro=BarRead; } else // Break Increase Process { if ( ValRead < ( ((100- Reversal)/100 ) * ValToPro ) ) // If break Decrease { Process = ProcessDecrease; ValFromPro=ValToPro; BarFromPro=BarToPro; ValToPro=ValRead; BarToPro=BarRead; } } } function TrtDecrease( ) { if ( ValRead < ValToPro ) // Still Decrease { Process = ProcessDecrease; ValToPro=ValRead; BarToPro=BarRead; } else // Break Decrease Process { if ( ValRead > ( ( (100+ Reversal)/100 ) * ValToPro ) ) // If break Decrease { Process = ProcessIncrease; ValFromPro=ValToPro; BarFromPro=BarToPro; ValToPro=ValRead; BarToPro=BarRead; } } } for( i = 1; i < BarCount; i++ ) { ValRead = Avg[i]; BarRead = i; if ( Process == ProcessUndef ) { TrtUndef(); } else { if ( Process == ProcessIncrease ) { TrtIncrease(); } else { TrtDecrease(); } } if ( BarToPro == BarRead ) FillLine( BarFromPro, ValFromPro, BarToPro, ValToPro ); else FillLine( BarToPro, ValToPro, BarRead, ValRead ); } _SECTION_BEGIN("avg"); SetChartOptions(0,chartShowArrows); Plot( Avg, _DEFAULT_NAME(), ParamColor("Color", colorBlack ), ParamStyle("Style", styleLine + styleDots, maskPrice ) ); _SECTION_END(); _SECTION_BEGIN("ZigZArray"); Plot( ZigZArray, _DEFAULT_NAME(), ParamColor("Color", colorRed ), ParamStyle("Style", styleLine + styleThick) ); _SECTION_END();
و كود PHP: //z_ZigZagValid // ******** CHARTING PercentChange = 6; mystartbar = SelectedValue(BarIndex()); // FOR GRAPHING mystartbardate = LastValue(ValueWhen(mystartbar == BarIndex(), DateNum(),1)); InitialValue = LastValue(ValueWhen(mystartbardate == DateNum(), C , 1 ) ) ; Temp1 = IIf(BarIndex() >= mystartbar, InitialValue, Null) ; Plot(Temp1, " ", colorBlack,styleLine); Plot((1+(LastValue(PercentChange)/100))*(Temp1), " ", colorGreen, styleLine) ; Plot((1-(LastValue(PercentChange)/100))*(Temp1), " ", colorRed, styleLine) ; ZZ = Zig(C,LastValue(PercentChange)) ; PivotLow = Ref(IIf(Ref(ROC(ZZ,1),-1) < 0 AND ROC(ZZ,1) > 0, 1, Null),1); PivotHigh = Ref(IIf(Ref(ROC(ZZ,1),-1) > 0 AND ROC(ZZ,1) < 0, 1, Null),1); PlotShapes( shapeCircle*PivotLow, colorGreen,0, L, -20) ; PlotShapes( shapeCircle*PivotHigh,colorRed,0,H, 20) ; Buy_Valid = IIf(C>(1+(LastValue(PercentChange)/100))*(ValueWhen(PivotLow, C, 1)) AND ROC(ZZ,1) > 0,1,0); Sell_Valid = IIf(C<(1-(LastValue(PercentChange)/100))*(ValueWhen(PivotHigh, C, 1)) AND ROC(ZZ,1) < 0,1,0); Buy_Valid = ExRem(Buy_Valid,Sell_Valid); Sell_Valid = ExRem(Sell_Valid,Buy_Valid); PlotShapes( shapeUpArrow*Buy_Valid, colorGreen,0, L, -20); PlotShapes( shapeDownArrow*Sell_Valid, colorRed,0,H, -20) ; |