I am looking for your help to get the indicator to work the same way on historical data as it does on live data.
In my indicator code, I maintain an internal list of bars, which is classified as either UP or DOWN according to some other indicators. I try to put the same "UP" or "DOWN"
bars into the same list. When a new bar is closed with a different "UP" or "DOWN", the decision is deferred until the close of the 2nd bar. If the 1st bar is the only different one, then
the difference is considered as noise. In this case, both two bars will be added into the latest list. If the 2nd bar is classified as the same of the 1st bar, then a new list will be created
to replace the previous list.
I use the below code to manage the list
===============================================
//calculate indicator values to be used internally in this custom indicator,
calculations are here on every tick;
if(FirstTickOfBar)
{
//when bar close,
//Manage the new incoming bars and add them into the list
//If 1st different bar is incoming, then wait till the 2nd bar close to decide.
//Otherwise, simply add the incoming bar to the list
//A new list is to be created only when 2 consecutive bars are classified as different to those in the latest list.
//in this case, a new list will be created at the close of 2nd bar.
}
else
{
//predict the new UP/DOWN of a ongoing bar against the latest list on every tick.
//STRANGE
//NEW LIST IS ALREADY CREATED WHILE THE 2ND BAR IS STILL TICKING!!!!!!!
}
===============================================
I believe I have something missing in the code. I am expecting to do some prediction using the latest list.
It seems FirstTickOfBar is already true while the 2nd bar is still ongoing, which leads to different decision making with historical data.
Thank you for your suggestions.
Best Regards
David
Comment