Login Page - Create Account

Support Board


Date/Time: Thu, 25 Apr 2024 00:22:47 +0000



[Programming Help] - ASCIL strategy trades will not reverse positions

View Count: 965

[2020-12-03 15:11:51]
User566913 - Posts: 39
I have my settings set just as Sierra support has written in their documentation:

If you want to enter Buy and Sell orders without any restriction and not use the automated trading management logic provided by Sierra Chart, then set the following variables as shown:

AllowMultipleEntriesInSameDirection to TRUE (Yes)
AllowOppositeEntryWithOpposingPositionOrOrders to TRUE (Yes)
CancelAllOrdersOnEntriesAndReversals to FALSE (No)
AllowEntryWithWorkingOrders to TRUE (Yes)
sc.AllowOnlyOneTradePerBar to FALSE (applies only to ACSIL trading systems)
MaximumPositionAllowed to the maximum Trade Position Quantity you want to allow for your automated trading system or set this to twice that Quantity to ensure MaximumPositionAllowed does not restrict order entry.
....
I have these settings just like this and my strategy will not reverse or exit it's position. What else should I do?
[2020-12-05 15:15:20]
bradh - Posts: 854
You will need this, as the default is false.

sc.SupportReversals = true;

[2020-12-19 15:24:21]
User566913 - Posts: 39
Thanks, I've tried that, still, doesnt work...
[2020-12-19 15:32:21]
bradh - Posts: 854
sc.CancelAllOrdersOnEntriesAndReversals = true;

[2020-12-19 17:15:18]
User566913 - Posts: 39
This is my current set up for trade parameters:
....
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*
/* Trade Parameters */
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  
    sc.AllowMultipleEntriesInSameDirection = false;
    sc.MaximumPositionAllowed = 25;
    sc.SupportReversals = true;

    // This is false by default. Orders will go to the simulation system always.
    sc.SendOrdersToTradeService = false;

    sc.AllowOppositeEntryWithOpposingPositionOrOrders = false;

    // This can be false in this function because we specify Attached Orders directly with the order which causes this to be considered true when submitting an order.
    //sc.SupportAttachedOrdersForTrading = false;

    sc.CancelAllOrdersOnEntriesAndReversals= true;
    sc.AllowEntryWithWorkingOrders = true;
    sc.CancelAllWorkingOrdersOnExit = true;

    // Only 1 trade for each Order Action type is allowed per bar.
    sc.AllowOnlyOneTradePerBar = false;

    //This needs to be set to true when a trading study uses trading functions.
    sc.MaintainTradeStatisticsAndTradesData = true;
....
I've been trying to solve this a long time. Thanks for your time and help...
[2020-12-19 19:14:28]
bradh - Posts: 854
sc.AllowOppositeEntryWithOpposingPositionOrOrders = true;

[2020-12-19 20:27:01]
User566913 - Posts: 39
Still nothing. Can it be the way I'm sending the orders:
.......
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* Buy Order Function */
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/

  if (RecentBidVolume > RecentAskVolume)
  {
    int Result = (int)sc.BuyEntry(NewOrder);
    if (Result > 0) //If there has been a successful order entry, then draw an arrow at the low of the bar.
    {
      Subgraph_BuyEntry[sc.Index] = sc.Low[sc.Index];

      // Remember the order IDs for subsequent modification and cancellation
      Target1OrderID = NewOrder.Target1InternalOrderID;
      Stop1OrderID = NewOrder.Stop1InternalOrderID;
    }
  }

/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  /* Sell Order Function */
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/

  else if (RecentAskVolume > RecentBidVolume)
  {
    int Result = (int)sc.SellEntry(NewOrder);
    if (Result > 0) //If there has been a successful order entry, then draw an arrow at the high of the bar.
    {
      Subgraph_SellEntry[sc.Index] = sc.High[sc.Index];

      // Remember the order IDs for subsequent modification and cancellation
      Target1OrderID = NewOrder.Target1InternalOrderID;
      Stop1OrderID = NewOrder.Stop1InternalOrderID;
    }
  }
[2020-12-19 20:43:10]
bradh - Posts: 854
Are you getting entries that are not reversals? Anything in the Message or Trade Service log?
[2020-12-19 21:15:24]
User566913 - Posts: 39
Trade Service Log:
Unable to Flatten or Reverse because no Position exists
[2020-12-20 01:06:01]
User99735 - Posts: 234
Hi,
Think you need to add additional check that a position exists before doing a sc.SellEntry(NewOrder);
Regards

Vivek
[2020-12-29 17:38:19]
User566913 - Posts: 39
Can someone help fix my code to work properly? Thanks
[2020-12-29 17:56:08]
bradh - Posts: 854
Think you need to add additional check that a position exists before doing a sc.SellEntry(NewOrder);



// Check if there is an actual position, if not return
s_SCPositionData PositionData;
sc.GetTradePosition(PositionData);
if (PositionData.PositionQuantity == 0)
return;

Date Time Of Last Edit: 2021-01-02 15:25:40
[2021-01-22 20:24:07]
User566913 - Posts: 39
Where would I put this code?
....
....
// Check if there is an actual position, if not return

s_SCPositionData PositionData;

sc.GetTradePosition(PositionData);

if (PositionData.PositionQuantity == 0)

return;
.....
.....
.....
.....
.....
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  /* Buy Order Function */
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/

  if (RecentBidVolume > RecentAskVolume)
  {
    int Result = (int)sc.BuyOrder(NewOrder);
    if (Result > 0) //If there has been a successful order entry, then draw an arrow at the low of the bar.
    {
      Subgraph_BuyEntry[sc.Index] = sc.Low[sc.Index];

      // Remember the order IDs for subsequent modification and cancellation
      Target1OrderID = NewOrder.Target1InternalOrderID;
      Stop1OrderID = NewOrder.Stop1InternalOrderID;
    }
  }

/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  /* Sell Order Function */
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/

if (RecentAskVolume > RecentBidVolume)
  {
    int Result = (int)sc.SellOrder(NewOrder);
    if (Result > 0) //If there has been a successful order entry, then draw an arrow at the high of the bar.
    {
      Subgraph_SellOrder[sc.Index] = sc.High[sc.Index];

      // Remember the order IDs for subsequent modification and cancellation
      Target1OrderID = NewOrder.Target1InternalOrderID;
      Stop1OrderID = NewOrder.Stop1InternalOrderID;
    }
  }
[2021-01-22 20:30:11]
User566913 - Posts: 39
I actually already had that code in there....Still nothing. Does it have to go somewhere specific?

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

Login

Login Page - Create Account