[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 640

 

I can't figure out what's wrong with the arrays (the condition is simple - buy/sell after the next peak of smoothed CCI):

The strategy compiles without errors and does not write anything in the log at startup, but no orders are placed.

   double c1b[];
   ArrayResize(c1b,PeriodB);
   for(i=1;i<=PeriodB;i++)
   c1b[i]=iCCI(NULL,0,PeriodB,PRICE_TYPICAL,i);
   double c1b_1=iMAOnArray(c1b,0,AvgB,0,MODE_SMA,i);
   double c1b_2=iMAOnArray(c1b,0,AvgB,0,MODE_SMA,i+2);
   double c1b_3=iMAOnArray(c1b,0,AvgB,0,MODE_SMA,i+3);
   
   double c1s[];
   ArrayResize(c1b,PeriodS);
   for(i=1;i<=PeriodS;i++)
   c1s[i]=iCCI(NULL,0,PeriodS,PRICE_TYPICAL,i);
   double c1s_1=iMAOnArray(c1s,0,AvgS,0,MODE_SMA,i);
   double c1s_2=iMAOnArray(c1s,0,AvgS,0,MODE_SMA,i+2);
   double c1s_3=iMAOnArray(c1s,0,AvgS,0,MODE_SMA,i+3);


   if (c1s_1>c1s_2&&c1s_2<c1s_3)
     {                                          //
      Opn_B=true;                               // Критерий откр. Buy
      Cls_S=true;                               // Критерий закр. Sell
     }
   if (c1b_1<c1b_2&&c1b_2>c1b_3)
     {                                          //
      Opn_S=true;                               // Критерий откр. Sell
      Cls_B=true;                               // Критерий закр. Buy
     }
 


double c1s[];
ArrayResize(c1b,PeriodS)

You declare one array and change another.

 
Roger:


double c1s[];
ArrayResize(c1b,PeriodS)

You declare one array and change another.


Thanks, what else is wrong - didn't help.
 

The array starts with a zero element, so the expression

for(i=1;i<=PeriodS;i++)

skips zero and does not write anything to the last one.

further on, only this expression will be executed in the loop

c1b[i]=iCCI(NULL,0,PeriodB,PRICE_TYPICAL,i);

the rest are meaningless, after the loop i equals maximum and therefore all values will be zero.

 
Craft:

what else is wrong


comparing doubles without normalization is incorrect... try it this way:

   double c1b[];
   ArrayResize(c1b,PeriodB);
   for(i=1;i<=PeriodB;i++)
   c1b[i]=iCCI(NULL,0,PeriodB,PRICE_TYPICAL,i);
   double c1b_1=iMAOnArray(c1b,0,AvgB,0,MODE_SMA,i);
   double c1b_2=iMAOnArray(c1b,0,AvgB,0,MODE_SMA,i+2);
   double c1b_3=iMAOnArray(c1b,0,AvgB,0,MODE_SMA,i+3);
   
   double c1s[];
   ArrayResize(c1b,PeriodS);
   for(i=1;i<=PeriodS;i++)
   c1s[i]=iCCI(NULL,0,PeriodS,PRICE_TYPICAL,i);
   double c1s_1=iMAOnArray(c1s,0,AvgS,0,MODE_SMA,i);
   double c1s_2=iMAOnArray(c1s,0,AvgS,0,MODE_SMA,i+2);
   double c1s_3=iMAOnArray(c1s,0,AvgS,0,MODE_SMA,i+3);


   if (NormalizeDouble(c1s_1,4)>NormalizeDouble(c1s_2,4)&&NormalizeDouble(c1s_2,4)<NormalizeDouble(c1s_3,4))
     {                                          //
      Opn_B=true;                               // Критерий откр. Buy
      Cls_S=true;                               // Критерий закр. Sell
     }
   if (NormalizeDouble(c1b_1,4)<NormalizeDouble(c1b_2,4)&&NormalizeDouble(c1b_2,4)>NormalizeDouble(c1b_3,4))
     {                                          //
      Opn_S=true;                               // Критерий откр. Sell
      Cls_B=true;                               // Критерий закр. Buy
     }

 
DDFedor:


comparing doubles without normalisation is incorrect... Try it this way:


Thanks for the help, bros, still doesn't work.
 
Roger:

The array starts with a zero element, so the expression

for(i=1;i<=PeriodS;i++)

skips zero and does not write anything to the last one.

further on, only this expression will be executed in the loop

c1b[i]=iCCI(NULL,0,PeriodB,PRICE_TYPICAL,i);

the rest are meaningless, after the loop i equals maximum and therefore all values will be zero.


What should I do then? Tried for(i=0;i<=PeriodS;i++) - did not work.
 
Craft:

What then?

Put Printers on each variable at every code point and look in the logs to see what's going on at each step.
 

Hello, Can I ask you a newbie? When I write symbol() in the open function on the demo, but when I change it to a symbol, for example EURUSD, I get error 133.
{Alert("!");}else{Alert("?");} - It gives out "!", i.e. trading is allowed... and simultaneously 133. What is the problem? No EA opens trade if I indicate a certain symbol in the open function... I have tried everything.

Thank you in advance. i'm here not to clutter up the forum ))

 
artmedia70:
Who says these are reversals and not corrections?

Sorry, I didn't answer right away, my notebook died completely. I hope the tooth doesn't hurt anymore, it's a scary thing. My confession, I blame the Babon, it works fine and the indicator NMAZZ is to blame, I don't remember where I downloaded it, but it still works on one chart, but I have installed it on three charts (5M, 30M, 4H) and that's it, the computer froze completely, or rather the terminal. I started to remove indicators from charts one by one and found this bug. I do not know what is wrong with this indicator, but at the beginning it worked fine. And about the reversal or correction, yes you are right, it's always unequivocally a reversal, but if at 30M, 1H and 4H the baton changes colour, if not a reversal, then correction is unambiguous and you can make some profit.
Reason: