Author Topic: exploration code  (Read 7949 times)

bharatk8

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
exploration code
« on: September 27, 2010, 01:08:21 pm »
Exploration code is either missing or there is some issue with version,hence I am not able to explore code for   VOLUME INCREASE SUDDENTLY for Amibroker (AFL)    ,which is available in pasties section.I am using version 5.3.                         

administrator

  • Administrator
  • Full Member
  • *****
  • Posts: 200
    • View Profile
Re: exploration code
« Reply #1 on: September 27, 2010, 07:43:46 pm »
You need to set ShowFwd and ShowBack to Yes via the parameters to enable exploration for that formula.

bharatk8

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Re: exploration code
« Reply #2 on: September 28, 2010, 09:16:12 am »
Tried your solution,but it did not work.see imge.Pl, guide

administrator

  • Administrator
  • Full Member
  • *****
  • Posts: 200
    • View Profile
Re: exploration code
« Reply #3 on: September 28, 2010, 07:15:27 pm »
You need to change the parameters in the exploration window not on the chart.

bharatk8

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Re: exploration code
« Reply #4 on: September 29, 2010, 12:09:46 am »
Dear Admin.

Tried solution,but it did not work.See image.Pl. point out my mistake.

administrator

  • Administrator
  • Full Member
  • *****
  • Posts: 200
    • View Profile
Re: exploration code
« Reply #5 on: September 29, 2010, 02:27:50 am »
Hello

I think you are using the wrong formula make sure it is this one:
Code: [Select]
/*   
   VolSpikeDemo_01.afl

   Demo code by Progster in response to:

   http://finance.groups.yahoo.com/group/amibroker/message/124977

   This is Exploration code.

*/


MaxBack = 150;       // maximum number of bars to look back
MaxFwd = 30;         // maximum number of bar to look forward

//   Exploration parameters
ShowBack = ParamToggle("ShowBack","No|Yes",1);
LB = Param("LookBack",1,1,MaxBack,1);      //   LookBack (for vol spikes exactly this many bars ago)

ShowFwd = ParamToggle("ShowFwd","No|Yes",0);
LF = Param("LookFwd",10,1,MaxFwd,1);      //   LookFwd (for vol spikes up to this many bars in the future)

//   Array calculations
MA_V = (MA(V,MaxBack)) ;   
SD_V = StDev(V,MaxBack) ;
VolSpike = Volume > (MA_V + SD_V);

//   Use array function BarsSince() to look back  (convenient and fast)
BarsSinceVolSpike = BarsSince(VolSpike);


//   Use a loop to look forward   (less convenient, less fast)
BarsToVolSpike = -1 ;

if ( ShowFwd )
{
    for ( idx = 0 ; idx < ( BarCount - MaxFwd ); idx++ )
    {
        //   Since jdx is positive, we are looking into the future relative to the current bar
        for ( jdx = 1; jdx < MaxFwd; jdx++ )
        {
            if ( VolSpike[idx + jdx] )
            {
                BarsToVolSpike[idx] = jdx;
                break;
            }
        }
    }
}

//   Set exploration Filter according to whether we are looking back, forward, or both
if(ShowBack AND ShowFwd){
   Filter = (BarsSinceVolSpike == LB) OR (BarsToVolSpike >= 0) ;
}
else if ( ShowBack ){
   Filter = (BarsSinceVolSpike == LB) ;
}
else if ( ShowFwd ){
   Filter = (BarsToVolSpike >= 0) ;
}

//   Info at current bar
AddColumn( DateTime(), "cDate", formatDateTime );      //   c = "current"
/*
AddColumn(Volume, "cVolume" );
AddColumn(MA_V, "cMA_V" );
AddColumn(SD_V, "cSD_V" );
*/

//   Info at the previous VolSpike bar.  p = "previous" or "past"
if ( ShowBack )
{
   // Volume-based calcs with no particular formatting applied
    AddColumn( LB, "BarsBack" );
    AddColumn( Ref( DateTime(), -LB ), "pDate", formatDateTime );
    AddColumn( Ref( Volume, -LB ), "pVolume" );
    AddColumn( Ref( MA_V, -LB ), "pMA_V" );
    AddColumn( Ref( SD_V, -LB ), "pSD_V" );
}

//   Info at the next VolSpike bar.  f = "forward"

if ( ShowFwd )
{
    textColor = colorDefault ;
    BGColor = IIf( BarsToVolSpike < 0, colorRed, colorDefault ) ;      // Use Red BG color if no forward vol spike found

    //   Volume-based calcs formetted to 0 decimals
    AddColumn( BarsToVolSpike, "BarsFwd", 1.0, textColor, BGColor );
    AddColumn( Ref( DateTime(), BarsToVolSpike ), "fDate", formatDateTime, textColor, BGColor );
    AddColumn( Ref( Volume, BarsToVolSpike ), "fVolume", 1.0, textColor, BGColor );
    AddColumn( Ref( MA_V, BarsToVolSpike ), "fMA_V", 1.0, textColor, BGColor );
    AddColumn( Ref( SD_V, BarsToVolSpike ), "fSD_V", 1.0, textColor, BGColor );
}

bharatk8

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Re: exploration code
« Reply #6 on: September 29, 2010, 02:43:42 am »
Just to avoid confusion,copied the code once again from above place and tried to explore.Same error message has popped up.Whats up?

joeoil

  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: exploration code
« Reply #7 on: September 29, 2010, 04:52:40 pm »
Hi

I've tried to run this exploration code which admin posted an it worked fine here. No error message.

Amibroker v. 5.30


Regards

bharatk8

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Re: exploration code
« Reply #8 on: September 29, 2010, 05:09:53 pm »
You are right joe.Tried again.Now it's OK.