Support Board
Date/Time: Mon, 24 Feb 2025 01:26:41 +0000
Post From: reseting calculation every day
[2021-02-24 12:55:19] |
User30743 - Posts: 365 |
no i am not looking for the FIRST occurrence, i am looking for all occurrences, but from the starting times i believe it is no really clear what the problem is, so i put together a simple study - it opens a long position when there are three consecutive highs. it trades only in RTH - from 8.30 to 14:00 the point is that it should not consider the bars before open as part of the price action pattern. look at that - https://prnt.sc/105nqgp how is it possible that i opened a trade on the 2. bar? logically, it should not, when i want to consider THREE bars back from the open this is the code for the study SCSFExport scsf_TakeTradeOnThirdRisingBar(SCStudyInterfaceRef sc) {
SCSubgraphRef Subgraph_IB = sc.Subgraph[0]; if (sc.SetDefaults) { sc.GraphName = "Take trade on 3 rising bar"; sc.GraphRegion = 0; sc.AutoLoop = 1; sc.Input[0].Name = "Start trading at: "; sc.Input[0].SetTime(HMS_TIME(8, 30, 0)); sc.Input[1].Name = "Stop trading at: "; sc.Input[1].SetTime(HMS_TIME(14, 00, 0)); sc.Input[2].Name = "Flat postion at: "; sc.Input[2].SetTime(HMS_TIME(15, 00, 30)); return; } s_SCPositionData pos; sc.GetTradePosition(pos); s_SCNewOrder order; order.OrderQuantity = 1; order.OrderType = SCT_ORDERTYPE_MARKET; order.Target1Offset = 10 * sc.TickSize; order.Stop1Offset = 10 * sc.TickSize; SCDateTime TradingDayStartDateTime = sc.GetTradingDayStartDateTimeOfBar(sc.BaseDateTimeIn[sc.IndexOfLastVisibleBar]); SCString s = sc.FormatDateTime(TradingDayStartDateTime).GetChars(); auto StartIndex = sc.GetFirstIndexForDate(sc.ChartNumber, TradingDayStartDateTime.GetDate()); bool areTradingHours = sc.BaseDateTimeIn[sc.Index].GetTime() > sc.Input[0].GetTime() && sc.BaseDateTimeIn[sc.Index].GetTime() < sc.Input[1].GetTime(); bool isTimeToFlat = sc.BaseDateTimeIn[sc.Index].GetTime() >= sc.Input[2].GetTime(); bool threeHigherHighs = sc.High[sc.Index] > sc.High[sc.Index - 1] && sc.High[sc.Index - 1] > sc.High[sc.Index - 2]; if (areTradingHours) { if (sc.Index >= StartIndex) { if (threeHigherHighs) { sc.BuyEntry(order); } } } if (isTimeToFlat) sc.FlattenPosition(); } this is my time session setting https://prnt.sc/105nx50 would be really glad if someone could explain me the issue Date Time Of Last Edit: 2021-02-24 13:12:00
|