Support Board
Date/Time: Tue, 26 Nov 2024 08:42:43 +0000
[Programming Help] - How do I set Trades between Specific Hours
View Count: 307
[2023-12-21 07:09:58] |
User719760 - Posts: 6 |
I have a ASCIL code as given below : How I can modify it to trade between a specific Start Time and End Time that is given by me? // The top of every source code file must include this line #include "sierrachart.h" // For reference, refer to this page: // Advanced Custom Study Interface and Language (ACSIL) // This line is required. Change the text within the quote // marks to what you want to name your group of custom studies. SCDLLName("Custom Study DLL") //This is the basic framework of a study function. Change the name 'TemplateFunction' to what you require. SCSFExport scsf_TemplateFunction(SCStudyInterfaceRef sc) { // Section 1 - Set the configuration variables and defaults SCInputRef Entry_Time = sc.Input[4]; SCInputRef Exit_Time = sc.Input[5]; if (sc.SetDefaults) { sc.GraphName = "Template Function"; sc.AutoLoop = 1; //Automatic looping is enabled. sc.AllowMultipleEntriesInSameDirection = true; sc.MaximumPositionAllowed = 10; sc.SupportReversals = false; sc.SendOrdersToTradeService = false; sc.AllowOppositeEntryWithOpposingPositionOrOrders = true; sc.SupportAttachedOrdersForTrading = false; sc.CancelAllOrdersOnEntriesAndReversals= false; sc.AllowEntryWithWorkingOrders = false; sc.CancelAllWorkingOrdersOnExit = false; sc.AllowOnlyOneTradePerBar = true; sc.MaintainTradeStatisticsAndTradesData = true; return; } SCGraphData StudyData; sc.GetStudyArraysFromChartUsingID(2, 2, StudyData); SCFloatArrayRef RSI = StudyData[3]; SCGraphData StudyData1; sc.GetStudyArraysFromChartUsingID(2,1, StudyData1); SCFloatArrayRef upper = StudyData1[0]; SCFloatArrayRef middle = StudyData1[1]; SCFloatArrayRef lower = StudyData1[2]; if(sc.GetBarHasClosedStatus() == BHCS_BAR_HAS_CLOSED) { float open = sc.BaseData[SC_OPEN][sc.Index]; float high = sc.BaseData[SC_HIGH][sc.Index]; float low = sc.BaseData[SC_LOW][sc.Index]; float close = sc.BaseData[SC_LAST][sc.Index]; float currRSi = RSI[sc.Index]; float uppboll = upper[sc.Index]; float lowboll = lower[sc.Index]; bool buycondition = close < lowboll && currRSi < 5; bool sellcondition = close > uppboll && currRSi > 95; if(buycondition){ s_SCNewOrder NewOrder; int Result = 0; NewOrder.OrderQuantity = 1; NewOrder.OrderType = SCT_ORDERTYPE_MARKET; NewOrder.TextTag = "Market Order"; NewOrder.TimeInForce = SCT_TIF_GOOD_TILL_CANCELED; NewOrder.Stop1Offset = 50*sc.TickSize; NewOrder.Target1Offset = 70*sc.TickSize; Result = static_cast<int>(sc.BuyEntry(NewOrder)); } if(sellcondition){ s_SCNewOrder NewOrder; int Result = 0; NewOrder.OrderQuantity = 1; NewOrder.OrderType = SCT_ORDERTYPE_MARKET; NewOrder.TextTag = "Market Order"; NewOrder.TimeInForce = SCT_TIF_GOOD_TILL_CANCELED; NewOrder.Stop1Offset = 50*sc.TickSize; NewOrder.Target1Offset = 70*sc.TickSize; Result = static_cast<int>(sc.SellEntry(NewOrder)); } } // Section 2 - Do data processing here } |
[2023-12-24 07:14:18] |
Ticks - Posts: 183 |
Did you take the time to look through the example code that Sierra provides in the ACS_source folder?
|
To post a message in this thread, you need to log in with your Sierra Chart account: