Login Page - Create Account

Support Board


Date/Time: Sat, 04 May 2024 12:26:35 +0000



ASCIL trading examples that come with SC

View Count: 1715

[2015-05-16 02:34:54]
User120827 - Posts: 77
hi

SC has many great ASCIL code examples like the trading example for crossovers.

I was hoping to find a similar sample for something other than a crossover. Perhaps a " greater than " sample.

In order to add a filter like " if 20 SMA > 50 SMA "

Are there other sources for ASCIL sample codes for SC ?

shane
Date Time Of Last Edit: 2015-05-16 02:35:33
[2015-05-16 08:39:45]
Sierra Chart Engineering - Posts: 104368
Tell us what specific ACSIL trading example you are looking at. Tell us the function name and then we will modify it to do what you are asking for.
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
[2015-05-16 20:42:52]
User120827 - Posts: 77
hi

This was the example crossover code that is with many other codes under tradingsystems file in the ACS soure folder.

SCSFExport scsf_SC_TradingCrossOverExample(SCStudyGraphRef sc)



SCSFExport scsf_SC_TradingCrossOverExample(SCStudyGraphRef sc)
{

  SCInputRef Line1Ref = sc.Input[0];
  SCInputRef Line2Ref = sc.Input[1];

  SCSubgraphRef BuyEntry = sc.Subgraph[0];
  SCSubgraphRef SellEntry = sc.Subgraph[1];

  if (sc.SetDefaults)
  {

    // Set the configuration and defaults

    sc.GraphName = "Trading CrossOver Example";

    sc.StudyDescription = "An example of a trading system that enters a new position or \
               reverses an existing one on the crossover of two study Subgraphs. \
               When line1 crosses line2 from below, the system will look to be long. \
               When line1 crosses line2 from above, the system will look to be short.";

    sc.AutoLoop = 1; // true
    sc.GraphRegion = 0;
    sc.FreeDLL = 0;
    sc.CalculationPrecedence = LOW_PREC_LEVEL;

    Line1Ref.Name = "Line1";
    Line1Ref.SetStudySubgraphValues(1, 0);

    Line2Ref.Name = "Line2";
    Line2Ref.SetStudySubgraphValues(1, 0);

    BuyEntry.Name = "Buy";
    BuyEntry.DrawStyle = DRAWSTYLE_POINTHIGH;
    BuyEntry.LineWidth = 3;

    SellEntry.Name = "Sell";
    SellEntry.DrawStyle = DRAWSTYLE_POINTLOW;
    SellEntry.LineWidth = 3;

    sc.AllowMultipleEntriesInSameDirection = false;
    sc.MaximumPositionAllowed = 5;
    sc.SupportReversals = true;

    // This is false by default. Orders will not go to the external connected trading service.
    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 = false;
    sc.CancelAllWorkingOrdersOnExit = true;

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

    //This needs to be set to true when a trading study uses trading functions.
    sc.MaintainTradeStatisticsAndTradesData = true;


    return;
  }

  // only process at the close of the bar; if it has not closed don't do anything
  if (sc.GetBarHasClosedStatus() == BHCS_BAR_HAS_NOT_CLOSED)
  {
    return;
  }


  // using the line1Ref and line2Ref input variables, retrieve the subgraph arrays into line1, line2 arrays respectively
  SCFloatArray line1;
  sc.GetStudyArrayUsingID(Line1Ref.GetStudyID(), Line1Ref.GetSubgraphIndex(), line1);

  SCFloatArray line2;
  sc.GetStudyArrayUsingID(Line2Ref.GetStudyID(), Line2Ref.GetSubgraphIndex(), line2);

  // code below is where we check for crossovers and take action accordingly

  if (sc.CrossOver(line1, line2) == CROSS_FROM_BOTTOM)
  {

    // mark the crossover on the chart
    BuyEntry[sc.Index] = 1;

    // Create a market order and enter long.
    s_SCNewOrder order;
    order.OrderQuantity = 1;
    order.OrderType = SCT_ORDERTYPE_MARKET;

    sc.BuyEntry(order);
  }

  if (sc.CrossOver(line1, line2) == CROSS_FROM_TOP)
  {


    // mark the crossover on the chart
    SellEntry[sc.Index] = 1;

    // create a market order and enter short
    s_SCNewOrder order;
    order.OrderQuantity = 1;
    order.OrderType = SCT_ORDERTYPE_MARKET;

    sc.SellEntry(order);
  }
}






i think the function I was in this section I was hoping to modify or add to the existing code.

if (sc.CrossOver(line1, line2) == CROSS_FROM_BOTTOM)
  {

    // mark the crossover on the chart
    BuyEntry[sc.Index] = 1;

    // Create a market order and enter long.
    s_SCNewOrder order;
    order.OrderQuantity = 1;
    order.OrderType = SCT_ORDERTYPE_MARKET;

    sc.BuyEntry(order);
  }

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

Login

Login Page - Create Account