Support Board
Date/Time: Sat, 19 Apr 2025 10:22:39 +0000
Post From: C2447 error when compiling Advanced Custom Studies
[2025-03-24 04:20:15] |
User595847 - Posts: 5 |
Hello, I’m encountering Error C2447: '(': missing function header (old-style formal list?) when I try to compile my custom strategy script. The error seems to be related to function headers or syntax, but I’m unable to pinpoint the exact cause. I’ve tried reviewing the function definitions and headers, checked for missing function headers or syntax errors in my custom function declarations but to no avail. If you could help pinpoint the problem and suggest how to fix the missing function header or any other related issues, I’d greatly appreciate it. Full script is below. Thank you for your assistance! Best regards, Mark #include "sierrachart.h" SCDLLName("Trade Logic Strategy") // Initialize study settings function void InitializeStudy(SCStudyInterfaceRef sc) { if (sc.SetDefaults) { sc.GraphName = "Trade Logic Strategy"; sc.StudyDescription = "Automated strategy using predefined levels and opening range."; sc.AutoLoop = 1; // Inputs sc.Input[0].Name = "Predefined Level"; sc.Input[0].SetFloat(4000.0); sc.Input[1].Name = "Opening Range Start Time"; sc.Input[1].SetTime(HOURS(9) + MINUTES(30)); sc.Input[2].Name = "Tick Bar Size"; sc.Input[2].SetInt(2000); sc.Input[3].Name = "Stop Loss (Ticks)"; sc.Input[3].SetInt(10); sc.Input[4].Name = "Target Profit (Ticks)"; sc.Input[4].SetInt(20); sc.Input[5].Name = "Order Quantity"; sc.Input[5].SetInt(1); sc.AllowMultipleEntriesInSameDirection = false; sc.MaximumPositionAllowed = 1; sc.SupportReversals = false; sc.SendOrdersToTradeService = false; } } // Calculate Opening Range void CalculateOpeningRange(SCStudyInterfaceRef sc, float &openingRangeHigh, float &openingRangeLow, bool &openingRangeSet) { SCDateTime now = sc.BaseDateTimeIn[sc.Index]; SCDateTime openingRangeStartTime = sc.Input[1].GetTime(); if (!openingRangeSet && now >= openingRangeStartTime && now < openingRangeStartTime + SCDateTime(0, 3600)) { openingRangeHigh = max(openingRangeHigh, sc.High[sc.Index]); openingRangeLow = min(openingRangeLow, sc.Low[sc.Index]); } else if (now > openingRangeStartTime + SCDateTime(0, 3600)) { openingRangeSet = true; } } // Check trade conditions bool CheckTradeConditions(SCStudyInterfaceRef sc, float predefinedLevel, float openingRangeHigh, float openingRangeLow) { bool isAboveConditions = (sc.Close[sc.Index] > predefinedLevel) && (sc.Close[sc.Index] > openingRangeHigh); bool isBelowConditions = (sc.Close[sc.Index] < predefinedLevel) && (sc.Close[sc.Index] < openingRangeLow); return isAboveConditions || isBelowConditions; } // Execute the trade void ExecuteTrade(SCStudyInterfaceRef sc, bool isAboveConditions, bool isBelowConditions, int orderQuantity, int stopLossTicks, int targetProfitTicks) { s_SCNewOrder NewOrder; NewOrder.OrderType = SCT_ORDERTYPE_MARKET; NewOrder.OrderQuantity = orderQuantity; NewOrder.TimeInForce = SCT_TIF_GOOD_TILL_CANCELED; NewOrder.AttachedOrderStopOffset = stopLossTicks * sc.TickSize; NewOrder.AttachedOrderTargetOffset = targetProfitTicks * sc.TickSize; if (isAboveConditions) { int result = sc.BuyEntry(NewOrder); if (result > 0) sc.AddMessageToLog("✅ Long trade executed", 0); } else if (isBelowConditions) { int result = sc.SellEntry(NewOrder); if (result > 0) sc.AddMessageToLog("✅ Short trade executed", 0); } } // Main function: Sierra Chart entry point SCSFExport void scsf_TradeLogicStrategy(SCStudyInterfaceRef sc) { // Initialize study settings InitializeStudy(sc); // Ensure valid index if (sc.Index < 1) return; // Retrieve input values float predefinedLevel = sc.Input[0].GetFloat(); int orderQuantity = sc.Input[5].GetInt(); int stopLossTicks = sc.Input[3].GetInt(); int targetProfitTicks = sc.Input[4].GetInt(); // Variables for opening range static float openingRangeHigh = 0.0; static float openingRangeLow = 0.0; static bool openingRangeSet = false; // Calculate the opening range CalculateOpeningRange(sc, openingRangeHigh, openingRangeLow, openingRangeSet); // Check if trade conditions are met bool tradeConditionsMet = CheckTradeConditions(sc, predefinedLevel, openingRangeHigh, openingRangeLow); // Execute trade if conditions are met if (tradeConditionsMet) { ExecuteTrade(sc, (sc.Close[sc.Index] > predefinedLevel && sc.Close[sc.Index] > openingRangeHigh), (sc.Close[sc.Index] < predefinedLevel && sc.Close[sc.Index] < openingRangeLow), orderQuantity, stopLossTicks, targetProfitTicks); } } |