Code:
[TypeConverterAttribute(typeof(ExpandableObjectConv erter))]
[Serializable()]
public class RangeCondition: ISerializable
{
private OF_OperatorType condoperator = OF_OperatorType.NoOperator; // enumerator defined above
private OF_ConditionType condtype = OF_ConditionType.OpositeSideDiagonally; // enumerator defined above
private double multiplier = 1;
private int increment = 0;
private int condvalue = 0;
public NinjaTrader.Indicator.Indicator Reference = null;
public RangeCondition() {
Operator = OF_OperatorType.NoOperator;
Type = OF_ConditionType.OpositeSideDiagonally;
Multiplier = 1;
Increment = 0;
Value = 0;
}
public override string ToString()
{
string rtn = "no condition";
if (condoperator!=OF_OperatorType.NoOperator) {
rtn = "Number ";
} else {
return rtn;
}
if (condoperator==OF_OperatorType.GreaterThan) rtn+= "> ";
if (condoperator==OF_OperatorType.GreaterThanOrEqualT o) rtn+= ">= ";
if (condoperator==OF_OperatorType.LessThan) rtn+= "< ";
if (condoperator==OF_OperatorType.LessThanOrEqualTo) rtn+= "<= ";
if (condtype==OF_ConditionType.OpositeSide) rtn+= "OS";
if (condtype==OF_ConditionType.AvgTradesPerPeriod) rtn+= "AvgTPP";
if (condtype==OF_ConditionType.Value) rtn+= condvalue+"";
if (Multiplier>1) rtn+= "*"+Multiplier;
if (Increment>0) rtn+= "+"+Increment;
return rtn;
}
public void GetObjectData(SerializationInfo serInfo, StreamingContext context)
{
serInfo.AddValue("Operator",Operator);
serInfo.AddValue("Type",Type);
serInfo.AddValue("Multiplier",Multiplier);
serInfo.AddValue("Increment",Increment);
serInfo.AddValue("Value",Value);
}
private RangeCondition(SerializationInfo serInfo,StreamingContext context)
{
this.Operator = (OF_OperatorType)Enum.Parse(typeof(OF_OperatorType ), serInfo.GetString("Operator"));
this.Type = (OF_ConditionType)Enum.Parse(typeof(OF_ConditionTy pe), serInfo.GetString("Type"));
this.Value = serInfo.GetInt32("Value");
this.Increment = serInfo.GetInt32("Increment");
this.Multiplier = serInfo.GetDouble("Multiplier");
}
.
.
.
and so on
}
Error text:
Failed to set property 'R1_Condition1' for indicator 'TestIndicator':
Object of type RangeCondition cannot be converted to type RangeCondition.
Is it a problem of serialization or WHAT ???
I would appreciate any help.
Thank you very much.
Alex
Comment