![]() | |
|
|
|
|
|
|
|
| ||||
| // Using ZIGZAG
|
| ||||
| var M1, Y, X, Y1, Y2, Y3, Y4: float; var BBOUGHT, SSOLD: boolean; var CHARTSON, DRVI, BAR, N, NMACDPANE, NSIGNAL, NSMA, NPANE, NCOUNT, I, COLOR, LINE, XSERIES, HILO, X1, X2, X3, X4: integer; {+++++++++++++++} ChartsOn := 1; enablenotes(false); hidevolume; { Highlight extreme moves down } for Bar := 0 to BarCount - 1 do begin n := Trunc( CumDown( Bar, #Close, 3 ) ); if n > 9 then n := 9; end; { Wealth-Lab's Master System } { Plot a 14 day Moving Average } nSMA := SMASeries( #Close, 14 ); PlotSeries( nSMA, 0, 978, 1 ); { Some variables } nCount := BarCount(); bBought := false; { Max 1000 shares per position } SetShareCap( 1000 ); { Execute the Trading System } for Bar := 15 to BarCount() - 1 do begin {Long Trading Rules} if CumDown( Bar, #Close, 4 ) = 0 then bBought := false; if (PriceClose( Bar-1 ) < PriceClose( Bar-3 )) and ( CMO( Bar, #Close, 14 ) <= 0 ) then if not bBought then begin BuyAtMarket( Bar + 1, ''); bBought := true; end; if ( CumUp( Bar, #Close, 4 ) >= 9 ) or ( CMO( Bar, #Close, 14 ) >= 50 ) then begin for i := 0 to PositionCount() - 1 do if PositionActive( i ) then if PositionLong( i ) then SellAtMarket( Bar + 1, i, ''); end; {****************} {Short Trading Rules} if CumUp( Bar, #Close, 4 ) = 0 then sSold := false; if not sSold then if ( CumUp( Bar, #Close, 4 ) >= 9 ) or ( CMO( Bar, #Close, 14 ) >= 50 ) then begin ShortAtMarket( Bar + 1, ''); sSold := true; end; if (PriceClose( Bar-1 ) < PriceClose( Bar-3 ))and ( CMO( Bar, #Close, 14 ) <= 0 ) then begin for i := 0 to PositionCount() - 1 do if PositionActive( i ) then if not PositionLong( i ) then CoverAtMarket( Bar + 1, i, ''); end; end; {****************} { Below is tbui's Support/Resistance PlugIn - It displays the most recent up and down trendlines Parameters --------------------------------------------------------} Bar := BarCount() - 20; Color := 900; Line := 0; {High Low AVERAGE For the last 50 bars: . Calculate the diff. between PriceHight and PriceLow . Normalize it with PriceClose . Put it into a new series . Total all them up . Average them with highest and the lowest excluded. ---------------------------------------------------------} x := 0 ; xSeries := CreateSeries(); For i := Bar - 50 to Bar do Begin y := (PriceHigh(i) - PriceLow(i)) / PriceClose(i); y := y * 100 ; SetSeriesValue( i, xSeries, y ); x := x + y; end; x := x - Highest(Bar, xSeries, 50); x := x - Lowest(Bar, xSeries, 50); hilo := Round(x / 48 ); { RESISTANCE LINE . Calculate coordinates of 2 consecutive peaks using hilo as ReversalPct. . Extrapolate the coordinates to the current bar, also 10 bars to the left. . Draw a resistance line. ---------------------------------------------------------} y1 := Peak( Bar, #High, hilo); x1 := Peakbar( Bar, #High, hilo); y2 := Peak( x1, #High, hilo * 2); x2 := Peakbar( x1, #High, hilo * 2); If (x2 <> x1) then Begin x3 := x1 + 20; if (x3 > (BarCount() - 1)) then x3 := BarCount() - 1; y3 := (((y2 - y1) * (x3 - x1)) / (x2 - x1)) + y1; x4 := x2 - 10; y4 := (((y2 - y1) * (x4 - x1)) / (x2 - x1)) + y1; DrawLine( x3, y3, x4, y4, 0, Color, Line); end; { SUPPORT LINE . Same as above ---------------------------------------------------------} y1 := Trough( Bar, #Low, hilo); x1 := Troughbar( Bar, #Low, hilo); y2 := Trough( x1, #Low, hilo * 2); x2 := Troughbar( x1, #Low, hilo * 2); If (x2 <> x1) then Begin x3 := x1 + 20; if (x3 > (BarCount() - 1)) then x3 := BarCount() - 1; y3 := (((y2 - y1) * (x3 - x1)) / (x2 - x1)) + y1; x4 := x2 - 10; y4 := (((y2 - y1) * (x4 - x1)) / (x2 - x1)) + y1; DrawLine( x3, y3, x4, y4, 0, Color, Line); end; { END OF STUDY ================================================== ========} ![]()
|
| ||||
| {$NO_AUTO_EXECUTE} UseUpdatedEma (true); EnableSynch( false ); /////////////////////////////////////////////////////////////////////////////// procedure PlotStochastic (period, line1, line2: integer); begin var slowK, slowD, pane : integer; pane := CreatePane( 60, false, true ); slowK := StochDSeries (period, 3); slowD := SMASeries (slowK, 3); DrawHorzLine( line1, pane, 222, #dotted ); DrawHorzLine( line2, pane, 222, #dotted ); PlotSeriesLabel( StochKSeries (period+3), pane, 222, #dotted, 'Stochastic' ); PlotSeriesLabel( slowK, pane, #red, #Thick, 'Slow K ('+IntToStr(period)+',3)' ); PlotSeriesLabel( slowD, pane, #Blue, #Thin, 'Slow D(3)' ); end; /////////////////////////////////////////////////////////////////////////////// procedure PlotPriceChange (period : integer); begin var series, smoothedSeries, pane : integer; var bar: integer; series := CreateSeries (); for bar := 1 to BarCount - 1 do begin var value: float; value := PriceClose(bar) - PriceClose(bar-1); SetSeriesValue (bar, series, value); end; ; pane := CreatePane( 60, false, true ); DrawHorzLine( 0, pane, #red, #Thin ); //PlotSeriesLabel( series, pane, #green, #Thin, 'PriceChange'); PlotSeriesLabel( smoothedSeries, pane, #red, #Thin, 'EMA ('+IntToStr(period)+')'); end; procedure DisplayPercentChangeForLast5Bars (); begin var count: integer; var text: String; var firstTime: boolean; firstTime := true; text := 'Change(%): '; for count := BarCount-5 to BarCount-1 do begin var val: float; val := (PriceClose(count)-PriceClose(count-1))*100/PriceClose(count-1); //val := (PriceHigh(count)-PriceLow(count))*100/PriceLow(count); //val := (PriceClose(count)-PriceOpen(count))*100/PriceOpen(count); if (firstTime) then begin text := text + ' ' + FormatFloat('#0.00', val); firstTime := false; end else text := text + ', ' + FormatFloat('#0.00', val); end; end; /////////////////////////////////////////////////////////////////////////////// try PlotStochastic (7, 20, 80); except end; // Stochastic Rsi and Bollinger Bands // suggested by YACOVT // from article // Stocks & Commodities Magazine in August 2002 had an article Develpoing A trading System By Dennis D Peterson // Code by Georges // Code Suggestions / Improvements by Glitch // Debugging Gyro // See Topic Post // Stochastic Rsi and Bollinger Bands . looking for script // http://www.wealth-lab.com/cgi-bin/We.../topic?id=3800 var Bar, StandardDev, Periods, ExitBar123, EntryBar1234: integer; var StochRSISer, VolSer, MyBBandLower, MyBBandUpper, WPrice: integer; var rdp1, rdp2, rdv1, adjust1, adjust2, BBpds: integer; var deviations, x, xPrice, bbBottom, bbTop: float; var HowCloseToBBot, HowCloseToBBTop: float; var LongThresholdEntry, BotPercentage, LongThresholdExit, TopPercentage: float; var Entry1, Entry2, Entry3, Entry4: boolean; var Exit1, Exit2, Exit3, Exit4, Exit5, Exit6, Exit7: boolean; var y, Vol, LastUpVol: float; procedure PlotEntryRule( b: boolean; s: string ); begin if b then begin y := y * 0.995; AnnotateChart( s, 0, Bar, y, #Gray, 7 ); end; end; procedure PlotExitRule( b: boolean; s: string ); begin if b then begin y := y * 1.005; AnnotateChart( s, 0, Bar, y, #Gray, 7 ); end; end; StandardDev := 60; Periods := 14; { Set up base StochRSI Series } StochRSISer := StochRSISeries( #Close, Periods ); { Set up average Volume Series } VolSer := SMASeries( #Volume, Periods ); VolSer := DivideSeriesValue( VolSer, 1000000 ); { Create Price Series to Hold Custom BBands } MyBBandLower := CreateSeries; MyBBandUpper := CreateSeries; { Create and Populate Weighted Price Series } WPrice := CreateSeries; for Bar := 0 to BarCount - 1 do begin x := ( 2 * PriceClose( Bar ) + PriceHigh( Bar ) + PriceLow( Bar) ) / 4; SetSeriesValue( Bar, WPrice, x ); end; { Main Loop ... executes once for each bar on chart } ExitBar123 := 0; EntryBar1234 := 0; for Bar := StandardDev to BarCount - 1 do begin rdp1 := Round( StdDev( Bar, StochRSISer, StandardDev ) /0.053 ); rdp2 := Round( StdDev( Bar, StochRSISer, StandardDev ) /0.035 ); rdv1 := Round( StdDev( Bar, VolSer, StandardDev ) ); adjust1 := rdv1 - rdp1 + 11; if adjust1 < 8 then adjust1 := 8; if adjust1 > 12 then adjust1 := 12; adjust2 := rdv1 - rdp2 + 14; if adjust2 < 12 then adjust2 := 12; if adjust2 > 20 then adjust2 := 20; Periods := adjust1; BBpds := adjust2; deviations := 0.0625 * BBpds + 0.75; bbBottom := BBandLower( Bar, WPrice, BBPds, deviations ); bbTop := BBandUpper( Bar, WPrice, BBPds, deviations ); SetSeriesValue( Bar, MyBBandLower, bbBottom ); SetSeriesValue( Bar, MyBBandUpper, bbTop ); HowCloseToBBot := 0.9; LongThresholdEntry := 30; xPrice := GetSeriesValue( Bar, WPrice ); if not ( ( bbTop -bbBottom) = 0.0 ) then botpercentage := Abs( ( xPrice - bbBottom ) / ( bbTop -bbBottom)); if ( ( bbTop -bbBottom) = 0.0 ) then botpercentage := Abs( ( xPrice - bbBottom ) / ( 0.001 + bbTop -bbBottom)); Entry1 := botpercentage - HowCloseToBBot < 0.3; Entry2 := ( PriceClose( Bar ) * 1.05 > BBandLower( Bar, WPrice, BBpds, deviations ) ) and ( StochRSI( Bar, #Close, Periods ) > LongThresholdEntry ); Entry3 := false; if PriceClose( Bar ) > PriceClose( Bar - 1 ) then begin Vol := Volume( Bar ); if Vol > LastUpVol then Entry3 := true; LastUpVol := Vol; end; if not ( (PriceHigh( Bar ) - PriceLow( Bar )) = 0.0 ) then Entry4 := ( PriceClose( Bar ) - PriceOpen( Bar ) ) /( PriceHigh( Bar ) - PriceLow( Bar ) ) > 0.2; if ( (PriceHigh( Bar ) - PriceLow( Bar )) = 0.0 ) then Entry4 := ( PriceClose( Bar ) - PriceOpen( Bar ) ) /( PriceHigh( Bar ) - PriceLow( Bar ) + 0.001 ) > 0.2; { Position Entry Rules } if not LastPositionActive then begin if Entry1 and Entry2 and Entry3 and Entry4 then begin BuyAtMarket( Bar + 1, '' ); SetBackgroundColor( bar+1, #greenbkg) ; end; { See which Entry Conditions were met } y := PriceLow( Bar ); if ( Entry1 and Entry2 and Entry3 and Entry4 ) then PlotEntryRule( True , '1234' ); end else { Position Exit Rules } begin HowCloseToBBTop := 0.7; LongThresholdExit := 70; xPrice := GetSeriesValue( Bar, WPrice ); if not ( ( bbTop -bbBottom) = 0.0 ) then toppercentage := Abs( ( xPrice - bbTop ) / ( bbTop -bbBottom)); if ( ( bbTop -bbBottom) = 0.0 ) then toppercentage := Abs( ( xPrice - bbTop ) / ( 0.001 + bbTop -bbBottom)); Exit1 := StochRSI( Bar, #Close, Periods ) < LongThresholdExit; Exit2 := TopPercentage < HowCloseToBBTop; Print( FloatToStr( TopPercentage ) + #9 + FloatToStr( HowCloseToBBTop ) ); Exit3 := PriceClose( Bar ) > 0.95 * BBandUpper( Bar, #Close, BBpds, deviations ); if Exit1 and Exit2 and Exit3 then ExitBar123 := Bar; Exit4 := PriceClose( Bar ) < BBandLower( Bar, #Close, BBpds, deviations ); Exit5 := ( Bar - ExitBar123 < 4 ); Exit6 := PriceClose( Bar - 1 ) - PriceOpen( Bar - 1 ) < 0; if Entry1 and Entry2 and Entry3 and Entry4 then EntryBar1234 := Bar; Exit7 := ( Bar - EntryBar1234 ) < 2; if ( Exit5 and Exit4 ) then begin SellAtMarket( Bar + 1, LastPosition, '4&5' ) ; SetBackgroundColor(bar+1 , #redbkg) ; end ; if ( Exit6 and Exit7 ) then begin SellAtMarket( Bar + 1, LastPosition, '6&7' ); SetBackgroundColor( bar + 1 , #redbkg) ; end ; { See which Exit Conditions were met } y := PriceHigh( Bar ); if ( Exit6 and Exit7 ) then PlotExitRule( True , '6-7' ); if ( Exit6 and Exit7 ) then PlotExitRule( True , '4-5' ); end; end; { Plot Weighted Price } PlotSeries( WPrice, 0, #Red, #Thin ); { Plot Custom BBands } PlotSeries( MyBBandUpper, 0, 337, #Thick ); PlotSeries( MyBBandLower, 0, 337, #Thick ); HideVolume ![]()
|
| ||||
| var ADXPane, ADXPane1, ADXPane2, ADXPane3, ADXPane4, ADXPane5, ADXPane6, ADXPane7, ADXPane8, ADXPane9, ADXPane10, ADXPane11, ADXPane12, ADXPane13, ADXPane14, ADXPane15, ADXPane16, ADXPane17, ADXPane18, ADXPane19, ADXPane20, ADXPane21, ADXPane22, ADXPane23: integer; var Bar, p: integer; var Cond1, Cond2, Cond3, Cond4, Cond5, Cond6, Cond7, Cond8, Cond9, Cond10, Cond11, Cond12, Cond13, Cond14, Cond15, Cond16, Cond17, Cond18, Cond19, Cond20: boolean; ADXPane := CreatePane( 100, true, true ); PlotSeries( ADXSeries( 14 ), ADXPane, #Blue, #Thick ); PlotSeries( ADXRSeries( 14 ), ADXPane, 002, #Thin ); PlotSeries( DIPlusSeries( 14 ), ADXPane, #Green, #Thin ); PlotSeries( DIMinusSeries( 14 ), ADXPane, #Red, #Thin ); DrawLabel( '14 Bar ***ectional Movement', ADXPane ); for Bar := 20 to BarCount - 1 do begin if LastPositionActive then begin p := LastPosition; Cond1 := false; Cond2 := false; Cond3 := false; Cond4 := false; Cond5 := false; Cond6 := false; Cond7 := false; Cond8 := false; Cond9 := false; Cond10 := false; Cond11 := false; Cond12 := false; Cond13 := false; Cond14 := false; Cond15 := false; Cond16 := false; Cond17 := false; Cond18 := false; Cond19 := false; Cond20 := false; if DIPlus( Bar, 14 ) < DIMinus( Bar, 14 ) then begin Cond1 := true; end; if CrossUnderValue( Bar, ADXSeries( 14 ), 46 ) then begin Cond2 := true; end; if CrossUnderValue( Bar, ADXSeries( 14 ), 44 ) then begin Cond3 := true; end; if CrossUnderValue( Bar, ADXSeries( 14 ), 42 ) then begin Cond4 := true; end; if CrossUnderValue( Bar, ADXSeries( 14 ), 40 ) then begin Cond5 := true; end; if CrossUnderValue( Bar, ADXSeries( 14 ), 38 ) then begin Cond6 := true; end; if CrossUnderValue( Bar, ADXSeries( 14 ), 36 ) then begin Cond7 := true; end; if CrossUnderValue( Bar, ADXSeries( 14 ), 34 ) then begin Cond8 := true; end; if CrossUnderValue( Bar, ADXSeries( 14 ), 32 ) then begin Cond9 := true; end; if CrossUnderValue( Bar, ADXSeries( 14 ), 30 ) then begin Cond10 := true; end; if CrossUnderValue( Bar, ADXSeries( 14 ), 28 ) then begin Cond11 := true; end; if CrossUnderValue( Bar, ADXSeries( 14 ), 26 ) then begin Cond12 := true; end; if CrossUnderValue( Bar, ADXSeries( 14 ), 24 ) then begin Cond13 := true; end; if CrossUnderValue( Bar, ADXSeries( 14 ), 22 ) then begin Cond14 := true; end; if CrossUnderValue( Bar, ADXSeries( 14 ), 20 ) then begin Cond15 := true; end; if CrossUnderValue( Bar, ADXSeries( 14 ), 18 ) then begin Cond16 := true; end; if CrossUnderValue( Bar, ADXSeries( 14 ), 16 ) then begin Cond17 := true; end; if CrossUnderValue( Bar, ADXSeries( 14 ), 14 ) then begin Cond18 := true; end; if CrossUnderValue( Bar, ADXSeries( 14 ), 12 ) then begin Cond19 := true; end; if CrossUnderValue( Bar, ADXSeries( 14 ), 10 ) then begin Cond20 := true; end; if Cond1 or Cond2 or Cond3 or Cond4 or Cond5 or Cond6 or Cond7 or Cond8 or Cond9 or Cond10 or Cond11 or Cond12 or Cond13 or Cond14 or Cond15 or Cond16 or Cond17 or Cond18 or Cond19 or Cond20 then begin SellAtClose( Bar, p, '' ); end; end else begin if not LastPositionActive then begin if ADX( Bar, 14 ) > ADX( Bar - 1, 14 ) then begin if ADX( Bar, 14 ) > 10 then begin if DIPlus( Bar, 14 ) > 25 then begin if DIPlus( Bar, 14 ) > DIPlus( Bar - 1, 14 ) then begin if DIPlus( Bar, 14 ) > DIMinus( Bar, 14 ) then begin BuyAtClose( Bar, '0' ); end; end; end; end; end; end; end; end; DrawHorzLine( 40,ADXPane, #WHITE, #DOTTED ); DrawHorzLine( 20,ADXPane, #WHITE, #DOTTED ); HideVolume; SetColorScheme( #Lime,905, #Olive, 000, 999, #Silver ); ![]()
|
| ||||
| {$I 'ZigZag Study'} function GetZoneGroup( x: float ): integer; begin if x > 80 then Result := 4 else if x < -80 then Result := 1 else if x > 20 then Result := 3 else if x < -20 then Result := 6 else if x > 0 then Result := 2 else Result := 5; end; function GetDevGroup( DevVal: float ): integer; begin Result := Trunc( ( DevVal + 100 ) / 20 ) + 1; if Result > 11 then Result := 11; end; var EMA40, Diff, DevOsc, Bar, DevPane, ZoneSeries, b, Last: integer; var DevHigh, DevLow, Normalized, Range, p, t, x: float; var B1, B2: integer; { Plot an 8 % Zig Zag } HideVolume; ZigZag( 8 ); { Plot 40 period EMA } EMA40 := EMASeries( #Close, 40 ); PlotSeries( EMA40, 0, #Green, #Thick ); { Create Deviation Oscillator } Diff := SubtractSeries( #Close, EMA40 ); DevOsc := CreateSeries; for Bar := 80 to BarCount - 1 do begin DevHigh := Highest( Bar, Diff, 80 ); DevLow := Lowest( Bar, Diff, 80 ); if GetSeriesValue( Bar, Diff ) > 0 then Normalized := GetSeriesValue( Bar, Diff ) * 100 / DevHigh else Normalized := -GetSeriesValue( Bar, Diff ) * 100 / DevLow; SetSeriesValue( Bar, DevOsc, Normalized ); end; { Plot Deviation Oscillator } DevPane := CreatePane( 100, false, true ); SetPaneMinMax( DevPane, -120, 120 ); PlotSeries( DevOsc, DevPane, #Navy, #Thin ); DrawHorzLine( 0, DevPane, #Navy, #Thin ); DrawLabel( 'Deviation Oscillator', DevPane ); { Create 20% Price Zones for ZigZag moves } ZoneSeries := SubtractSeriesValue( CreateSeries, 9999 ); Last := -1; for Bar := 200 to BarCount - 1 do begin B1 := PeakBar( Bar, #Close, 8 ); if B1 = Last then Continue; Last := B1; B2 := TroughBar( B1, #Close, 8 ); for b := B2 to B1 do if b1 <> b2 then SetSeriesValue( b, ZoneSeries, ( b - b2 ) * 100 / ( b1 - b2 ) ); end; Last := -1; for Bar := 200 to BarCount - 1 do begin B1 := TroughBar( Bar, #Close, 8 ); if B1 = Last then Continue; Last := B1; B2 := PeakBar( B1, #Close, 8 ); for b := B2 to B1 do SetSeriesValue( b, ZoneSeries, -( 100 - ( ( b - b2 ) * 100 / ( b1 - b2 ) ) ) ); end; { Color background based on which zone it belongs to } for Bar := 200 to BarCount - 1 do begin x := GetSeriesValue( Bar, ZoneSeries ); if ( x >= 0 ) and ( x <= 20 ) then SetBackgroundColor( Bar, 787 ) else if x > 80 then SetBackgroundColor( Bar, 877 ) else if ( x <= 0 ) and ( x >= -20 ) then SetBackgroundColor( Bar, 778 ) else if ( x < -80 ) and ( x >= -100 ) then SetBackgroundColor( Bar, 887 ); end; { Create Correlation Matrix } type TMatrix = array[1..11] of array[1..6] of float; var arUp: TMatrix; var arDown: TMatrix; var ZoneVal, DevVal: float; var ZoneGroup, DevGroup, DevGroupPrev: integer; DevGroupPrev := -1; for Bar := 200 to BarCount - 1 do begin ZoneVal := GetSeriesValue( Bar, ZoneSeries ); ZoneGroup := 4; x := GetSeriesValue( Bar, ZoneSeries ); ZoneGroup := GetZoneGroup( x ); DevVal := GetSeriesValue( Bar, DevOsc ); DevGroup := GetDevGroup( DevVal ); if DevGroup <> DevGroupPrev then if DevGroupPrev > 0 then if ZoneVal >= -100 then begin if DevGroup > DevGroupPrev then arUp[DevGroup][ZoneGroup] := arUp[DevGroup][ZoneGroup] + 1 else arDown[DevGroup][ZoneGroup] := arDown[DevGroup][ZoneGroup] + 1; end; DevGroupPrev := DevGroup; end; { Dump matrix to debug window } var s: string; Print( 'Correlation Matrix for Up moves' ); for DevGroup := 1 to 11 do begin s := ''; for ZoneGroup := 1 to 6 do s := s + FloatToStr( arUp[DevGroup][ZoneGroup] ) + #9; Print( s ); end; Print( 'Correlation Matrix for Down moves' ); for DevGroup := 1 to 11 do begin s := ''; for ZoneGroup := 1 to 6 do s := s + FloatToStr( arDown[DevGroup][ZoneGroup] ) + #9; Print( s ); end; { Analysis of Current Situation } procedure Predict( ar: TMatrix ); begin var z: integer; var HighVal: float; HighVal := -1; for z := 1 to 6 do if ar[DevGroup][z] > HighVal then begin ZoneGroup := z; HighVal := ar[DevGroup][z]; end; s := 'Predicted Zone ZigZag Zone: '; case ZoneGroup of 1: s := s + 'Buy 2'; 2: s := s + 'Long'; 3: s := s + 'Sell 1'; 4: s := s + 'Sell 2'; 5: s := s + 'Short'; 6: s := s + 'Buy 1'; end; DrawLabel( s, DevPane ); end; x := GetSeriesValue( BarCount - 1, DevOsc ); DevGroup := GetDevGroup( x ); DrawLabel( 'Deviation Oscillator is currently in Zone: ' + IntToStr( DevGroup ), DevPane ); for Bar := BarCount - 2 downto 0 do begin DevGroupPrev := GetDevGroup( GetSeriesValue( Bar, DevOsc ) ); if DevGroupPrev <> DevGroup then begin if DevGroup > DevGroupPrev then begin DrawLabel( 'Moved up from Zone: ' + IntToStr( DevGroupPrev ), DevPane ); Predict( arUp ); end else begin DrawLabel( 'Moved down from Zone: ' + IntToStr( DevGroupPrev ), DevPane ); Predict( arDown ); end; Break; end; end ![]()
|
| ||||
|
|
| ||||
| var MACDPANE, MAC Bar,eBar,bSMA,UpBnd,LoBnd,per1,TrendLB,StopLB,char tpane,P :integer; [IMG]http://******************vb/<a%20href=[/IMG]var ADXPane, ADXPane1, ADXPane2, ADXPane3, ADXPane4, ADXPane5, ADXPane6, ADXPane7, ADXPane8, ADXPane9, ADXPane10, ADXPane11, ADXPane12, ADXPane13, ADXPane14, ADXPane15, ADXPane16, ADXPane17, ADXPane18, ADXPane19, ADXPane20: integer; var Cond1, Cond2, Cond3, Cond4, Cond5, Cond6, Cond7, Cond8,DSIGNAL, Cond9: boolean; var W,LiqPt:float; W:=1.25; {channel halfwidth,StdDev} per1:=50; {period of price and band SMAs} TrendLB:=30; {period of trend lookback} bSMA:=SMASeries(#Close,per1); UpBnd:=AddSeries(bSMA,MultiplySeriesValue (StdDevSeries(#Close,per1),W)); LoBnd:=SubtractSeries(bSMA,MultiplySeriesValue (StdDevSeries(#Close,per1),W)); PlotStops; for Bar:=per1 to BarCount-1 do begin {-----Exit Trades-----} if LastPositionActive then begin eBar:=PositionEntryBar(LastPosition); StopLB:=Round(Max((per1-(Bar-eBar)),10)); LiqPt:=SMA(Bar,#Close,StopLB); if PositionLong(LastPosition) then if LiqPt<@UpBnd[Bar] then SellAtStop(Bar+1,LiqPt,LastPosition,''); if PositionShort(LastPosition) then if LiqPt>@LoBnd[Bar] then CoverAtStop(Bar+1,LiqPt,LastPosition,''); end else {-----Enter Trades-----} begin if PriceClose(Bar)>PriceClose(TrendLB-1) then {if PriceHigh(Bar)<@UpBnd[Bar] then} BuyAtStop(Bar+1,@UpBnd[Bar],''); if PriceClose(Bar)<PriceClose(TrendLB-1) then {if PriceLow(Bar)>@LoBnd[Bar] then} ShortAtStop(Bar+1,@LoBnd[Bar],''); end; end; {-----Plotting-----} PlotSeries(bSMA,0,#blue,#Thick); PlotSeries(UpBnd,0,#red,#Thick); PlotSeries(LoBnd,0,#green,#Thick); DrawLabel('Price SMA - solid line',0); Drawlabel('Up/LoBand - dotted line',0); DrawLabel('LiquidationPt - diamond line',0); for Bar := 20 to BarCount - 1 do begin if PriceClose(bar) > 5000 then setpositionsize(priceclose(bar)*1.1); if LastPositionActive then begin if PositionLong( LastPosition ) then { Long Position Exit Rules } begin if (Aroondown(bar,#close,7) > 99) then SellAtMarket( Bar+1, LastPosition, '' ); end else { Short Position Exit Rules } begin if (Aroonup(bar,#close,7) > 99) then CoverAtMarket( Bar+1, LastPosition, '' ); end; end else begin { Long Position Entry Rules } if (Aroonup(bar,#close,14) = 100) and (Aroondown(bar,#close,14) < 40) then BuyAtMarket( Bar+1,'') { Short Position Entry Rules } else if (Aroonup(bar,#close,14) < 40) and (Aroondown(bar,#close,14) = 100) then ShortAtMarket( Bar+1,''); end; end; chartPane := CreatePane( 75, true, true ); PlotSeries( AroonUpSeries( #Close,14 ), chartpane, 009, #Thin ); PlotSeries( AroonDownSeries( #Close,14 ), chartpane, 905, #Thin ); { This system buys a new position whenever MACD crosses the signal line from below 0. It sells all open positions when MACD crosses below the signal line from above 0. } MACDPane := CreatePane( 75, true, true ); PlotSeries( MACDSeries( #Close ), MACDPane, #blue, #Thick ); MACDSignal := EMASeries( MACDSeries( #Close ), 9 ); PlotSeries( MACDSignal, MACDPane, #red, #Thick ); for Bar := 20 to BarCount - 1 do begin if CrossOver( Bar, MACDSeries( #Close ), MACDSignal ) then if MACD( Bar, #Close ) < 0 then BuyAtMarket( Bar + 1, ''); if CrossUnder( Bar, MACDSeries( #Close ), MACDSignal ) then if MACD( Bar, #Close ) > 0 then for P := 0 to PositionCount - 1 do SellAtMarket( Bar + 1, P, 'MACD' ); end; DrawHorzLine( 0,MACDPane, #green, #Thick ); ADXPane := CreatePane( 100, true, true ); PlotSeries( ADXSeries( 14 ), ADXPane, #Blue, #Thick ); PlotSeries( DIPlusSeries( 14 ), ADXPane, #Green, #Thin ); PlotSeries( DIMinusSeries( 14 ), ADXPane, #Red, #Thin ); DrawLabel( '14 Bar ***ectional Movement', ADXPane ); DrawHorzLine( 20,ADXPane, #bluebkg, #Thick ); DrawHorzLine( 25,ADXPane, #bluebkg, #Thick ); DrawHorzLine( 45,ADXPane, #redbkg, #Thick ); DrawHorzLine( 65,ADXPane, #redbkg, #Thick ); procedure SMA65VolumeColor; begin var Bar, BCnt: integer; // Make sure there is an average even if the symbol has less than 65 bars if BarCount < 66 then BCnt := BarCount else BCnt := 65; // Draw SMA and label in volume pane PlotSeries( SMASeries( #Volume, BCnt ), 1, 009, #Thick ); DrawText( 'SMA(Volume,' + IntToStr(BCnt) + ') = ' + FormatFloat( '#,###', SMA( BarCount - 1, #Volume, BCnt ) ), 1, 4, 4, #Black, 12 ); for Bar := 1 to BarCount - 1 do if PriceClose( Bar ) > PriceClose( Bar - 1 ) then SetSeriesBarColor( Bar, #Volume, #Green ) else SetSeriesBarColor( Bar, #Volume, #Red ); end; SMA65VolumeColor; ">
|
![]() |
| خيارات الموضوع | |
| طريقة العرض | |
| |
مواضيع مشابهة | ||||
| الموضوع | الكاتب | القسم | الردود | آخر مشاركة |
| هبوط مؤشرات الأسواق الخليجية | مال وأعمال | الأسواق الأمريكيه,الأوربيه,الأسيويه للأوراق الماليه | 0 | 01-07-2009 04:49 AM |
| خصائص ووظائف FX AccuCharts | خـدمة العمـلاء | أكاديمية الفوركس Forex | 0 | 23-05-2009 07:59 AM |
| أقسام المنتدى |
| أسـواق المال @ السوق السعودي للأوراق الماليه @ المنتدى العام - General Section @ الــشــكاوي - الإقــتراحات @ المنتدى الإسلامي - Islamic Section @ المنتديات الادارية @ الإشـراف - المراقبة @ الأسواق الخليجيه والعربيه للأوراق الماليه @ عملات - معادن - نفط - فوركس - Forex @ الأقسام العامه @ الطب, طب الاعشاب, الطب البديل, اعشاب طبيه, Health Section @ وظائف - موارد بشرية - وظائف نسائيه Jobs - Human Resources @ مهارات - تطوير النفس - تطوير الذات skills and self-restraint @ برامج التحليل الفني والمؤشرات @ اكاديمية اسواق واعمال الخليج @ أكاديمية الفوركس Forex @ مشاريع تجارية -الإعلانات الفردية والتجارية المجانية @ السياحه - السفر - دليل السياحة -الطقس - الصيد Travel -Weather - Tourism Guide @ برامج,كمبيوتر @ برامج كمبيوتر, برامج كاملة, برامج مجانية, تحميل برامج, PC Applications @ عقار عقارات فلل منازل قصور شاليهات استراحات اراضي اسواق العقار @ أرشيف التحليل الفني @ اتصالات - فضائيات - جوالات satellite - Phones @ أخبار السوق السعودي @ اعلانات الشركات @ تقارير السوق السعودي @ التحليل الفني والأساسي @ أخبار هيئة السوق المالية @ الأسواق الأمريكيه,الأوربيه,الأسيويه للأوراق الماليه @ مقاطع يوتيوب, مشاهد يوتيوب, لقطات يوتيوب, افلام يوتيوب, Youtube @ صدى الملاعب - كووورة - منتديات الرياضة - كرة القدم - Sports Section @ قسم توصيات فوركس | تداول عملات | تجارة عملات | Forex Trading @ قسم التحليلات والأخبار @ الصكوك والسندات @ المواضيع المكرره والمخالفه @ المكتبة الاقتصادية @ ركن نادي Google @ ركن نادي قيمزر Gamezer @ خيمة رمضان, شهر رمضان, رمضان 1431, رمضان 2010 @ |
|
|
![]() |