[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 641

 
Craft:

What to do then? I tried for(i=0;i<=PeriodS;i++) - didn't help.


As you have already been told

   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);

iMAOnArray is executed outside the loop (as it should be). Correspondingly, i+2 = PeriodB + 2. For ArrayResize(c1b,PeriodB);

And in fact ... replace your "i+" with 0,2,3.

 
SergNF:


As already written to you

iMAOnArray is executed outside the loop (as it should be). Correspondingly, i+2 = PeriodB + 2. For ArrayResize(c1b,PeriodB);

And in fact ... Replace your "i+" with 0,2,3.


Thank you, I did everything as you said, but now why aren't the orders being placed?

I tried it both with and without normalization.

   double c1b[];
   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,1);
   double c1b_2=iMAOnArray(c1b,0,AvgB,0,MODE_SMA,2);
   double c1b_3=iMAOnArray(c1b,0,AvgB,0,MODE_SMA,3);
   
   double c1s[];
   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,1);
   double c1s_2=iMAOnArray(c1s,0,AvgS,0,MODE_SMA,2);
   double c1s_3=iMAOnArray(c1s,0,AvgS,0,MODE_SMA,3);

 //if (NormalizeDouble(c1s_1,4)>NormalizeDouble(c1s_2,4)&&NormalizeDouble(c1s_2,4)<NormalizeDouble(c1s_3,4))
 if (c1s_1>c1s_2&&c1s_2<c1s_3)
     {                                          // 
      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))
if (c1b_1<c1b_2&&c1b_2>c1b_3)
     {                                          // 
      Opn_S=true;                               // Критерий откр. Sell
      Cls_B=true;                               // Критерий закр. Buy
     }
 
gordeef:

Sorry, I didn't answer right away, my notebook died completely. I hope my tooth doesn't hurt anymore, it's a scary thing. I confess, I was blaming Babon, he works fine, but the fault indicator NMAZZ, I do not remember where I downloaded it, but on one chart it still works, but I put it on three charts (5M, 30M, 4H) and all, 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 reversal or correction, yes you are right, it's always a reversal but if at 30M, 1H and 4H the baton changes colour, if not a reversal, then correction is certain and we may make some profit.
Yes... Sore tooth does wonders... Wherever you go with it... :) If you like an indicator and want to work with it - either iCustom, or into Expert Advisor's code, I think. But about the trend TP - be careful, you may buy it at the end of the move, i.e., before the reversal. Then the moose will hang in the air (like me yesterday with a bad tooth... :))). I am working on the definition of the trend exhaustion at the moment, I hope I will share my results.
 
Craft:


Thanks, did everything as you said, but now why aren't the orders being placed?

Tried both with and without normalisation.


Well then only an "unpriming" after both if's to see if the error is in this block or not (Including Opn_B and Cls_S) One line and you will know everything.

I don't know, maybe you reassign them (Opn_B and Cls_S) afterwards or use completely different variables when opening.

 
artmedia70:
Yes... A bad tooth can do wonders... Wherever you go with it... :)

You haven't tried treatment. They say it works.
 
Vinin:

Have you tried treatment? They say it helps.
Oh, yeah! You live and learn... ;) Only at night we can't find any dentists in Zakolyuchinsk... I had to use folk remedies...
 

Guys, I understand that miracles don't happen, but I can't win... I'm already looking under the table to see if Hottabych is sitting there... :)

I tried to display some EA data in the indicator window and decided to display trends in the same window. I calculate trends with my function, which returns int -1, 0 and +1 values. Accordingly, the down trend = 1, flat = 0, up trend = 1. I noticed that the arrows appear as they wish, but not in the direction of trends on different TFs. So, I commented out the arrows for a long time and replaced them with the output of the value returned by the trend function. In two places of the code, I placed the output of the state returned by this function. It returns its state correctly; in the upper left corner of the chart the function values are displayed directly after the call of this function. Below, in the indicator window the function values are also displayed. The numbers are correct, but the fourth value of the function, which by definition returns only three numbers, is taken from somewhere... So at this fourth value, the indicator window displays the message "Fuck you"... Well, I've already written it myself out of anger... :)

Help me to understand what the problem is? I don't want to believe in Hassan Obdurahman ibn Hottab... :):)

   ObjectCreate("trM15",OBJ_LABEL,1,0,0,0,0);
   ObjectSet("trM15",OBJPROP_XDISTANCE,x*10);
   ObjectSet("trM15",OBJPROP_YDISTANCE,y*10);
   
   ObjectCreate("ArrowM15",OBJ_LABEL,1,0,0,0,0);
   ObjectSet("ArrowM15",OBJPROP_XDISTANCE,x*17);
   ObjectSet("ArrowM15",OBJPROP_YDISTANCE,y*10);
   
   if (trM15==1)
      {
         ObjectSetText("trM15","Тренд M15",9,"Tahoma",Lime);
//         ObjectSetText("ArrowM15",CharToStr(241),10,"Wingdings",Lime);
         ObjectSetText("ArrowM15",DoubleToStr(trM15,0),9,"Tahoma",Lime);
      }
   if (trM15==-1)
      {
         ObjectSetText("trM15","Тренд M15",9,"Tahoma",OrangeRed);
//         ObjectSetText("ArrowM15",CharToStr(242),10,"Wingdings",OrangeRed);
         ObjectSetText("ArrowM15",DoubleToStr(trM15,0),9,"Tahoma",OrangeRed);
      }
   if (trM15==0)
      {
         ObjectSetText("trM15","Тренд M15",9,"Tahoma",OrangeRed);
//         ObjectSetText("ArrowM15",CharToStr(240),10,"Wingdings",OrangeRed);
         ObjectSetText("ArrowM15",DoubleToStr(trM15,0),9,"Tahoma",OrangeRed);
      }
   else
      {
         ObjectSetText("trM15","Хрен вам",9,"Tahoma",LightGray);
//         ObjectSetText("ArrowM15",CharToStr(240),10,"Wingdings",LightGray);
         ObjectSetText("ArrowM15",DoubleToStr(trM15,0),9,"Tahoma",LightGray);
      }

