Login Page - Create Account

Support Board


Date/Time: Mon, 24 Feb 2025 01:07:29 +0000



Post From: reseting calculation every day

[2021-02-23 21:09:24]
Flipper_2 - Posts: 57
if (StartIndex == sc.Index) sc.Index = 0;

This isn't correct. Its saying if the current bar is the start of day set the current bar Index to 0! The bar indexes are read only!


no, i dont hold any persist vars. i keep track of a candlestick pattern

Well you have to. If you want the condition to reset each day you have to have something to re-set. Some sort of bool condition.If you only want the condition to be true once a day its pretty simple with a version of the pattern I suggested above.

int& OncePerDay = sc.GetPersistentInt(0);


if ( StartIndex == sc.Index) {
OncePerDay = 0; // this re-set the Persistent int at the start of each day.
}

if (OncePerDay == 0 && sc.High[sc.Index] > sc.High[sc.Index - 1] && sc.High[sc.Index - 1] > sc.High[sc.Index - 2] ){
Subgraph_IB[sc.Index] = sc.Index;
Subgraph_IB[sc.Index-1] = sc.Index;
Subgraph_IB[sc.Index-2] = sc.Index;
OncePerDay = 1; // Now you have reset the Persistent varrible to 1 so this code block will not trigger until the next day
}

Date Time Of Last Edit: 2021-02-23 21:21:09