Hello!!! I'm Cristina. I'm from Italy and I'm looking for help to realise a formula. First I'm sorry for my bad english and my bad practise in efs
I'm trying to build a cyclical indicator based on two centered moving averages = CMA and its speed
First I created a given CMA of the cycle under consideration. then I calculated the difference with the CMA of double length, like a Price oscillator of two CMA.This difference is my cycle indicator=C
Ex:cma(32)-cma(64)=C
This is C for a weekly cycle http://i55.tinypic.com/2z9gxew.jpg
Now I want to get the speed =V of indicator C making the difference between a given value and the previous one and so on: that is V=C(t)-C(t-1)
After obtaining V , I need to put the zero axis and a simple moving average of V
When V cuts down to the top the axis of zero or the SMA, the cycle in question is likely to have its maximum size and will be entered in its descending phase of closure. Similarly, when V will cut from the bottom its SMA or the axis of zero we have the start of the cycle.
Until now we have created the cyclical indicator C and I attach the script. We are not able to finish the part of the formula to calculate speed= V and the last following steps.
is there someone who would like to help us to finish our speed indicator please? Thank you very much
Have a nice weekend
Cristina
/************************************************** *******
Alexis C. Montenegro © July 2003
Use and/or modify this code freely. If you redistribute it
please include this and/or any other comment blocks and a
description of any changes you make.
************************************************** ********/
var vMA1 = null;
var vCntr = 0;
var vMA2=null;
function preMain() {
setPriceStudy(true);
setStudyTitle("CenteredMAtest");
setCursorLabelName("MA", 0);
setDefaultBarStyle(PS_SOLID, 0);
setDefaultBarFgColor(Color.magenta, 0);
setDefaultBarThickness(1, 0);
setPlotType(PLOTTYPE_LINE, 0);
var fp1 = new FunctionParameter("MA1Length", FunctionParameter.NUMBER);
fp1.setLowerLimit(1);
fp1.setDefault(32); //Edit this value to set a new default
var fp6 = new FunctionParameter("MA1Length1", FunctionParameter.NUMBER);
fp6.setLowerLimit(1);
fp6.setDefault(64); //Edit this value to set a new default
var fp2 = new FunctionParameter("MA1Offset", FunctionParameter.NUMBER);
fp2.setDefault(24); //Edit this value to set a new default
var fp3 = new FunctionParameter("MA1Source", FunctionParameter.STRING);
fp3.setName("MA1Source");
fp3.addOption("Close");
fp3.addOption("High");
fp3.addOption("Low");
fp3.addOption("Open");
fp3.addOption("HL/2");
fp3.addOption("HLC/3");
fp3.addOption("OHLC/4");
fp3.setDefault("Close"); //Edit this value to set a new default
var fp4 = new FunctionParameter("MA1Type", FunctionParameter.STRING);
fp4.setName("MA1Type");
fp4.addOption("MAStudy.SIMPLE");
fp4.addOption("MAStudy.EXPONENTIAL");
fp4.addOption("MAStudy.WEIGHTED");
fp4.addOption("MAStudy.VOLUMEWEIGHTED");
fp4.setDefault("MAStudy.SIMPLE"); //Edit this value to set a new default
var fp5 = new FunctionParameter("Centered", FunctionParameter.STRING);
fp5.addOption("Yes");
fp5.addOption("No");
fp5.setDefault("Yes");
}
function main(MA1Length,MA1Length1,MA1Offset,MA1Source,MA1T ype,Centered) {
if(getBarState()==BARSTATE_NEWBAR){
vCntr +=1;
}
if(vCntr<MA1Length*2)
return;
if(Centered=="Yes"){
MA1Offset = Math.ceil(MA1Length/2)*(-1);
}
if (vMA1 == null) vMA1 = new MAStudy(MA1Length, MA1Offset, MA1Source, eval(MA1Type));
if (vMA2 == null) vMA2 = new MAStudy(MA1Length1, MA1Offset, MA1Source, eval(MA1Type));
/******************************************
Insert your code following this text block
Use vMA1.getValue(MAStudy.MA) for your code
*******************************************/
if(getBarState() == BARSTATE_NEWBAR){
var nNum = 1;
}else{
var nNum = 0;
}
var vReturn = vMA1.getValue(MAStudy.MA,MA1Offset);
if (vReturn == null) return;
var vReturn1 = vMA2.getValue(MAStudy.MA,MA1Offset);
if (vReturn1 == null) return;
var vReturn2 = (vReturn-vReturn1);
if (vReturn2 == null) return;
if(MA1Offset<0){
if(getBuildNumber() > 636){
setBar(Bar.Value,MA1Offset,0,vReturn2);
drawLineRelative(MA1Offset,vReturn2,0,vReturn2,PS_ SOLID,1,Color.magenta,"line");
vReturn2=null;
}else{
setBar(Bar.Value,MA1Offset+nNum,vReturn2);
drawLineRelative(MA1Offset+nNum,vReturn2,0,vReturn 2,PS_SOLID,1,Color.magenta,"line");
vReturn2=null;
}
}
return vReturn2;
}
I'm trying to build a cyclical indicator based on two centered moving averages = CMA and its speed
First I created a given CMA of the cycle under consideration. then I calculated the difference with the CMA of double length, like a Price oscillator of two CMA.This difference is my cycle indicator=C
Ex:cma(32)-cma(64)=C
This is C for a weekly cycle http://i55.tinypic.com/2z9gxew.jpg
Now I want to get the speed =V of indicator C making the difference between a given value and the previous one and so on: that is V=C(t)-C(t-1)
After obtaining V , I need to put the zero axis and a simple moving average of V
When V cuts down to the top the axis of zero or the SMA, the cycle in question is likely to have its maximum size and will be entered in its descending phase of closure. Similarly, when V will cut from the bottom its SMA or the axis of zero we have the start of the cycle.
Until now we have created the cyclical indicator C and I attach the script. We are not able to finish the part of the formula to calculate speed= V and the last following steps.
is there someone who would like to help us to finish our speed indicator please? Thank you very much
Have a nice weekend
Cristina
/************************************************** *******
Alexis C. Montenegro © July 2003
Use and/or modify this code freely. If you redistribute it
please include this and/or any other comment blocks and a
description of any changes you make.
************************************************** ********/
var vMA1 = null;
var vCntr = 0;
var vMA2=null;
function preMain() {
setPriceStudy(true);
setStudyTitle("CenteredMAtest");
setCursorLabelName("MA", 0);
setDefaultBarStyle(PS_SOLID, 0);
setDefaultBarFgColor(Color.magenta, 0);
setDefaultBarThickness(1, 0);
setPlotType(PLOTTYPE_LINE, 0);
var fp1 = new FunctionParameter("MA1Length", FunctionParameter.NUMBER);
fp1.setLowerLimit(1);
fp1.setDefault(32); //Edit this value to set a new default
var fp6 = new FunctionParameter("MA1Length1", FunctionParameter.NUMBER);
fp6.setLowerLimit(1);
fp6.setDefault(64); //Edit this value to set a new default
var fp2 = new FunctionParameter("MA1Offset", FunctionParameter.NUMBER);
fp2.setDefault(24); //Edit this value to set a new default
var fp3 = new FunctionParameter("MA1Source", FunctionParameter.STRING);
fp3.setName("MA1Source");
fp3.addOption("Close");
fp3.addOption("High");
fp3.addOption("Low");
fp3.addOption("Open");
fp3.addOption("HL/2");
fp3.addOption("HLC/3");
fp3.addOption("OHLC/4");
fp3.setDefault("Close"); //Edit this value to set a new default
var fp4 = new FunctionParameter("MA1Type", FunctionParameter.STRING);
fp4.setName("MA1Type");
fp4.addOption("MAStudy.SIMPLE");
fp4.addOption("MAStudy.EXPONENTIAL");
fp4.addOption("MAStudy.WEIGHTED");
fp4.addOption("MAStudy.VOLUMEWEIGHTED");
fp4.setDefault("MAStudy.SIMPLE"); //Edit this value to set a new default
var fp5 = new FunctionParameter("Centered", FunctionParameter.STRING);
fp5.addOption("Yes");
fp5.addOption("No");
fp5.setDefault("Yes");
}
function main(MA1Length,MA1Length1,MA1Offset,MA1Source,MA1T ype,Centered) {
if(getBarState()==BARSTATE_NEWBAR){
vCntr +=1;
}
if(vCntr<MA1Length*2)
return;
if(Centered=="Yes"){
MA1Offset = Math.ceil(MA1Length/2)*(-1);
}
if (vMA1 == null) vMA1 = new MAStudy(MA1Length, MA1Offset, MA1Source, eval(MA1Type));
if (vMA2 == null) vMA2 = new MAStudy(MA1Length1, MA1Offset, MA1Source, eval(MA1Type));
/******************************************
Insert your code following this text block
Use vMA1.getValue(MAStudy.MA) for your code
*******************************************/
if(getBarState() == BARSTATE_NEWBAR){
var nNum = 1;
}else{
var nNum = 0;
}
var vReturn = vMA1.getValue(MAStudy.MA,MA1Offset);
if (vReturn == null) return;
var vReturn1 = vMA2.getValue(MAStudy.MA,MA1Offset);
if (vReturn1 == null) return;
var vReturn2 = (vReturn-vReturn1);
if (vReturn2 == null) return;
if(MA1Offset<0){
if(getBuildNumber() > 636){
setBar(Bar.Value,MA1Offset,0,vReturn2);
drawLineRelative(MA1Offset,vReturn2,0,vReturn2,PS_ SOLID,1,Color.magenta,"line");
vReturn2=null;
}else{
setBar(Bar.Value,MA1Offset+nNum,vReturn2);
drawLineRelative(MA1Offset+nNum,vReturn2,0,vReturn 2,PS_SOLID,1,Color.magenta,"line");
vReturn2=null;
}
}
return vReturn2;
}
Comment