![]() |
ماشاء الله تبارك الله ماشاء الله لاقوة الا بالله , اللهم اني اسالك الهدى
والتقى والعفاف والغنى
| |
|
|
|
|
|
|
|||||||
|
|
|
|
|
#1 | |
|
|
|
|
|
|
|
|
#2 | |
|
بارك الله فيك
|
|
|
|
|
|
|
#3 | |
|
بعض معادلات الخاصة بالبولينجر في برنامج الويلث لاب ![]() كود:
var Bar,eBar,bSMA,UpBnd,LoBnd,per1,TrendLB,StopLB :integer;
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,#Blue,#Dotted);
PlotSeries(LoBnd,0,#Blue,#Dotted);
DrawLabel('Price SMA - solid line',0);
Drawlabel('Up/LoBand - dotted line',0);
DrawLabel('LiquidationPt - diamond line',0);
//----------------------------------------------------------------------------------------------------------//
var x: float;
|
|
|
|
|
|
|
#4 | |
|
![]() كود:
// 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 ); |
|
|
|
|
|
|
#5 | |
|
![]() كود:
//
// Bollinger BreakOut v.1.1
//
// v.1.1 BreakOut Bar Volume checking
var Bar,ATRPane2,BBWPane: integer;
var BBW,BBAvg,UpperBand,LowerBand: integer;
var BBStdev,PctBBWMin: float;
var cond1:boolean;
//
// Indicator settings
//
BBAvg:=20;
BBStdev:=2.0;
//
UpperBand:=BBandUpperSeries(#Close,BBAvg,BBStdev);
LowerBand:=BBandLowerSeries(#Close,BBAvg,BBStdev);
BBW:= SubtractSeries(BBandUpperSeries(#Close,BBAvg,BBStdev),
BBandLowerSeries(#Close,BBAvg,BBStdev));
//
for Bar:=21 to BarCount-1 do
begin
if @BBW[bar]< (1.75*ATR(bar,1)) then
begin
SetBackgroundColor(Bar,#GreenBkg );
cond1:=true;
end;
if not LastPositionActive then
begin
if cond1
and (PriceClose(bar)>@UpperBand[bar])
and volume(bar)>(volume(bar-1)*1.2)
then
BuyAtClose(Bar,'');
if cond1
and (PriceClose(bar)<@LowerBand[bar])
and volume(bar)>(volume(bar-1)*1.2)
then
ShortAtClose(Bar,'');
end;
if LastPositionActive then
begin
if positionlong (LastPosition )
then
begin //check for sell
if PriceClose(bar)< SMA(Bar, #Close,20) then
begin
SellAtClose(Bar,LastPosition,'');
cond1:=false;
end;
end
else
begin //check for cover
if PriceClose(bar)> SMA(Bar, #Close,20) then
begin
CoverAtClose(Bar,LastPosition,'');
cond1:=false;
end;
end;
end;
end;
//
// Draw Charts
//
BBWPane:=CreatePane(75,true,true);
PlotSeries(BBW,BBWPane,522,#Thin);
DrawLabel('Band Width(20,2)',BBWPane);
ATRPane2:=CreatePane(75,true,true);
PlotSeries(ATRSeries(1),ATRPane2,522,#Thin);
DrawLabel('ATR(1)',ATRPane2);
PlotSeries(BBandLowerSeries(#Close,20,2),0,009,#Thin);
DrawLabel('BBandLower(Close,20,2)',0);
PlotSeries(BBandUpperSeries(#Close,20,2),0,900,#Thin);
DrawLabel('BBandUpper(Close,20,2)',0);
PlotSeries(SMASeries(#Close,20),0,#Green,#Thin);
|
|
|
|
|
|
|
#6 | |
|
مشكورة يا مولي
|
|
|
|
|
|
|
#7 | |
|
|
|
|
|
|
![]() |
| مواقع النشر (المفضلة) |
| الذين يشاهدون محتوى الموضوع الآن : 1 ( الأعضاء 0 والزوار 1) | |
| أدوات الموضوع | |
| انواع عرض الموضوع | |
|
|
المواضيع المتشابهه
|
||||
| الموضوع | كاتب الموضوع | المنتدى | مشاركات | آخر مشاركة |
| البولنجر بانس Bollinger Bands | ابـــ البادية ـــن | التحليل الفني والأساسي | 13 | 04-01-2009 05:01 AM |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27