Topics

Forum Topics not found

Replies

kartheek99923
14 Jun 2024, 04:28 ( Updated at: 14 Jun 2024, 05:11 )

RE: Cancel Pending Orders by pip distance from current price?

theonlinemick said: 

Great, thank you, works perfectly.

added the parameter and label for anyone who wants to save time.

[Parameter("Cancel Pending Orders", DefaultValue = 30, MinValue = 0)]
        public int MaxPipDistance { get; set; }

 

protected override void OnTick()
        {
            foreach (var order in PendingOrders)
            {
                var pipDistance = Math.Abs((order.TargetPrice - Symbol.Ask) / Symbol.PipValue);
                if (pipDistance > MaxPipDistance)
                {
                    CancelPendingOrder(order);
                    Print("Order Has Reached Max Distance, Order Cancelled");
                }
            }
        }

This code is showing errors while building. Can you help me with the code?


@kartheek99923