Wich parameters of the getvalue method do i have to change to specify an interval other than the chart default.
Announcement
Collapse
No announcement yet.
getvalue on different intervals
Collapse
This topic is closed.
X
X
-
I'm looking for the getvalue format. I'm aware that the symbol format is ie. IBM, 5 for a 5-min interval. However, how would I have the getvalue call a 5-min interval for any symbol on a 1-min chart.
I've tried: var vCCI30 = new CCIStudy("30, 5","Close") to replace var vCCI30 = new CCIStudy(30, "Close")
& then
vCCI30.getValue(CCIStudy.CCI, -1) for instance. & a few variations also, but nothing has worked.
Comment
-
nife01, you can only do the getValue() for other symbols/intervals for the OHLC data, not for studies built on that data.
We are planning major additions to EFS for v8.0 in which you will be able to do syntax similar to:
sma(10, sym("MSFT,5")) or sma(10, int(5)) to grab the 10 period SMA of another symbol and/or interval.
The date for the delivery of v8.0 has not yet been determined.
Comment
-
I posed this question on a recent eSignal Chat conducted by JasonK. He seemed to feel that it could be done. I followed his instructions, but was unable to make it work. Here are the details of our chat:
<nife01> Is there any way to have the arguments in 1 study use more than 1 interval? Ie. You are plotting your output on a 5-min chart, however some of your arguments are based on 5-min price intervals while others are on 1 or 10 min price intervals.
"
<eSignal_JasonK> nife01, you can pass the symbol as one of the paramters to getValue(), where the symbol "IBM,5" would be a 5 min interval.
<nife01> JasonK, are you saying that I would have to put the symbol in the code?
<eSignal_JasonK> ya ... getValue("Close", ... "Symbol,5");
<nife01> JasonK, I suppose there is no way to have a this work for every new symbol typed?
<eSignal_JasonK> you can use: var vSym = getSymbol(); ... and use vSym to build the symbol string: vSym + ",5" ...getValue("Close", ... , vSym + ",5"); that way, when you change your chart symbol, vSym will also change to your chart symbol.
"
Perhaps I require more than what is in his instructions, but he seems to be saying that a study can be used in multiple intervals for one chart. Is this wrong?
Comment
-
Hi,
Yes it is possible. I'm pretty sure I mentioned at that same chat that the hard part is synching the times.
What you can't do (currently) is use the builtins for different intervals. You can only use the getValue() for open, close, high, low and volume.
GarthGarth
Comment
-
gspiker,
In formulas where I use MACD, for instance, I would use vMACD12_26.getValue(MACDStudy.SIGNAL)
I dont actually know the difference between the "builtin" function and the "basic" version.
But if you say that it can be done with the getValue(MACDStudy), how would I do it? I've tried a few different variations that have not worked?
thanks,
Ian
Comment
-
Hi,
I think we are having a terminology problem. When I say getValue, I mean the getValue command as in:
getValue(Open) or getValue(Close).
When I say builtins, I'm talking about the exposed interface to the built in EFS indicators such as MACD, MA's, RSI, etc..
so doing multiple interval with getValue would look something like:
getValue("Close", 0, 10,"IBM,30");
Which would get the last 10 closes from the 30 minute IBM chart.
Doing a MACD.getValue on a differnt timeframe from the base chart is NOT possible at this time. As Dion mentioned earlier eSignal is working on a way to allow this, but it is not available yet. They are also working on nice features to allowing multiple intervals with getValue() to work much easier that it currently does. Currently Multiple intervals is one of the hardest things to do in EFS.
GarthGarth
Comment
-
gspiker,
Thank you for the clarification and for your help.
Since I cannot use studies of varying intervals on a base chart, I am forced to look at other alternatives.
The one that I am working on involves using up to 3 charts of varying intervals for one symbol. For instance, I may get a buy-entry on a 1-minute chart and then a sell-exit on a 3-minute chart. The problem is that I use variables to indicate whether I am long (for instance) or not, thus preventing repeated buy signals and unneccessary sell signals. I realized that if this is going to work, I need to link the 2 formulas so that they may share the variable. In looking through the bulletin, I saw a suggestion you provided back in Feb. of this year to use SetGlobalValue() and GetGlobalValue().
I should mention that everything that I know about EFS & JavaScript I have essentially only learned in the last 3 weeks through these bulletins & mixing & matching. I have no programming background & have impressed the hell out of myself, but am still a rank novice.
Anyhow, I tried using the "universal" global variables as you coined them, but am obviously not using them properly. I have included the code of 2 efs's that would need to work with one another as an example (which include my last attempt to use Get/SetGlobalValue().) If you dont mind, could you tell me how they would use the GetGlobalValue() & SetGlobalValue():
//{{Buy Side
var vADXDM = new ADXDMStudy(10);
var lastHighADX=0;
var signal=0;
var vLastAlert = -1;
var LongOndmi=0;
function preMain() {
setPriceStudy(true);
setStudyTitle("Test SetGlobalValue()entry");
}
function main() {
GetGlobalvalue(LongOndmi)
//{{establishes PDI highs
if (
vADXDM.getValue(ADXDMStudy.PDI, -2)+.75 < vADXDM.getValue(ADXDMStudy.PDI, -1) &&
vADXDM.getValue(ADXDMStudy.PDI, -1) > vADXDM.getValue(ADXDMStudy.PDI)+.75 &&
vADXDM.getValue(ADXDMStudy.PDI, -1) > vADXDM.getValue(ADXDMStudy.NDI, -1)
) onAction1();
//{{establishes PDI higher high 1 lot buy entry
else if (
vADXDM.getValue(ADXDMStudy.PDI) > lastHighADX &&
vADXDM.getValue(ADXDMStudy.PDI) > vADXDM.getValue(ADXDMStudy.NDI) &&
signal==0 &&
LongOndmi==0
) onAction2();
return null;
}
function postMain() {
}
function onAction1() {
lastHighADX=vADXDM.getValue(ADXDMStudy.PDI, -1);
signal = 0;
vLastAlert = 1;
}
function onAction2() {
drawTextRelative(0, high(), "DMI HH ShortCover Buy1lot", Color.lime, Color.black, Text.left, "Arial", 6);
lastHighADX=vADXDM.getValue(ADXDMStudy.PDI, -1);
signal=1;
SetGlobalValue(LongOndmi,1);
vLastAlert = 2;
}
-----------------------------------------
//{{ Sell Side
var vADXDM = new ADXDMStudy(10);
var lastHighADX=0;
var signal=0;
var vLastAlert = -1;
var LongOndmi=0;
function preMain() {
setPriceStudy(true);
setStudyTitle("Test SetGlobalValue()exit");
//}}setComputeOnClose();
}
function main() {
GetGlobalValue(LongOndmi)
//{{establishes DMI cross & long stop
if (
vADXDM.getValue(ADXDMStudy.PDI, -1) >= vADXDM.getValue(ADXDMStudy.NDI, -1) &&
vADXDM.getValue(ADXDMStudy.PDI) < vADXDM.getValue(ADXDMStudy.NDI) &&
LongOndmi==1
) onAction1()
}
function postMain() {
}
function onAction1() {
drawTextRelative(0, high(), "DMI Long Stop!", Color.red, Color.black, Text.left, "Arial", 6)
SetGlobalValue(LongOndmi,0);
vLastAlert = 1;
}
Comment
-
Hi,
Looks like you are catching on quickly. That's great!
Without having looked over your code in detail and focusing only on the Universal Globals...
You want to use them as follows:
var localvar = getGlobalValue("NameofMyGlobal");
and
setGlobalValue("NameofMyGlobal", value);
Note the way caps are used in the getGlobal and setGlobal commands themselves. Also note that the global name is a string supplied to eSignal to keep track of you variable.
In order to use a stored variable, you need to set a local (or local global) to its value.
So...
PHP Code:main(){
var nMyGlobal;
var nTest = 0;
nMyGlobal = getGlobalValue("GnMyGlobal");
if (nTest > 0 && nMyGlobal == 0)
setGlobalValue("GnMyGlobal", 1);
Note that again, the really hard part here will be synching the timeframes if you want to backtest/line up historical data. It should work fairly well in realtime without syching, but your historical data for your indicator will be messed up if not synched.
GarthGarth
Comment
-
Garth,
Once again, thank you.
When working after hours and everything is in 1 EFS, its easy to test the conditions. The data will plot historically. Since there are 2 EFS the data does not plot, even in replay. ...or perhaps I still am not using the GlobalValues properly. I have no errors, but the data will not plot.
There are no other errors in the formula and I know it works fine without the GlobalValues. I tried several ways, starting with the way you suggested.
There is still so much I dont know and, ya I guess I'm dense. ..but would you mind taking another gander at the way I've used the get/setGlobalValues().
Buy Side
//{{EFSWizard_Declarations
var vADXDM = new ADXDMStudy(10);
var lastHighADX=0;
var signal=0;
var vLastAlert = -1;
function preMain() {
/**
* This function is called only once, before any of the bars are loaded.
* Place any study or EFS configuration commands here.
*/
setPriceStudy(true);
setStudyTitle("Test SetGlobalValue()entry");
//}}setComputeOnClose();
}
function main() {
/**
* The main() function is called once per bar on all previous bars, once per
* each incoming completed bar, and if you don't have 'setComputeOnClose(true)'
* in your preMain(), it is also called on every tick.
*/
var Long;
Long = getGlobalValue("LongOndmi");
//{{establishes PDI highs
if (
vADXDM.getValue(ADXDMStudy.PDI, -2)+.75 < vADXDM.getValue(ADXDMStudy.PDI, -1) &&
vADXDM.getValue(ADXDMStudy.PDI, -1) > vADXDM.getValue(ADXDMStudy.PDI)+.75 &&
vADXDM.getValue(ADXDMStudy.PDI, -1) > vADXDM.getValue(ADXDMStudy.NDI, -1)
) onAction1();
//{{resets PDI high everytime PDI cross below NDI
if (
vADXDM.getValue(ADXDMStudy.PDI) < vADXDM.getValue(ADXDMStudy.NDI)
) onAction101();
//{{establishes PDI higher high 1 lot buy entry
else if (
vADXDM.getValue(ADXDMStudy.PDI) > lastHighADX &&
vADXDM.getValue(ADXDMStudy.PDI) > vADXDM.getValue(ADXDMStudy.NDI) &&
signal==0 &&
Long==0
) onAction2();
setGlobalValue("LongOndmi", 1);
return null;
}
function postMain() {
/**
* The postMain() function is called only once, when the EFS is no longer used for
* the current symbol (ie, symbol change, chart closing, or application shutdown).
*/
}
function onAction1() {
//{{drawShapeRelative(-1, high(), Shape.CIRCLE, "", Color.red, Shape.LEFT);
lastHighADX=vADXDM.getValue(ADXDMStudy.PDI, -1);
signal = 0;
vLastAlert = 1;
}
function onAction101() {
signal = 1;
vLastAlert = 101;
}
function onAction2() {
if (vLastAlert != 2) Alert.addToList(getSymbol(), "DMI HH If Cover Short, BUY 1 LOT", Color.lime, Color.lime);
if (vLastAlert != 2) Alert.playSound("doorbell.wav");
drawTextRelative(0, high(), "DMI HH ShortCover Buy1lot", Color.lime, Color.black, Text.left, "Arial", 6);
drawShapeRelative(0, low(), Shape.UPARROW, "", Color.lime, Shape.LEFT);
lastHighADX=vADXDM.getValue(ADXDMStudy.PDI, -1);
signal=1;
vLastAlert = 2;
}
------------------------------------------------------
sell side
//{{EFSWizard_Declarations
var vADXDM = new ADXDMStudy(10);
var lastHighADX=0;
var signaldmi=0;
var vLastAlert = -1;
function preMain() {
/**
* This function is called only once, before any of the bars are loaded.
* Place any study or EFS configuration commands here.
*/
setPriceStudy(true);
setStudyTitle("Test SetGlobalValue()exit");
//}}setComputeOnClose();
}
function main() {
/**
* The main() function is called once per bar on all previous bars, once per
* each incoming completed bar, and if you don't have 'setComputeOnClose(true)'
* in your preMain(), it is also called on every tick.
*/
var Long;
Long = getGlobalValue("LongOndmi");
//{{establishes DMI cross & long stop
if (
vADXDM.getValue(ADXDMStudy.PDI, -1) >= vADXDM.getValue(ADXDMStudy.NDI, -1) &&
vADXDM.getValue(ADXDMStudy.PDI) < vADXDM.getValue(ADXDMStudy.NDI) &&
//{{signaldmi==0
Long==1
) onAction3();
setGlobalValue("LongOndmi", 0);
}
function postMain() {
/**
* The postMain() function is called only once, when the EFS is no longer used for
* the current symbol (ie, symbol change, chart closing, or application shutdown).
*/
}
function onAction3() {
if (vLastAlert != 3) Alert.playSound("Interrupted.wav");
if (vLastAlert != 3) Alert.addToList(getSymbol(), "DMI LONG STOP!!", Color.red, Color.red);
drawTextRelative(0, high(), "DMI Long Stop!", Color.red, Color.black, Text.left, "Arial", 6)
drawShapeRelative(0, high(), Shape.DOWNARROW, "", Color.red, Shape.LEFT);
//{{signaldmi=1;
vLastAlert = 3;
}
Comment
-
Garth,
I've been working too long on this. I just read at the bottom of your 2nd to last post that it is difficult to historically sync up the data. I guess I'll try tomorrow during hours. ..I think I need sleep, this stuff is tiring.
thnx,
Ian
Comment
-
Ian,
What you are trying to do is really not easy in EFS right now. I would suggest the following...wait for Alex to post the most recent version of the twotimer formula he and I created (he is cleaning it up right now). This is a slightly different and easier (IMHO) of dealing with multiple intervals. Use twotimer as your base and add code in the section indicated by the formula. I think it will be much easier in the long run for you.
GGarth
Comment
Comment