Support Board
Date/Time: Wed, 27 Nov 2024 08:32:43 +0000
[User Discussion] - ACSIL trade certain hours
View Count: 2233
[2014-08-17 00:07:34] |
User021827 - Posts: 174 |
Hi Can I ask how to add 10 am to 4pm trading times to the code ? And flatten at 4PM ? I am trying to port my spreadsheet strategy over to ACSIL. I have everything else done, but I cant figure out these things. thanks shane |
[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
|
[2014-08-17 13:30:03] |
User120827 - Posts: 77 |
Hi Thanks, I am not proficient at this but was able to get the "flatten" part to work. I had to adapt because I had 2 line inputs to work around. It took awhile, but I was able to get the times to work also. I do appreciate your help with this. It is difficult for me after using spreadsheets. Thank you very much for your assistance. You were extremely helpful ! regards Shane Date Time Of Last Edit: 2014-08-17 13:47:26
|
To post a message in this thread, you need to log in with your Sierra Chart account: