Login Page - Create Account

Support Board


Date/Time: Mon, 23 Dec 2024 18:59:18 +0000



market orders and BHCS_BAR_HAS_CLOSED

View Count: 873

[2015-10-15 17:35:36]
cmb999 - Posts: 211
In a bar-based back test, i am checking:

sc.GetBarHasClosedStatus() == BHCS_BAR_HAS_CLOSED

before creating and sending a market order.

however, the market order does not execute until the close of the bar (or open of next one, cant tell which yet).

how can i get the open of the current bar (or near it) to be the execution price for the market order as it would be in real-time ?
[2015-10-16 00:08:06]
ejtrader - Posts: 688
You can check my earlier post - it should help in this case as well.

ACSIL - How to run part of code only once per bar | Post: 57332
[2015-10-16 20:09:04]
Sierra Chart Engineering - Posts: 104368
It would make sense to send the order when a new bar is added to the chart if the conditions are met.

This code example will help:

SCSFExport scsf_DetectingNewBarsAdded(SCStudyInterfaceRef sc)
{
  if (sc.SetDefaults)
  {
    // Set the configuration and defaults

    sc.GraphName = "Detecting New Bars Added";

    sc.AutoLoop = 1;
    
    sc.FreeDLL = 0;

    return;
  }


  // Do data processing

  int& PriorArraySize = sc.GetPersistentInt(1);

  //This is not a full recalculation of the study
  if (!sc.IsFullRecalculation)
  {
    // If there are new bars added
    if (PriorArraySize < sc.ArraySize)
    {
      // put processing here that is required for when new bars are added to the chart
    }
  }
  
  PriorArraySize = sc.ArraySize;

  

}

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