[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Reversal signals(wealth script)



PureBytes Links

Trading Reference Links

This look to me a v good code indeed and one can check
it at below mentioned link for varification.Can we
convert the code for AB as well?I am new and setting
my fingures on this amazing software for charts,though
it is a demo version for me right now.



check this link,
http://www.wealth-lab.com/cgi-bin/WealthLab.DLL/editsystem?id=10061

code is below:-
{#OptVar1 10;2;33;1} // 24


// Program StairCase 4
// By Gyro
// Start Date 17-June-02
// End Date 5 July 02

// Description -------------------------
// Staircase System - loosely modelled on Nic. Darvas
// ----------------------------------------


// Only difference , reduced the size of the PA%
printout to screen
// it was getting in the way of the chart -
// didnt relaize that till after I published.




// VARIABLES -----
var Bar, GreenSeries, RedSeries , lookback,
BullPeriod, GreenHiSeries : integer;
var PALength , RedTrend : integer;
var Sell , Buy, HiBand, Old , New , PA : float ;

var BuyFlag, SellFlag , BuyContrarian : Boolean ;


GreenSeries := CreateSeries;
GreenHiSeries := CreateSeries;
RedSeries := CreateSeries;

// use to estimate recent equivalent PA%
RedTrend := CreateSeries;


lookback := #Optvar1 ; // Distance bewteen Buy and
Sell
                          // Long Trend , 14
                          // Choppy / Cylcic 6

// HI limit band - Use to Flag Potential Reversal
------
HiBand := 1.03 ; 

SellFlag := False;
BuyFlag := False;
BuyContrarian := False ;


for Bar := 30 to BarCount - 1 do
Begin
                         
                         
                      
   Sell := 1.0 * GetSeriesValue( Bar, LowestSeries(
#Close, lookback));
   SetSeriesValue( Bar, RedSeries , Sell );

   Buy := GetSeriesValue(Bar,HighestSeries( #Close,
lookback) );
   SetSeriesValue( Bar, GreenSeries , Buy );
   SetSeriesValue( Bar, GreenHiSeries , HiBand * Buy
);


   // Flag Potential Reversal ----------------------
if ( GetSeriesValue(Bar-1,GreenSeries) =
GetSeriesValue(Bar-2, GreenSeries)) and
   ( GetSeriesValue(Bar,GreenSeries) =
GetSeriesValue(Bar-1, GreenSeries)) and
  ( GetSeriesValue(Bar-2,#high ) >
GetSeriesValue(Bar-2, GreenHiSeries)) then
   SetBackgroundColor( Bar, #Maroon );

   // Flag Potential Reversal ----------------------
if ( GetSeriesValue(Bar-3,GreenSeries) <
GetSeriesValue(Bar-2, GreenSeries)) and
   ( GetSeriesValue(Bar-2,GreenSeries) =
GetSeriesValue(Bar-1, GreenSeries)) and
   ( GetSeriesValue(Bar-1,GreenSeries) =
GetSeriesValue(Bar, GreenSeries)) and
  ( GetSeriesValue(Bar-3,#high ) >
GetSeriesValue(Bar-3, GreenhiSeries)) then
   SetBackgroundColor( Bar, #Red );

   // Flag Potential Reversal ----------------------
 if ( GetSeriesValue(Bar,#high ) > GetSeriesValue(Bar,
GreenhiSeries)) and
  ( GetSeriesValue(Bar,#Low ) < GetSeriesValue(Bar,
GreenSeries)) then
   SetBackgroundColor( Bar, #Yellow );


   // Flag the beginning of a drop from green
  if ( GetSeriesValue(Bar-1,GreenSeries) =
GetSeriesValue(Bar, GreenSeries)) and
     ( GetSeriesValue(Bar-1,#High ) >
GetSeriesValue(Bar, GreenSeries)) and
     ( GetSeriesValue(Bar,#Close ) <= 0.94*
GetSeriesValue(Bar, GreenSeries))then
       SetBackgroundColor( Bar, #Purple );






    // BUY RULES ---------------
    if not LastPositionActive then
    begin
      if ( GetSeriesValue(Bar,GreenSeries) >
GetSeriesValue(Bar-1, GreenSeries)) then
      begin
            BuyFlag := True ;
            print('Green rising Buyflag T '+
IntToStr(Bar));
       end;

     if ( GetSeriesValue(Bar,GreenSeries) <
GetSeriesValue(Bar-1, GreenSeries)) then
      begin
            BuyFlag := False ;
            print('Green falling Buyflag F '+
IntToStr(Bar));
       end;

     if ( GetSeriesValue(Bar,GreenSeries) =
GetSeriesValue(Bar-1, GreenSeries)) then
      begin
            BuyFlag := False ;
            print('Green = Buyflag F '+
IntToStr(Bar));
       end;


       if BuyFlag then
          Begin
               BuyAtMarket(Bar + 1, '' ) ;
             // BuyFlag := False;

           end;


        if BuyContrarian then
           Begin
              // BuyAtMarket(Bar + 1, '' ) ;
           end;


    end // Buy Rules
Else
  // SELL RULES ------------------
  begin


     if ( GetSeriesValue(Bar,RedSeries) >
GetSeriesValue(Bar-1, RedSeries)) then
      begin
            SellFlag := False;
            print('red rising sellflag F '+
IntToStr(Bar));

       end;

       if ( GetSeriesValue(Bar,RedSeries) <
GetSeriesValue(Bar-1,RedSeries)) then
      begin
           SellFlag := True;
           print('red falling sellflag T '+
IntToStr(Bar));
      end;



      // Final SELL -----------------------
      If SellFlag Then
      Begin
         SellAtMarket(Bar + 1, LastPosition,'') ;
         SellFlag := False;
      End;

  end; // sell rules


End; // Loop

// Underlying Trend ( Bull or Bear )
RedTrend := SMASeries(RedSeries, 15) ;

// Calculate the Equiv PA%
//SMA( Bar, Series, Period: integer ): float;
PALength := 15 ;
old := GetSeriesValue(Barcount- PALength, RedTrend);
new := GetSeriesValue(Barcount- 1, RedTrend);

PA := 100* (252/PALength ) * ( new -old )/PALength;

DrawText( 'Estimated ' + FormatFloat( '#,##0.',PA) + '
PA% Calc. over the last '+IntToStr(PALength)+' Days',
0 ,5, 220, #Black, 10 );
DrawText('Color Bars = Potential Reversals ' , 0 ,5,
240, #Black, 9 );


PlotSeries( RedSeries ,0, #Red, #Thin) ;
PlotSeries( GreenSeries ,0, #Green, #Thin) ;
PlotSeries( GreenHiSeries ,0, #Lime, #Thin) ;

// Show Underlying Trend
PlotSeries(RedTrend ,0, #Red, #dotted)






__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/GHeqlB/TM
---------------------------------------------------------------------~->

Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/