Below is an EFS study which calculates a MA of CCI. On an advanced chart regMACCI is returned by the EFS and displayed as a line chart.
I use regMACCI in different time frames 60, 30 & 5 and would like to pass these individual values to excel; As an example assume the following are column headings in excel....
GBP A0-FX | Bid | Ask | regMACCI 60 Min | regMACCI 30 | regMACCI 5 min
and i have 3 advanced charts of USD/GBP in esignal dipicting 60, 30 & 5 minute time frames running the same EFS study.
Basically how do i pass the 3 different time frame EFS values for 1 instrument into excel?
I've looked through previous posts and tried unsuccessfully to code this myself
==========
arCCI = new Array(3); // Array to hold CCI history to calculate MACCI
arMaCCI = new Array(2); // Array to hold MACCI history to calculate Regression
function preMain() {
addBand(100, PS_SOLID, 1, Color.black);
addBand(-100, PS_SOLID, 1, Color.black);
}
function main(nPeriod, maPeriod) {
if(nPeriod == null) var nPeriod = 6;
if(maPeriod == null) var maPeriod = 3; // Period of MACCI average
var i;
var vHigh = getValue("High", 0, -nPeriod);
var vLow = getValue("Low", 0, -nPeriod);
var vClose = getValue("Close", 0, -nPeriod);
var maTP = 0; // Moving average of Typical Price;
var vTP = 0; // Typical Price
var vMDTP = 0; // Meav Deviation of Typical Price
var vCCI = 0; // Commodity Channel Index value
var vMACCI = 0; // Moving Average of CCI
if(vHigh == null)
return;
// Calulate Moving Average of Typical Price = maTP
for(i = 0; i < nPeriod; i++) {
maTP += (vHigh[i] + vLow[i] + vClose[i]) / 3;
}
maTP = maTP/nPeriod;
// Calculate Mean Deviation of Typical Price
vTP = 0;
for(i=0; i < nPeriod; i++) {
vTP = (vHigh[i] + vLow[i] + vClose[i]) / 3;
vMDTP += Math.abs( vTP - maTP);
}
vMDTP = vMDTP/nPeriod;
vTP = (vHigh[0] + vLow[0] + vClose[0]) / 3;
vCCI = ( vTP - maTP) / (vMDTP * 0.015);
var vTemp;
vTemp = arCCI.unshift(vCCI);
vMACCI = 0.0;
for(i = 0; i < maPeriod; i++){
if( arCCI[i] == null) return;
vMACCI += arCCI[i];
}
vTemp = arCCI.pop();
vMACCI /= maPeriod;
// Calulate Regression of MACCI
vTemp = arMaCCI.unshift(vMACCI);
if( arMaCCI[0] == null || arMaCCI[1] == null) return;
var regMACCI = 0.0;
regMACCI = 0.6 * arMaCCI[0] + 0.4 * arMaCCI[1];
vTemp = arMaCCI.pop();
return regMACCI;
}
I use regMACCI in different time frames 60, 30 & 5 and would like to pass these individual values to excel; As an example assume the following are column headings in excel....
GBP A0-FX | Bid | Ask | regMACCI 60 Min | regMACCI 30 | regMACCI 5 min
and i have 3 advanced charts of USD/GBP in esignal dipicting 60, 30 & 5 minute time frames running the same EFS study.
Basically how do i pass the 3 different time frame EFS values for 1 instrument into excel?
I've looked through previous posts and tried unsuccessfully to code this myself
==========
arCCI = new Array(3); // Array to hold CCI history to calculate MACCI
arMaCCI = new Array(2); // Array to hold MACCI history to calculate Regression
function preMain() {
addBand(100, PS_SOLID, 1, Color.black);
addBand(-100, PS_SOLID, 1, Color.black);
}
function main(nPeriod, maPeriod) {
if(nPeriod == null) var nPeriod = 6;
if(maPeriod == null) var maPeriod = 3; // Period of MACCI average
var i;
var vHigh = getValue("High", 0, -nPeriod);
var vLow = getValue("Low", 0, -nPeriod);
var vClose = getValue("Close", 0, -nPeriod);
var maTP = 0; // Moving average of Typical Price;
var vTP = 0; // Typical Price
var vMDTP = 0; // Meav Deviation of Typical Price
var vCCI = 0; // Commodity Channel Index value
var vMACCI = 0; // Moving Average of CCI
if(vHigh == null)
return;
// Calulate Moving Average of Typical Price = maTP
for(i = 0; i < nPeriod; i++) {
maTP += (vHigh[i] + vLow[i] + vClose[i]) / 3;
}
maTP = maTP/nPeriod;
// Calculate Mean Deviation of Typical Price
vTP = 0;
for(i=0; i < nPeriod; i++) {
vTP = (vHigh[i] + vLow[i] + vClose[i]) / 3;
vMDTP += Math.abs( vTP - maTP);
}
vMDTP = vMDTP/nPeriod;
vTP = (vHigh[0] + vLow[0] + vClose[0]) / 3;
vCCI = ( vTP - maTP) / (vMDTP * 0.015);
var vTemp;
vTemp = arCCI.unshift(vCCI);
vMACCI = 0.0;
for(i = 0; i < maPeriod; i++){
if( arCCI[i] == null) return;
vMACCI += arCCI[i];
}
vTemp = arCCI.pop();
vMACCI /= maPeriod;
// Calulate Regression of MACCI
vTemp = arMaCCI.unshift(vMACCI);
if( arMaCCI[0] == null || arMaCCI[1] == null) return;
var regMACCI = 0.0;
regMACCI = 0.6 * arMaCCI[0] + 0.4 * arMaCCI[1];
vTemp = arMaCCI.pop();
return regMACCI;
}
Comment