Could anybody help me, I'm stuck in simple code and simple math
I want to calculate how many up close and down close bars appeared in current session. And then I want to have one number like a somekind of coef, how many up close bars were in this session compared to all bars in this session.
so far what I get in output window is correct calculations for aboveS and belowS, but i get zeros for double sessionClose. So the code is not working.
In my deffence I'm total beginner in programming so any help or suggestions are wellcome. And maybe there's a more effective ways do that kinds of calculations.
Thank you all in advance.
private int numberOfBars = 0;
private int aboveS = 0;
private int belowS = 0;
private double sessionClose = 0.00;
protected override void OnBarUpdate()
{
if (Bars.FirstBarOfSession)
{
numberOfBars = 0;
private int aboveS = 0;
private int belowS = 0;
sessionClose = 0.00;
}
numberOfBars++;
if(numberOfBars <1) return;
if (Close[0] > Close[1])
aboveS++;
if (Close[0] < Close[1])
belowS++;
sessionClose = aboveS/(aboveS + belowS);
Print("Current session number of bars = " + numberOfBars.ToString() + “ // “ +“ sessionClose = “ + sessionClose.ToString()+ “ // “ + "Date = " + ToDay(Time[0]).ToString() + " // " + “Time = “ + ToTime(Time[0]).ToString());
}
Comment