Login Page - Create Account

Support Board


Date/Time: Wed, 07 May 2025 16:02:57 +0000



Post From: recalculation infinite loop if chart contains 1 bar

[2024-11-28 23:38:59]
seandunaway - Posts: 348
please check that an intraday chart with 1 bar (e.g. 1 days loaded and 1 day bar period) is in constant recalculation

#include <sierrachart.h>

SCDLLName("recalc")
SCSFExport scsf_recalc(SCStudyInterfaceRef sc) {
  if (sc.SetDefaults) {
    sc.AllowOnlyOneTradePerBar = 0;
    sc.GraphName = "recalc";
    sc.GraphRegion = 0;
    sc.UpdateAlways = 1;
    return;
  }

  if (sc.IsFullRecalculation) return; // !
  if (!sc.GetCustomStudyControlBarButtonEnableState(2)) return;

  s_SCNewOrder order;
  order.OrderQuantity = 1;
  order.OrderType = SCT_ORDERTYPE_MARKET;

  int result = sc.BuyEntry(order);
  if (result < 0) sc.AddMessageToTradeServiceLog(sc.GetTradingErrorTextMessage(result), 1, 1);

  sc.SetCustomStudyControlBarButtonEnable(2, 0);
}

animated gif attached
Date Time Of Last Edit: 2024-11-29 00:39:40
imagerecalc.gif / V - Attached On 2024-11-28 23:38:53 UTC - Size: 2.53 MB - 47 views