Login Page - Create Account

Support Board


Date/Time: Wed, 15 Jan 2025 15:26:40 +0000



Issue with sc.MaximumPositionAllowed

View Count: 1208

[2017-08-11 06:24:40]
onnb - Posts: 662
The short description of this is that MaximumPositionAllowed is not working as expected when placing market orders with OCO
Just tested this with 1598 but from what we see the same thing is happening in previous versions.

To reproduce:

I set the MaximumPositionAllowed to 2
I then submit market order, qty 2 with target/stop OCO.
I can do this multiple times so that my position size grows beyond 2.

If I do the same without the OCO, then after the first market order I get expected error when submitting more orders.

The script below demonstrates this. It places an order at the close of the bar. When I comment out the stop/target, the MaximumPositionAllowed works as expected.

SCSFExport scsf_maxpostest(SCStudyInterfaceRef sc)
{
  if (sc.SetDefaults)
  {
    sc.GraphName = "MaximumPositionAllowed Test";

    sc.GraphRegion = 0;
    sc.ValueFormat = VALUEFORMAT_INHERITED;
    sc.FreeDLL = 1;
    sc.AutoLoop = 1;

    return;
  }

  sc.MaximumPositionAllowed = 2;
  sc.AllowMultipleEntriesInSameDirection = 1;
  sc.AllowEntryWithWorkingOrders = 1;
  sc.AllowOnlyOneTradePerBar = 0;

  s_SCPositionData pd;
  sc.GetTradePosition(pd);

  if (sc.Index == sc.ArraySize - 2)
  {

    s_SCNewOrder order;
    order.OrderType = SCT_ORDERTYPE_MARKET;
    order.OrderQuantity = 2;
    order.Stop1Offset = 11;
    order.Target1Offset = 11;

    sc.AddMessageToLog(SCString().Format("sc.MaximumPositionAllowed = %i", sc.MaximumPositionAllowed), 1);

    int scerr = sc.BuyEntry(order);
    if (scerr > 0)
      sc.AddMessageToLog(SCString().Format(" the order has been placed", scerr), 1);
    else
      sc.AddMessageToLog(SCString().Format(" the order submission was ignored, SC error %i", scerr), 1);
    
  }
}


[2017-08-11 15:15:35]
Sierra Chart Engineering - Posts: 104368
What you see is consistent with the documentation:
Automated Trading Management: MaximumPositionAllowed

However, we should probably not be including in the calculation orders which will reduce the current Trade Position.

We need to think about this a little.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
[2017-08-11 15:15:36]
Sierra Chart Engineering - Posts: 104368
What you see is consistent with the documentation:
Automated Trading Management: MaximumPositionAllowed

However, we should probably not be including in the calculation, orders which will reduce the current Trade Position.

We need to think about this a little. We can certainly change this, but it could affect other automated trading systems. Should be all right if we document the change.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
Date Time Of Last Edit: 2017-08-11 15:16:28
[2017-08-11 15:44:09]
onnb - Posts: 662
Agree and understood.

For what its worth, we view the MaxPositionAllowed as a sort of safety net.
In that context it implies that you should never be allowed to submit orders that would increase the current position to a level that goes beyond this value.
[2017-08-15 05:28:50]
Sierra Chart Engineering - Posts: 104368
In the next release, when determining the quantity for maximum position allowed, exit orders are not considered when there is a long or short position.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account