Profile Picture

efficiency when chaining indicators

Posted By mark0419 9 Years Ago
Message
QuestionMark Posted Wednesday March 26 2008
I'm looking at how to implement my indicators and I have a question about efficiency in systems with chained custom indicators.

Given the examples below, does RE attempt to do any optimization on the loading/storage of the chained indicators (ie, how many instances of Indicator_A are really created)? If there's no sharing going on, I would expect model_A to be the more efficient design approach. However, model_B would certainly simplify coding systems based on any derivative indicators.



namespace Model_A{
public class Indicator_A : IndicatorBase {
}


[SeriesInputAttribute("Input Series", 1, Value = "Indicator_A")]
public class Indicator_B : SeriesCalculatorBaseWithValues{
}

[SeriesInputAttribute("Input Series", 1, Value = "Indicator_A")]
public class Indicator_C : SeriesCalculatorBaseWithValues{
}


//////////////////////////////////////////
class MySymbolScript : MySymbolScriptBase{

private Indicator_B _iA;
private Indicator_B _iB;
private Indicator_C _iC;

public override void Startup(){
_iA=new Indicator_A();

_iB=new Indicator_B();
_iB.SetInputs(iA);

_iC=new Indicator_C();
_iC.SetInputs(iA);
}
}


}//end of namespace_A




namespace Model_B{

public class Indicator_A : IndicatorBase {
}



public class Indicator_B : SeriesCalculatorBaseWithValues{

private Indicator_A _iA;

public Indicator_B(){
_iA=new Indicator_A();
}
}


public class Indicator_C : SeriesCalculatorBaseWithValues{

private Indicator_A _iA;

public Indicator_C(){
_iA=new Indicator_A();
}
}

//////////////////////////////////////////
class MySymbolScript : MySymbolScriptBase{

private Indicator_B _iB;
private Indicator_C _iC;

public override void Startup(){
_iB=new Indicator_B();
_iC=new Indicator_C();
}
}

}//end of namespace_B
Posted Wednesday March 26 2008
Model A is more efficient, as only one copy of indicator A will be created.  Each time you call "new IndicatorA()", a new copy will be created and there isn't really any magic we can do to prevent this.

Thanks,
Daniel

Posted Thursday March 27 2008
Thanks Daniel. I expected as much, but I thought perhaps there might be something tricky with static constructors going on in the RE base classes. I'll go ahead and work with first model.


Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems