loop after if else statement ?

 

Hello All . Please help .

I am trying to do the following . but i cant figure out how ? I tried to use if else It does not give the wanted result. Any advice/fix please.

1.if I choose userinput value 2 then the value of shift should be cross_ago ( another user input value ) and then it should do the lines inside {

2. if i choose userinput value 1 then the shift should be the initiator expression for the for loop for the lines inside {

I am just trying to make a filter where I can choose to see result given by all the shift values from 1 to  till cross_ago ( hence the need for the loop ) or  values given by  just one shift=cross_ago only .The whole thing is nested inside another loop.

 if (userinputvalue ==1)
        
       
          int shift ;
          for(shift = 1; shift< (cross_ago +1 );shift++)
      
         else
         
         shift= cross_ago ;    
          
           {

            double mv0 = iStochastic(Symbname[i],timeframes[j],StochK,StochD,StochSlowing,StochMethod,StochPrice,MODE_MAIN,shift);
            double sv0 = iStochastic(Symbname[i],timeframes[j],StochK,StochD,StochSlowing,StochMethod,StochPrice,MODE_SIGNAL,shift);

            double mv1 = iStochastic(Symbname[i],timeframes[j],StochK,StochD,StochSlowing,StochMethod,StochPrice,MODE_MAIN,shift+1);
            double sv1 = iStochastic(Symbname[i],timeframes[j],StochK,StochD,StochSlowing,StochMethod,StochPrice,MODE_SIGNAL,shift+1);
 
if(????)
   {
    //
   }
else
   {
    //
   }
 
Keith Watford:

Thank you Keith . I did as you told. But It does not work as intended. What am I doing wrong ?

        int shift;

         if(only_OR_inclusive==1)
           
            shift=cross_ago; // this line does not seem to have any effect 
           
         else
           
            for(shift = 1; shift< (cross_ago +1); shift++) // only this line produces results
              

           {


            double mv0 = iStochastic(Symbname[i],timeframes[j],StochK,StochD,StochSlowing,StochMethod,StochPrice,MODE_MAIN,shift);
            double sv0 = iStochastic(Symbname[i],timeframes[j],StochK,StochD,StochSlowing,StochMethod,StochPrice,MODE_SIGNAL,shift);

            double mv1 = iStochastic(Symbname[i],timeframes[j],StochK,StochD,StochSlowing,StochMethod,StochPrice,MODE_MAIN,shift+1);
            double sv1 = iStochastic(Symbname[i],timeframes[j],StochK,StochD,StochSlowing,StochMethod,StochPrice,MODE_SIGNAL,shift+1);

If the only_OR_inclusive value = 1 .I would like  the value of the shift to be cross_ago ( user input value) and do codes in  { ....

if the only_OR_value is different then I would like the codes inside { done as part of the for  loop as expressed after else.

 

I am not sure what you are trying to do.

Maybe

   int shift;
   if(only_OR_inclusive==1)
      shift=cross_ago; // this line does not seem to have any effect
   else
      shift = 1;

   for(; shift< (cross_ago +1); shift++) // only this line produces results
      {
      //
      }
 
Keith Watford:

I am not sure what you are trying to do.

Maybe

THANK YOU KEITH !

works perfectly now.