Cant use +=, wont return desired return.

FranK Duc 121 Reputation points
2021-02-01T13:40:41.69+00:00

Hello,

Cant understand why += wont sum in this context my variable difCP .

if(CurrentBar < 1) return;


DateTime MyDateTime9 = new DateTime(Time[0].Year,Time[0].Month, Time[0].Day, 09, 30, 0);
DateTime MyDateTime16 = new DateTime(Time[0].Year,Time[0].Month, Time[0].Day-1, 16, 00, 0);



                    Print("time"+ChartBars.GetBarIdxByTime(ChartControl, MyDateTime9));
                    Print("time"+ChartBars.GetBarIdxByTime(ChartControl, MyDateTime16));        

      double difCplus = 0;

     double closePrice16 = Bars.GetClose(Bars.GetBar(MyDateTime16));
     double closePrice9 = Bars.GetClose(Bars.GetBar(MyDateTime9));

      double    difCP = closePrice16 - closePrice9;



      difCplus += difCP;

                  Print("dif"+difCP);
                  Print("CP"+closePrice16);
                  Print("CP"+closePrice9);
                Print("DP"+ difCplus);

                  double candle = Close[0] + difCplus;

                  Print("Can"+candle);

difCplus is Printed does not return a cumulative sum.

-2,10,-2

it should return -2, 8, 6

TY

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,111 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Abdulhakim M. Elrhumi 356 Reputation points
    2021-02-02T00:35:46.393+00:00

    Hi

    label6.Text=DateTime.Now.Month.ToString()+"/"+DateTime.Now.Year.ToString();
          for (int i=1;i<13;i++)
          {
            comboBox1.Items.Add(dt.GetMonthName(i).ToString());
          }
    

    //Cant use +=

    Best Regards.
    Please remember to mark the replies as answers if they help.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.