Here I have already tried to check all four states, not just -1, 1 and else...

And that's what it outputs to me - else

trM15 is a variable, which is assigned a value returned by the trend function

In the picture you can see that the values are returned correctly, but the "funny inscription" is printed, which is only if else

My head is already at the seams...

 
artmedia70:

Guys, I understand that miracles don't happen, but I can't win... I'm already looking under the table to see if Hottabych is sitting there... :)

I tried to display some EA data in the indicator window and decided to display trends in the same window. I calculate trends with my function, which returns int -1, 0 and +1 values. Accordingly, the down trend = 1, flat = 0, up trend = 1. I noticed that the arrows appear as they wish, but not in the direction of trends on different TFs. So, I commented out the arrows for a long time and replaced them with the output of the value returned by the trend function. In two places of the code, I placed the output of the state returned by this function. It returns its state correctly; in the upper left corner of the chart the function values are displayed directly after the call of this function. Below, in the indicator window the function values are also displayed. Numerically everything is correct, but somewhere takes the fourth value of the function, which by definition returns only three numbers... So at this fourth value, the indicator window displays the message "Fuck you"... Well, I've already written it myself out of anger... :)

Help me to understand what the problem is? I don't want to believe in Hasan Obdurahman ibn Hottab... :):)

Here I have already tried to check all four states, not just -1, 1 and else...

And that's what it outputs to me - else

trM15 is a variable, which is assigned a value returned by the trend function

In the picture you can see that the values are returned correctly, while the "funny inscription" is displayed that only if else

My head is already at the seams...



That's right.

ObjectCreate("trM15",OBJ_LABEL,1,0,0,0,0);
   ObjectSet("trM15",OBJPROP_XDISTANCE,x*10);
   ObjectSet("trM15",OBJPROP_YDISTANCE,y*10);
   
   ObjectCreate("ArrowM15",OBJ_LABEL,1,0,0,0,0);
   ObjectSet("ArrowM15",OBJPROP_XDISTANCE,x*17);
   ObjectSet("ArrowM15",OBJPROP_YDISTANCE,y*10);
   
   if (trM15==1)
      {
         ObjectSetText("trM15","Тренд M15",9,"Tahoma",Lime);
//         ObjectSetText("ArrowM15",CharToStr(241),10,"Wingdings",Lime);
         ObjectSetText("ArrowM15",DoubleToStr(trM15,0),9,"Tahoma",Lime);
      }
   else if (trM15==-1)
      {
         ObjectSetText("trM15","Тренд M15",9,"Tahoma",OrangeRed);
//         ObjectSetText("ArrowM15",CharToStr(242),10,"Wingdings",OrangeRed);
         ObjectSetText("ArrowM15",DoubleToStr(trM15,0),9,"Tahoma",OrangeRed);
      }
   else if (trM15==0)
      {
         ObjectSetText("trM15","Тренд M15",9,"Tahoma",OrangeRed);
//         ObjectSetText("ArrowM15",CharToStr(240),10,"Wingdings",OrangeRed);
         ObjectSetText("ArrowM15",DoubleToStr(trM15,0),9,"Tahoma",OrangeRed);
      }
   else
      {
         ObjectSetText("trM15","Хрен вам",9,"Tahoma",LightGray);
//         ObjectSetText("ArrowM15",CharToStr(240),10,"Wingdings",LightGray);
         ObjectSetText("ArrowM15",DoubleToStr(trM15,0),9,"Tahoma",LightGray);
      }

You may try this variant

 
Vinin:


That's right.

You could try this

OK. Thank you, Victor. So far it's working correctly. So far, because I haven't followed it for a long time, but NEVER had it output Trend Up to me before. It is now:


I knew there was always a more powerful sorcerer-wizard for one sorcerer-wannabe... :)

Of course, it's all a joke, but... Victor, I don't just want to copy the right solution, but to find out and understand where the problem lies, what is the reason for such incomprehensible code's behavior?

 
artmedia70:
Yes... A bad tooth can do wonders... Wherever you go with it... :) If you like an indicator and want to work with it - either iCustom or EA code, I think. But about the trend TP - be careful, you may buy it at the end of the move, i.e., before the reversal. Then the moose will hang in the air (like me yesterday with a bad tooth... :))). I am working on the definition of the trend exhaustion at the moment, I hope I will share my results.

Yeah I'm trying to be cautious about reversals and corrections as it is. But concerning the trend exhaustion I am also interested in it, I wandered through the forum and looked at the CodeBase but did not encounter any indices on this theme. It will be interesting to read your results. I have another question, they sent me an EA that controls my losses and profits, like in the picture it should work, but the question is, it has a 15 point profit and I see that the price may go even higher, if I increase the profit on one or another trade, it may break the general calculations and operation of the EA?
Reason: