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

RE: [amibroker] Re: Replicating Studies; Simplified approach; Automatic Range Selection [1 Attachment]


  • To: <amibroker@xxxxxxxxxxxxxxx>
  • Subject: RE: [amibroker] Re: Replicating Studies; Simplified approach; Automatic Range Selection [1 Attachment]
  • From: "Joris Schuller" <jschuller@xxxxxxxxxxx>
  • Date: Mon, 19 Oct 2009 01:03:33 -0500

PureBytes Links

Trading Reference Links

<*>[Attachment(s) from Joris Schuller included below]

I decided to add an automatic highest high and lowest low determination
within the visible range (Option 0). The outer lines will be drawn outside
those values. # of divisions (# of lines -1) is selected through the imax
parameter.

//Repl Study Simpl Complete.afl
Title = EncodeColor(4)+ _DEFAULT_NAME()+";  "+EncodeColor(1) +
StrFormat("{{NAME}} - {{INTERVAL}}; {{DATE}}; O=%g, H=%g, L=%g, C=%g
(%.1f%%) 
{{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) );    
Plot(C, "Close",1,64); //has to be before Include statement
#include <Repl Study Simplified.afl>
//============= Repl Study Simplified.afl
============================================================================
=======================================
Title = EncodeColor(4)+ _DEFAULT_NAME()+";  "+EncodeColor(1) +
StrFormat("{{NAME}} - {{INTERVAL}}; {{DATE}}; O=%g, H=%g, L=%g, C=%g
(%.1f%%) 
{{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) );	

/* 0.  General case where Lowest L and Highest H values within the visible
region 
are automatically determined and contained within the outer lines.
*/
//==============HHV(H) and LLV(L) determination within visible
range=========================================
ShowLines=ParamToggle("ShowLines","No|Yes",1);
// _SECTION_BEGIN("HHVLLV");
fvb = Status("firstvisiblebar"); 
lvb = Status("lastvisiblebar"); 
HHVMax=0; LLVMin=10000;
for( i = fvb; i <= Lvb; i++ ) 
{ 
 HHVMax=Max(H[ i ],HHVMax); 
 LLVMin=Min(L[ i ],LLVMin);
}	
Plot(C, "Price", colorBlack, 64 ); 
Plot(HHVMax,"HHVMax",colorGreen,37);
Plot(LLVMin,"LLVMin",colorRed,37);
//_SECTION_END();
//================Drawing of
Lines=====================================================
iMax=Param("# of Divisions",12,1,100,1);
Mult= IIf(HHVMax>2,50,5000);
LowerLimit= floor(Mult*LLVMin)/Mult;//LowerLimit <= lowest visible value
UpperLimit= ceil(Mult*HHVMax)/Mult; //Upper Limit >= highest visible value

if (ShowLines)
{
for( i = 0; i <=imax; i++ )  
{
x=LowerLimit+(UpperLimit-LowerLimit)/imax *i;
Plot( x, "\nLine"+WriteVal(i,2.0), 1);
}
}
/*
// 1.  For lines that can be defined by an algebraic equation/functional
relationship.
ShowLines=ParamToggle("ShowLines","No|Yes",0);
imax=10;
LowerLimit= 83;
UpperLimit= 84;
if (ShowLines)
{
for( i = 1; i <imax; i++ )  
{
x=LowerLimit+(UpperLimit-LowerLimit)/(imax) *i;
Plot( x, "\nLine"+WriteVal(i,2.0), 1);
}
}
*/
//=======================================================
/*
// 2. For values that can not be described by an algebraic relationship.  
ShowLines=ParamToggle("ShowLines","No|Yes",0);
function Line( k )
{
  return VarGet( "Line"+ StrFormat("%01.0f", k ) );
}
Line1=83.0123;
Line2=83.1435;
Line3=83.27454;
Line4=83.312;
Line5=83.487;
Line6=83.5435;
Line7=83.632;
Line8=83.787;
Line9=83.890;
Line10=83.967;
Line11=84.043;

if (ShowLines)
{
for( i = 1; i <=11; i++ )  
{
Plot( Line( i ), "\nLine"+WriteVal(i,2.0), 1);
}
}
*/

From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf
Of Joris Schuller
Sent: Sunday, October 18, 2009 5:42 PM
To: amibroker@xxxxxxxxxxxxxxx
Subject: RE: [amibroker] Re: Replicating Studies; Simplified approach

  
No doubt "jooleanlogic" approach works. However, this approach has several
drawbacks: 1. Each time one has to copy and paste the data loading afl you
described below, which makes each afl longer and less overviewable and 2.
One now has a datafile inside the AMIBroker root directory (Although
presumably it could be redirected to a data directory; in both cases it
requires occasional data look up and review/edit).  An easier way, if one
wants to use this approach, is to place the dataload afl in the "include"
directory (Repl Study "jooleanlogic".afl) which therefore is now at least
universally accessible by each afl that requires it.  Then load this afl
after the Plot statement.  (Don't ask me why: One would think that it should
be before the Plot statement; possibly something to do with layers).
 
This will result in:
//Repl Study "jooleanlogic" Complete.afl
Title = EncodeColor(4)+ _DEFAULT_NAME()+";  "+EncodeColor(1) +
StrFormat("{{NAME}} - {{INTERVAL}}; {{DATE}}; O=%g, H=%g, L=%g, C=%g
(%.1f%%) 
{{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) );    
Plot(C, "Close",1,64); //has to be before Include statement
#include < Repl Study "jooleanlogic".afl>
//Plot(C, "Close",1,64);//Will not plot C if after include statement!!!!
====================================================
I normally use an even simpler approach. (Unless the data are already in a
file in a prescribed format and in addition there are many data points, and
one therefore is somewhat boxed in). I generate a simple data afl that
already includes Plot statements in the include directory ("Repl Study
Simplified.afl") and access this afl thru an include statement in the actual
Plot Afl ("Repl Study Simpl Complete.afl"). This way I only have to copy 1
Line (#include <Repl Study Simplified.afl>).
 
//Repl Study Simpl Complete.afl
Title = EncodeColor(4)+ _DEFAULT_NAME()+";  "+EncodeColor(1) +
StrFormat("{{NAME}} - {{INTERVAL}}; {{DATE}}; O=%g, H=%g, L=%g, C=%g
(%.1f%%) 
{{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) );    
Plot(C, "Close",1,64); //has to be before Include statement
#include <Repl Study Simplified.afl>
 
//Repl Study Simplified.AFL in Include Directory
Title = EncodeColor(4)+ _DEFAULT_NAME()+";  "+EncodeColor(1) +
StrFormat("{{NAME}} - {{INTERVAL}}; {{DATE}}; O=%g, H=%g, L=%g, C=%g
(%.1f%%) 
{{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) );    
 
// 1.  For lines that can be defined by an algebraic equation/functional
relationship.
ShowLines=ParamToggle("ShowLines","No|Yes",0);
imax=10;
LowerLimit= 83;
UpperLimit= 84;
if (ShowLines)
{
for( i = 1; i <imax; i++ )  
{
x=LowerLimit+(UpperLimit-LowerLimit)/(imax) *i;
Plot( x, "\nLine"+WriteVal(i,2.0), 1);
}
}
/*
// 2. For values that can not be described by an algebraic
relationship/functional relationship.  
ShowLines=ParamToggle("ShowLines","No|Yes",0);
function Line( k )
{
  return VarGet( "Line"+ StrFormat("%01.0f", k ) );
}
Line1=83.0123;
Line2=83.1435;
Line3=83.27454;
Line4=83.312;
Line5=83.487;
Line6=83.5435;
Line7=83.632;
Line8=83.787;
Line9=83.890;
Line10=83.967;
Line11=84.043;
 
if (ShowLines)
{
for( i = 1; i <=11; i++ )  
{
Plot( Line( i ), "\nLine"+WriteVal(i,2.0), 1);
}
}
 
 
 
From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf
Of jooleanlogic
Sent: Sunday, October 18, 2009 10:02 AM
To: amibroker@xxxxxxxxxxxxxxx
Subject: [amibroker] Re: Replicating Studies
 
  


The issue of copying actual studies has been covered a few times from memory
Sid but I don't know where it stands.
I created a script for it because I got so sick of not only copying study
lines but re-copying them whenever you change one.

The following is a simple display of what I was referring to in my last
post.
Add this to any existing script that has a price plot.
Create a text file called levels.txt with a different level value on each
line and put it in the root Amibroker folder.
This code just loads that data into static vars when you click the Load
button, then displays them.

I use a similar one and find it the fastest way to display horizontal levels
across multiple charts. It has the natural advantage that you only have to
change a value once in the text file to have it updated across all charts.

showLevels = ParamToggle("Show Levels", "No|Yes");
filename = ParamStr("Filename", "levels.txt");
LoadTrigger = ParamTrigger("Load Levels", "Load Levels");

VarPrefix = "levels";

procedure loadLevels (){
fh = fopen(filename, "r");
if(fh) {
StaticVarRemove(VarPrefix + "*");
LevelCount = 0;

while(!feof(fh)){
Line = fgets(fh);
LevelCount++;
LevelValue = StrToNum(Line);
StaticVarSet(VarPrefix + LevelCount, LevelValue);
}

StaticVarSet(VarPrefix + "levelcount", LevelCount); 
fclose(fh);
}
}

procedure displayLevels(){
LevelCount = StaticVarGet(VarPrefix + "levelcount");
if (!IsEmpty(LevelCount)){
for (i=1; i<=LevelCount; i++){
LevelValue = StaticVarGet(VarPrefix + i);
if (!IsEmpty(LevelValue)){
Plot(LevelValue, "", colorBlack, styleLine);
}
}
}
}

if(LoadTrigger){
LoadLevels();
}

if (showLevels){
displayLevels();
}

The levels.txt file would look something like this
4000
4005
4020
4035
etc

Regards,
Jules.

--- In amibroker@xxxxxxxxxxxxxxx <mailto:amibroker%40yahoogroups.com> ,
"Rob" <sidhartha70@xxx> wrote:
>
> Ummm... it's a tricky one. I'm not particularly keen to reinvent the wheel
and create my own study plotting interface...
> 
> Before I go down that road I just want to check I'm not missing a more
obvious way of replicating studies across charts of different symbols...
i.e. highly correlated symbols where the price action is similar enough that
they broadly have similar characteristics... for example, reaction highs and
lows in roughly the same places... etc
> 
> 
> --- In amibroker@xxxxxxxxxxxxxxx <mailto:amibroker%40yahoogroups.com> ,
"jooleanlogic" <jooleanl@> wrote:
> >
> > I just manually write levels in a text file Rob and then have a simple
script to load and plot them which you can add to any chart.
> > 
> > You can also prefix different types of levels. E.g.
> > vah,4000
> > poc,3990
> > val,3985
> > vah,3970
> > ...
> > and plot them in different colours or turn different types off/on.
> > 
> > Regards,
> > Jules.
> > 
> > --- In amibroker@xxxxxxxxxxxxxxx <mailto:amibroker%40yahoogroups.com> ,
"Rob" <sidhartha70@> wrote:
> > >
> > > Can anyone think of a good way of 'replicating' studies across charts
and symbols...
> > > 
> > > For example, thinking of something very simple... lets pretend I
wanted to draw a horizontal line across a reaction low in the ES contract...
would there be an easy way of replicating that study in the NQ contract
(i.e. across that same reaction low but in a different contract).
> > > 
> > > I need to do something similar across multiple contracts, multiple
times... so a way of automating the replication would be very useful.
> > > 
> > > Suggestions appreciated...
> > > 
> > > TIA
> > >
> >
>
No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.5.422 / Virus Database: 270.14.20/2444 - Release Date: 10/18/09
09:04:00

No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.5.422 / Virus Database: 270.14.20/2444 - Release Date: 10/18/09
09:04:00


<*>Attachment(s) from Joris Schuller:


<*> 1 of 1 File(s) http://groups.yahoo.com/group/amibroker/attachments/folder/744882295/item/list 
  <*> winmail.dat

------------------------------------

**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to 
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

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