Strategy in (Welath-lab), I want (amibroker) !

#1
hi all ..

Strategy in (Welath-lab) , Dr. Joe i think :(



Code:
var Bar,MACDPane,MyMACD,MyMACDHisto ,nPrev ,n: integer;
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);
SetColorScheme( #GREEN,  #RED, #Olive, #black, #Gray, #Silver );
DrawLine (lrBar1,lrPrice1,lrBar2,lrPrice2,0, #yellow, #solid);
DrawLine (lrBar1,lrPrice1+(1.5*sd),lrBar2,lrPrice2+(1.5*sd),0, #silver, #solid);
DrawLine (lrBar1,lrPrice1-(1.5*sd),lrBar2,lrPrice2-(1.5*sd),0, #silver, #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, #silver, 12);
AnnotateChart ('1.5SD', 0, BarCount - 66, lrPrice1+(1.5*sd), #silver, 12);
AnnotateChart ('1.5SD', 0, BarCount - 66, lrPrice1-(1.5*sd), #silver, 12);
AnnotateChart ('3SD', 0, BarCount - 66, lrPrice1+(3*sd), #silver, 12);
AnnotateChart ('3SD', 0, BarCount - 66, lrPrice1-(3*sd), #silver, 12);
var x: float;
PlotSeries( wMASeries( #Close, 200 ), 0, #Red, #Thin );
x := wMA( BarCount - 1, #Close, 200 );

PlotSeries( wMASeries( #Close,100 ), 0, #Olive, #Thin );
x := wMA( BarCount - 1, #Close, 100 );

PlotSeries( wMASeries( #Close, 20 ), 0, #Blue, #Thin );
x := wMA( BarCount - 1, #Close, 20 );

function SR( hi, lo, cl: float ): string;
begin
  var histr: string = formatfloat( '##.####', hi );
  var lostr: string = formatfloat( '##.####', lo );
  var clstr: string = formatfloat( '##.####', cl );

 Result := ' '
+'function flComputeAll(form) {'
+' var hi = eval(form.high.value);'
+' var lo = eval(form.low.value);'
+' var cl = eval(form.close.value);'
+' var p1 = (hi + lo + cl) / 3;'
+' var r1 = (2 * p1) - lo;'
+' var s1 = (2 * p1) - hi;'
+' var r2 = p1 - s1 + r1;'
+' var s2 = p1 - (r1 - s1);'
+' form.result1.value = fxPrec(r2,2,false);'
+' form.result2.value = fxPrec(r1,2,false);'
+' form.result3.value = fxPrec(p1,2,false);'
+' form.result4.value = fxPrec(s1,2,false);'
+' form.result5.value = fxPrec(s2,2,false);'
+'}'
+'function maketable() {'
+' var x = 130;'
+' var y = 120;'
+' var t = "<"+"form>"'
+'  + fxTHead(fx_w)'
+'  + fxTTitle(2,"S-R Calculator")'
+'  + "<"+"tr>" + fxTEnter("All",2) + "<"+"/tr>"'
+'  + "<"+"tr>" + fxTItem("High",1,x) + fxTInput("high",y, "value='+histr+'", "")  + "<"+"/tr>"'
+'  + "<"+"tr>" + fxTItem("Low",1,x)  + fxTInput("low",y, "value='+lostr+'", "")   + "<"+"/tr>"'
+'  + "<"+"tr>" + fxTItem("Close",1,x)+ fxTInput("close",y, "value='+clstr+'", "") + "<"+"/tr>"'
+'  + "<"+"/table><"+"br>"'
+''
+'  + fxTHead(fx_w)'
+'  + "<"+"tr>" + fxTColmn("Results",2) + "<"+"/tr>"'
+'  + "<"+"tr>" + fxTItem("Resistance 2",1,x) + fxTInput("result1",y,fx_r) + "<"+"/tr>"'
+'  + "<"+"tr>" + fxTItem("Resistance 1")     + fxTInput("result2",y,fx_r) + "<"+"/tr>"'
+'  + "<"+"tr>" + fxTItem("Pivot")            + fxTInput("result3",y,fx_r) + "<"+"/tr>"'
+'  + "<"+"tr>" + fxTItem("Support 1")        + fxTInput("result4",y,fx_r) + "<"+"/tr>"'
+'  + "<"+"tr>" + fxTItem("Support 2")        + fxTInput("result5",y,fx_r) + "<"+"/tr>"'
+'  + "<"+"/table><"+"br>"'
+'  + fxTHead(fx_b)'
+'  + "<"+"td>"+fxCalcBtn("flComputeAll")+"<"+"/td>"'
+'  + "<"+"/table><"+"/form>";'
+' document.write(t);'
+'}'
+'function fcCFactors() {'
+' maketable();'
+'}'
+'fcCFactors();';
end;





procedure FibRetrace;
begin
  var Bar, b1, b2, b: integer;
  var p1, p2, Decline, r50, r382, r618: float;
  Bar := BarCount - 1 ;
  b2 := TroughBar( Bar, #Low, 20 );
  p2 := Trough( Bar, #Low, 20 );
  b1 := PeakBar( b2, #High, 20 );
  p1 := Peak( b2, #High, 20 );
  Decline := p1 - p2;
  r50 := p2 + Decline * 0.5;
  r382 := p2 + Decline * 0.382;
  r618 := p2 + Decline * 0.618;

end;
 { Create a new chart pane to hold our MACD indicator }
MACDPane := CreatePane( 100, TRUE, TRUE );
{Develop the 12,26 MACD Oscillator}
MyMACD := CreateSeries();
for Bar := 26 to BarCount () - 1 do
SetSeriesValue ( Bar, MyMACD, EMA( Bar, #close, 12) - EMA( Bar, #close,26 ) );
{ Set the series for the MACD Histogram }
MyMACDHisto := CreateSeries();
for Bar := 26 to BarCount () - 1 do
SetSeriesValue ( Bar, MyMACDHisto, ((EMA( Bar, #close, 12) - EMA( Bar, #close,26 ))) - EMA(Bar, MyMACD, 9 )) ;
{Plot the 12,26 MACD}
PlotSeries( MyMACD, MACDPane, #red, #Thin ) ;
{Plot a 9 day MACD signal line}
PlotSeries( EMASeries( MyMACD, 9 ), MACDPane, #Blue, #dotted ) ;
{Plot the MACD Histogram}
PlotSeries( MyMACDHisto,MACDPane, 999, #ThickHist) ;
DrawText( '    maccd  ',MACDPane, 4, 4, #white, 10 );
for Bar := 0 to BarCount - 1 do
begin
      if (@MyMACDHisto[bar] > 0) then
        SetSeriesBarColor( Bar, MyMACDHisto, #green )
      else if (@MyMACDHisto[bar] < 0) then
        SetSeriesBarColor( Bar, MyMACDHisto, #red );

end;
{ Flag bars that are 5% Troughs }
for Bar := 0 to BarCount - 1 do
begin
  n := TroughBar( Bar, #Low, 30 );
  if ( n <> nPrev ) and ( n > -1 ) then
  begin
    DrawCircle( 10, 0, n, PriceLow( n ), #white, #Thick );
    SetBarColor (bar,599);
    nPrev := n;
{ Draw the result of our commentary to the volume pane }
var COMMENTARYSTRING: string;
 CommentaryString := 'by M O L Y ^_^';
DrawText( CommentaryString, 0 , 300, 4, 345,15 );

  end;
end;
 HideVolume
 

Similar threads