I'm trying to use a public class to insert/cancel orders (without using ATM).
I created a public class in an indicator and use it to pass strings or entry prices to a strategy, generating orders.
I've no problem to insert orders but I cannot find a way to cancel them.
Here is my class:
public class Global {
public static string command1 = string.Empty;
public static double stopPriceLong1=0;
}
protected override void OnBarUpdate()
{
// insert Long Order
if (longOrder1 == null)
{
if (Global.command1.Contains("BuyStop"+ Convert.ToString (instrument)))
{
enterLong1 = Global.stopPriceLong1;
longOrder1 = EnterLongStop(1,enterLong1,"LONG "+Convert.ToString (instrument));
}
}
if (longOrder1.OrderState == OrderState.PendingSubmit)
{
if (Global.command1.Contains("Cancel"+ Convert.ToString (instrument)))
{
CancelOrder(longOrder1);
}
}
}
If I leave only the entry stop order code, it insert the order regularly, but I need to pass a value also to delete the order but the above code does not work when the delete code strings are included.
Does someone have any suggestion?
Thanks

Comment