Seek help coding an indicator
3 replies
Aj
2 years ago #276588
Hey guys, what’s up?
I’m having a real hard time to code and compile a simple thing. I did all tutorials and youtube videos regardless and still not getting to solve this:
Error “illegal start of expression” on this: ==> private double MVAS(ChartData data, int Period){…}
I’m trying to fix it and after several trials getting the same failed compile. Please if tehre someone to help me, I’d really appreciate! : )
Cheers,
AJ
Here is the full code:
package SQ.Blocks.Indicators.ValueOpen;
import com.strategyquant.lib.*;
import com.strategyquant.datalib.*;
import com.strategyquant.tradinglib.*;
import SQ.Internal.IndicatorBlock;
@BuildingBlock(name=”(VO) ValueOpen”, display=”ValueOpen(#Period#)[#Shift#]”, returnType = ReturnTypes.Number)
@Help(“ValueOpen Indicator”)
public class ValueOpen extends IndicatorBlock {
@Parameter
public ChartData Input;
@Parameter(defaultValue=”10″, isPeriod=true, minValue=2, maxValue=1000, step=1)
public int Period;
@Output
public DataSeries Value;
//__________________________________
//___________________________________
@Override
protected void OnBarUpdate() throws TradingException {
if (CurrentBar == 0 ) {
Value.set(0,0); } else {
Value.set(0, (Input.Open.get(0) – MVAS) / ( ATRI * 1/Period));
private double MVAS(ChartData data, int Period) {
double sum, relative;
for (int i = 0; i<Period; i++){
sum+= ((Input.High.get(i) + Input.Low.get(i))/2);
}
relative = (sum/Period);
return(relative);
}
private double ATRI(ChartData data, int Period) {
double range, VolatU;
for (int i = 0; i<Period; i++){
range+= (Input.High.get(i) – Input.Low.get(i));
}
VolatU = (0.2 * (range/Period));
if(VolatU==0 || VolatU==0.0)
{
VolatU=0.00000001;
}
return(VolatU);
}
}
Aj
2 years ago #276597
Hey Guys,
I’ve just did it….
I used average calculators and it is done
I will post on the full code on Roadmap.Strategyquant.com
Cheers,
AJ
tomas262
2 years ago #276599
Hello,
thanks for your feedback. You can also post here so others can learn from it too 🙂
Aj
2 years ago #276710
Hey Tomas!
I will attach the SQExtension to import the Indicator on SQX
The Pack contains the Calculation of Value Chart plus all Values (VO, VH, VL & VC) independent, so that makes it easier to work with AlgoWizard using a separated calculation. As I am pretty new on all of this, I wonder the calculations and the indicator are pretty Raw, so I’d suggest the Pros from the community take a look and make them better if needed.
And let others open to use and improve the indicator and share thru here.
PS. As I use Tradestation, I have set up the indicator code only for Easy Language Files.
Viewing 3 replies - 1 through 3 (of 3 total)