{#OptVar1 4;2;4;1} //Optimierung fuer Days, hier 4 eingestellt {#OptVar2 20;10;40;1} //Optimierung fuer SMA, hier 20 eingestellt var BBUp, BBLow: integer; var Bar, p: integer; BBUp := BBandUpperSeries( #Close, 20, 2 ); BBLow := BBandLowerSeries( #Close, 20, 2 ); PlotSeries( SMASeries( #Close, 20 ), 0, #Teal, #Thick ); PlotSeries( BBUp, 0, 559, #Thick ); PlotSeries( BBLow, 0, 559, #Thick ); InstallTimeBasedExit( #OptVar1 ); for Bar := 20 to BarCount - 1 do begin ApplyAutoStops( Bar ); if LastPositionActive then begin p := LastPosition; if CrossOver( Bar, #Close, BBUp ) or CrossUnder( Bar, #Close, SMASeries( #Close, #OptVar2 ) ) then begin SellAtMarket( Bar + 1, p, '' ); end; end else begin if not LastPositionActive then begin if CrossOver( Bar, #Close, SMASeries( #Close, #OptVar2 ) ) then begin BuyAtMarket( Bar + 1, '0' ); end; end; end; end;
|
|
|
{#OptVar1 4;2;4;1} //Optimierung fuer Days, hier 4 eingestellt{#OptVar2 20;10;40;1} //Optimierung fuer SMA, hier 20 eingestellt var BBUp, BBLow: integer; var Bar, p: integer; BBUp := BBandUpperSeries( #Close, 20, 2 ); BBLow := BBandLowerSeries( #Close, 20, 2 ); PlotSeries( SMASeries( #Close, 20 ), 0, #Teal, #Thick ); PlotSeries( BBUp, 0, 559, #Thick ); PlotSeries( BBLow, 0, 559, #Thick ); InstallTimeBasedExit( #OptVar1 ); for Bar := 20 to BarCount - 1 do begin ApplyAutoStops( Bar ); if LastPositionActive then begin p := LastPosition; if CrossOver( Bar, #Close, BBUp ) or CrossUnder( Bar, #Close, SMASeries( #Close, #OptVar2 ) ) then begin SellAtMarket( Bar + 1, p, '' ); end; end else begin if not LastPositionActive then begin if CrossOver( Bar, #Close, SMASeries( #Close, #OptVar2 ) ) then begin BuyAtMarket( Bar + 1, '0' ); end; end; end; end;
var BAR, APos, MyRSI, PaneRSI, Undervalued: Integer; Undervalued := 0; PaneRSI := CreatePane( 100, true, false ); SetPaneMinMax( PaneRSI, 0, 100 ); PlotSeries( RSISeries( #Close, 14 ), PaneRSI, #Navy, #Thick ); DrawHorzLine( 30, PaneRSI , #Silver, #Dotted ); DrawHorzLine( 70, PaneRSI , #Silver, #Dotted ); DrawHorzLine( 50, PaneRSI , #Gray, #Dotted ); for Bar := 15 to BarCount() - 1 do begin if EMA( Bar, #Close, 4 ) - EMA( Bar-1, #Close, 4 ) < 0 then begin for aPos := 0 to PositionCount() - 1 do if PositionActive( aPos ) then SellAtMarket( Bar + 1, aPos, ''); end; if RSI( Bar, #Close, 14 ) <= 30 then begin Undervalued := 1; end; if (Undervalued = 1) then if ( EMA (Bar, #Close, 5) - EMA(Bar -1, #Close, 5) > 0) then begin BuyAtMarket( Bar + 1, ''); Undervalued := 0; end; end;
{ The trading system below buys a position whenever MFI crosses below 25. It sells all open positions as soon as MFI crosses above 75. The ChartScript also colors MFI bars red and green to show oversold/overbought levels. } var MFIPANE, BAR, P: integer; MFIPane := CreatePane( 100, true, true ); PlotSeries( MFISeries( 14 ), MFIPane, #Blue, #Thick ); DrawLabel( 'MFI14 ', MFIPane ); for Bar := 3 to BarCount - 1 do begin DrawHorzLine( 80,mfiPane, #red, #thin ); DrawHorzLine( 50,mfiPane, #yellow, #dotted ); DrawHorzLine( 20,mfiPane, #green, #thin ); if CrossoverValue( Bar, MFISeries( 14 ), 20) then BuyAtMarket( Bar + 1, ''); if CrossUnderValue( Bar, MFISeries( 14 ), 75) then for P := 0 to PositionCount - 1 do if PositionActive( P ) then SellAtMarket( Bar + 1, P, 'MFI' ); if MFI( Bar, 14 ) < 20 then SetSeriesBarColor( Bar, MFISeries( 14 ), #Green ); if MFI( Bar, 14 ) > 75 then SetSeriesBarColor( Bar, MFISeries( 14 ), #red ); end; var lrBar1, lrBar2: integer; var lrPrice1, lrPrice2: float; var sd: float; lrBar1 := BarCount - 66; lrBar2 := BarCount - 1; lrPrice2 := LinearReg (BarCount - 1, #close, 65); lrPrice1 := lrPrice2 - (65 * LinearRegSlope (BarCount - 1, #close, 65)); sd := stddev (BarCount - 1, #close, 65); DrawLine (lrBar1,lrPrice1,lrBar2,lrPrice2,0, #Red, #solid); DrawLine (lrBar1,lrPrice1+(1.5*sd),lrBar2,lrPrice2+(1.5*sd) ,0, #Blue, #solid); DrawLine (lrBar1,lrPrice1-(1.5*sd),lrBar2,lrPrice2-(1.5*sd),0, #Blue, #solid); DrawLine (lrBar1,lrPrice1+(3*sd),lrBar2,lrPrice2+(3*sd),0, #Green, #solid); DrawLine (lrBar1,lrPrice1-(3*sd),lrBar2,lrPrice2-(3*sd),0, #Green, #solid); print (floattostr (lrPrice2+(3*sd))); print (floattostr (lrPrice2+(1.5*sd))); print (floattostr (lrPrice2)); print (floattostr (lrPrice2-(1.5*sd))); print (floattostr (lrPrice2-(3*sd))); AnnotateChart ('LR', 0, BarCount - 66, lrPrice1, #blue, 12); AnnotateChart ('1.5SD', 0, BarCount - 66, lrPrice1+(1.5*sd), #blue, 12); AnnotateChart ('1.5SD', 0, BarCount - 66, lrPrice1-(1.5*sd), #blue, 12); AnnotateChart ('3SD', 0, BarCount - 66, lrPrice1+(3*sd), #blue, 12); AnnotateChart ('3SD', 0, BarCount - 66, lrPrice1-(3*sd), #blue, 12); var MPane, MHist: integer; MHist := SubtractSeries( MACDSeries( #Close ), EMASeries( MACDSeries( #Close ), 9 ) ); MPane := CreatePane( 100, true, true ); PlotSeries( MACDSeries( #Close ), MPane, #Maroon, #Thick ); PlotSeries( EMASeries( MACDSeries( #Close ), 9 ), MPane, 209, #Thin ); PlotSeries( MHist, MPane, 444, #Histogram ); DrawLabel( 'MACD and 9 period Signal Line', MPane ); Bar := BarCount - 1; if CrossOverValue( Bar, MHist, 0 ) then begin BuyAtMarket( Bar + 1, '' ); end;
{ The trading system below buys a position whenever MFI crosses below 25.It sells all open positions as soon as MFI crosses above 75. The ChartScript also colors MFI bars red and green to show oversold/overbought levels. } var MFIPANE, BAR, P: integer; MFIPane := CreatePane( 100, true, true ); PlotSeries( MFISeries( 14 ), MFIPane, #Blue, #Thick ); DrawLabel( 'MFI14 ', MFIPane ); for Bar := 3 to BarCount - 1 do begin DrawHorzLine( 80,mfiPane, #red, #thin ); DrawHorzLine( 50,mfiPane, #yellow, #dotted ); DrawHorzLine( 20,mfiPane, #green, #thin ); if CrossoverValue( Bar, MFISeries( 14 ), 20) then BuyAtMarket( Bar + 1, ''); if CrossUnderValue( Bar, MFISeries( 14 ), 75) then for P := 0 to PositionCount - 1 do if PositionActive( P ) then SellAtMarket( Bar + 1, P, 'MFI' ); if MFI( Bar, 14 ) < 20 then SetSeriesBarColor( Bar, MFISeries( 14 ), #Green ); if MFI( Bar, 14 ) > 75 then SetSeriesBarColor( Bar, MFISeries( 14 ), #red ); end;var lrBar1, lrBar2: integer; var lrPrice1, lrPrice2: float; var sd: float;lrBar1 := BarCount - 66; lrBar2 := BarCount - 1; lrPrice2 := LinearReg (BarCount - 1, #close, 65); lrPrice1 := lrPrice2 - (65 * LinearRegSlope (BarCount - 1, #close, 65));sd := stddev (BarCount - 1, #close, 65);DrawLine (lrBar1,lrPrice1,lrBar2,lrPrice2,0, #Red, #solid); DrawLine (lrBar1,lrPrice1+(1.5*sd),lrBar2,lrPrice2+(1.5*sd) ,0, #Blue, #solid); DrawLine (lrBar1,lrPrice1-(1.5*sd),lrBar2,lrPrice2-(1.5*sd),0, #Blue, #solid); DrawLine (lrBar1,lrPrice1+(3*sd),lrBar2,lrPrice2+(3*sd),0, #Green, #solid); DrawLine (lrBar1,lrPrice1-(3*sd),lrBar2,lrPrice2-(3*sd),0, #Green, #solid);print (floattostr (lrPrice2+(3*sd))); print (floattostr (lrPrice2+(1.5*sd))); print (floattostr (lrPrice2)); print (floattostr (lrPrice2-(1.5*sd))); print (floattostr (lrPrice2-(3*sd)));AnnotateChart ('LR', 0, BarCount - 66, lrPrice1, #blue, 12); AnnotateChart ('1.5SD', 0, BarCount - 66, lrPrice1+(1.5*sd), #blue, 12); AnnotateChart ('1.5SD', 0, BarCount - 66, lrPrice1-(1.5*sd), #blue, 12); AnnotateChart ('3SD', 0, BarCount - 66, lrPrice1+(3*sd), #blue, 12); AnnotateChart ('3SD', 0, BarCount - 66, lrPrice1-(3*sd), #blue, 12);var MPane, MHist: integer; MHist := SubtractSeries( MACDSeries( #Close ), EMASeries( MACDSeries( #Close ), 9 ) ); MPane := CreatePane( 100, true, true ); PlotSeries( MACDSeries( #Close ), MPane, #Maroon, #Thick ); PlotSeries( EMASeries( MACDSeries( #Close ), 9 ), MPane, 209, #Thin ); PlotSeries( MHist, MPane, 444, #Histogram ); DrawLabel( 'MACD and 9 period Signal Line', MPane ); Bar := BarCount - 1; if CrossOverValue( Bar, MHist, 0 ) then begin BuyAtMarket( Bar + 1, '' ); end;
الكلمات الدلالية (Tags) |
لبرنامج, مؤشرات, تنصيب, خصائص, pro, wealthlab |
أدوات الموضوع | |
تعليمات المشاركة |
لا تستطيع إضافة مواضيع جديدة
لا تستطيع الرد على المواضيع
لا تستطيع إرفاق ملفات
لا تستطيع تعديل مشاركاتك
BB code is متاحة
الابتسامات متاحة
كود [IMG] متاحة
كود HTML معطلة
|