Login Page - Create Account

Support Board


Date/Time: Sat, 04 May 2024 20:47:25 +0000



[Programming Help] - Strategy not exiting

View Count: 797

[2017-10-08 19:49:00]
vectorTrader - Posts: 86
Can someone give me an idea why this is not exiting.


// Create an s_SCNewOrder object.
  s_SCNewOrder NewOrder;
  NewOrder.OrderQuantity = 1;
  NewOrder.OrderType = SCT_ORDERTYPE_MARKET;
  NewOrder.TimeInForce = SCT_TIF_GOOD_TILL_CANCELED;

  int Result = 0;
  if (sc.Subgraph[4][sc.Index] > sc.Subgraph[4][sc.Index - 5] && sc.Close[sc.Index]<sc.Subgraph[6][sc.Index] &&
    sc.Subgraph[6][sc.Index]>sc.Subgraph[6][sc.Index - 2] && sc.Subgraph[6][sc.Index] <= sc.Subgraph[6][sc.Index - 3] &&
    sc.GetBarHasClosedStatus() == BHCS_BAR_HAS_CLOSED)
  {
    Result = sc.BuyEntry(NewOrder);
    if (Result > 0) //If there has been a successful order entry, then draw an arrow at the low of the bar.
    {
      BuyEntrySubgraph[sc.Index] = sc.Low[sc.Index];
    }
  }
  else if (PositionData.PositionQuantity > 0 && sc.CrossOver(FastMovAvgSubgraph,SlowMovAvgSubgraph)
     && sc.GetBarHasClosedStatus() == BHCS_BAR_HAS_CLOSED)
  {
    Result = sc.BuyExit(NewOrder);

    // If there has been a successful order entry, then draw an arrow at the high of the bar.
    if (Result > 0)
    {
      SellExitSubgraph[sc.Index] = sc.High[sc.Index];
    }
  }
update: The Crossover signal in the sell is the same subgraghs as Subgraph[4] and Subgraph[5]
Date Time Of Last Edit: 2017-10-08 23:01:33

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

Login

Login Page - Create Account