Because I don’t know whether it will be Indicator1’s order that executes, or Indicator2’s. I suppose I can have them both do a check against existing orders for an OCO, and then have them extract what that is from the most recent Working order, but in my code that would create a huge plate of spaghetti.
Suppose I just want this passing a variable from one Indicator to another to actually work. I know that it does, because both of these Indicators are using a variable passed from a third Indicator, and it works just fine.
Having realized what I stated in the first sentence of this post, and in light of what I stated in the second paragraph of this post, I have inserted the code to generate the random OCO ID into the third Indicator which is already successfully passing a variable to these two indicators.
The third Indicator uses OnPositionUpdate to generate a new OCO ID whenever a position is closed. That works perfectly. And, even though the other variable that it is passing to the other Indicators continues to be read properly, the OCO ID string doesn’t.
Same Indicator passing two variables, same two Indicators receiving them, one gets through, the other doesn’t. Regardless what other methodology may exist to achieve my ends, I want to solve this problem.
Now, let’s take a look…
Variable originating Indicator:
public class PassingIndicator : Indicator
{
private bool var1;
private string var2;
.........................
private void OnPositionUpdate(object sender, PositionEventArgs e)
{
if (e.MarketPosition == MarketPosition.Flat)
{
var2 = myrandomString + CurrentBar.ToString();
Print("Generating new OCO ID: " + var2);
}
}
.........................
#region Properties
[Browsable(false)]
[XmlIgnore]
public bool vaR1
{
get { Update(); return var1; }
}
[Browsable(false)]
[XmlIgnore]
public string vaR2
{
get { Update(); return var2; }
}
Receiving Indicator:
public class ReceivingIndicator1 : Indicator
{
private PassingIndicator PassingIndicator1;
.........................
protected override void OnStateChange()
{
else if (State == State.DataLoaded)
{
PassingIndicator1 = PassingIndicator(Close);
}
.........................
protected override void OnBarUpdate()
{
variable1 = PassingIndicator1.vaR1;
variable2 = PassingIndicator1.vaR2;
Now, why does var1 get sent through and read properly by the receiving Indicators, while var2 does not?
This is the problem I must solve.
Thanks again!