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

RE: [amibroker] Re: Replicating Studies; Simplified approach



PureBytes Links

Trading Reference Links



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, "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, "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, "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



__._,_.___


**** 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/





Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___