Support Board
Date/Time: Wed, 27 Nov 2024 10:35:14 +0000
Post From: ACSIL trade certain hours
[2014-08-17 07:12:47] |
vegasfoster - Posts: 444 |
Didn't test, but try this. Must consider if processing at bar close and the type of bar you are using, for example non-time based bars could close after your cutoff. if (sc.SetDefaults) { sc.Input[0].Name = "Start Hour"; sc.Input[0].SetInt(10); sc.Input[0].SetIntLimits(0,23); sc.Input[1].Name = "Start Minute"; sc.Input[1].SetInt(0); sc.Input[1].SetIntLimits(0,59); sc.Input[2].Name = "End Hour"; sc.Input[2].SetInt(16); sc.Input[2].SetIntLimits(0,23); sc.Input[3].Name = "End Minute"; sc.Input[3].SetInt(0); sc.Input[3].SetIntLimits(0,59); } int StartTime, EndTime, InputDate; SCDateTime StartDateTime, EndDateTime, InputDateTime1, InputDateTime2; InputDate = sc.BaseDateTimeIn[sc.Index].GetDate(); InputDateTime1 = sc.BaseDateTimeIn[sc.Index]; InputDateTime2 = sc.BaseDateTimeIn[sc.Index-1]; StartTime = HMS_TIME(sc.Input[0].GetInt(), sc.Input[1].GetInt(), 0); StartDateTime = COMBINE_DATE_TIME(InputDate, StartTime); EndTime = HMS_TIME(sc.Input[2].GetInt(), sc.Input[3].GetInt(), 0); EndDateTime = COMBINE_DATE_TIME(InputDate, EndTime); if (InputDateTime1 > StartDateTime && InputDateTime1 < EndDateTime) { INSERT TRADING CODE HERE } if (InputDateTime2 < EndDateTime && InputDateTime1 >= EndDateTime) { sc.FlattenAndCancelAllOrders(); } Date Time Of Last Edit: 2014-08-17 07:13:38
|