Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 959

 
AlexeyVik:
Well, look for where the variables are reassigned. First, find where ClsS = false; and if it is executed.
ClsS = false in global variables. Aha! Got it - I'm changing false to true. Let's check...
 

WORKING! THANK YOU!

I'll go and check further. Thanks again.

 
Again, please help... Checking the opening/closing criteria shows that they appear according to the given conditions, but when I go further, the alert writes that they don't exist. Is there something I'm missing here too?
//----------------------------------------------------------------------------------- 8 -- Открытие ордеров

    while (Ticket==0)                                            // Цикл открытия ордеров
     {
      if (OpnB != true || OpnS != true)
         {
          Alert("Отсутствуют критерии открытия позиций");
          return;                                            // Выход из OnTick()
         }
      if (Total==0) Alert("открытых ордеров нет"); 

      if (Total==0 && OpnB == true)                         // Если открытых ордеров нет и есть критерий открытия БАЙ...
       {

        SL = Bid - New_Stop(StopLoss)*Point;                // СЛ открытия
        TP = Bid + New_Stop(TakeProfit)*Point;              // ТП открытия
        Alert("Попытка открыть БАЙ. Ожидание ответа...");
        Ticket=OrderSend(Symb,OP_BUY,Lots,Ask,2,SL,TP,Blue); // Открытие БАЙ
        if (Ticket>0)                                       // Если получилось...
         {
          Alert("Открыт ордер БАЙ №",Ticket);
        break;                                              // Выход из while
         }
 
gince:

mHow do I do it programmatically in the indicator ?

I don't know how to ask in the helper.

Maybe someone can give me a specific link or keywords.

SeeChartGetInteger() and CHART_WINDOW_IS_VISIBLE properties

 

Good day to you all! Now here's a question from out of the box..... Introducing the start function. Question, why at each new bar the variable N is doubled. At each new bar, while it should do it ONLY when a new signal arrives???

What do the developers have to say about it???

int start()
 { 
  int i,limit,K;
  int counted_bars=IndicatorCounted();

//  double R,P,N,Zscore,Nprof,Nloose;
//limit=Bars-100;

if (b!=Bars){
b=Bars;
//Sleep(3000);

double ldt_BeginDay = iTime (NULL, PERIOD_D1,20); 
double limit1 = iBarShift (NULL, 0, ldt_BeginDay);

   if(counted_bars<1) limit=limit1-counted_bars;
   else limit=limit1;

 for(i=limit; i>=1; i--)   
      {
       double Profit=(iCustom(NULL, 0, "TDSEQUENTA v2015",5,8,12,0,i)); 
       double CurSignal=(iCustom(NULL, 0, "TDSEQUENTA v2015",5,8,12,6,i)); 
if (CurSignal!=0){      
   /*   
if (curDay!=TimeDay(Time[i])) {
curDay=TimeDay(Time[i]);
double AAA=ProfitFactor;
}*/
      
   
       if ((Profit>0)&&(CurSignal!=0))  {Nprof=Nprof+1;
       if (LastProfit<=0) R=R+1;
                                                      SredP1=SredP1+Profit;
                                                      GrosProf=GrosProf+Profit;
                                                     } else Nprof=Nprof;
                                                     
       if ((Profit<0)&&(CurSignal!=0))  { Nloose=Nloose+1;
       if (LastProfit>=0) R=R+1;
                                                      SredL1=SredL1+(Profit*-1);                                                    
                                                      GrosLoose=GrosLoose+(Profit*-1);
                                                     } Nloose=Nloose;
      if (Nloose>0)SredL=SredL1/Nloose;
      if (Nprof>0) SredP=SredP1/Nprof;
      
      // if (Profit>0) Sred=Sred+Profit; else Sred=Sred+(Profit*-1);                                                                                                                                                    
       N=Nprof+Nloose;
       P=2*Nprof*Nloose;
     // if (Body!=LastBody)N=N+1;   
    //   if (CurSignal!=0)K=K+1;
       
      // if (CumDel!=0)Volum=AD/CumDel;
       if (((Nprof+Nloose)>5)&&(SredL!=0)) MO=(1+(SredP/SredL))*((Nprof/(Nprof+Nloose))-1); //MO
      //////////стандартное отклонение//////////
      if ((N>0)&&(LastProfit!=Profit))Sred1=Sred1+((Profit-(Sred/N))*(Profit-(Sred/N)));
      if ((N>2)&&(LastProfit!=Profit)) Sred2=sqrt(Sred1/(N-1));
      if ((Sred2>0)) Sharp=MO/Sred2;
       
       
       if (GrosLoose>0) ProfitFactor=GrosProf/(GrosLoose); //ProfitFactor
       
       if ((N>2)&&(P>5)) Zscore=(N*(R-0.5)-P)/sqrt((P*(P-N))/(N-1)); // Zscore
       
      if ((SredL>0)&&(SredP>0)&&(P>5))  Kelli=((1-(Nprof/N))/(SredP/SredL))-(Nprof/N);
    //Buffer0[i+1]=ProfitFactor;
    }
    
  //  Buffer1[i]=Kelli-LastKelli;
    //Buffer2[i]=Zscore-LastZscore;
     Buffer2[i]=N;
      // if ((Profit1>0)) Buffer3[i]=1; else Buffer3[i]=0;
  //      if ((Profit1<0)) Buffer5[i]=1; else Buffer5[i]=0;
    // Buffer4[i]=Sharp;
        //Buffer5[i]=HC;
  //      Buffer6[i]=LC;
  
  
  /*
  if (Buffer2[i]>0){
                     if (Profit>0.000){
                                 if (CurSignal>0) Buffer3[i]=1;
                                 if (CurSignal<0) Buffer3[i]=-1;
                                   }
                     if (Profit<0.000){
                                 if (CurSignal>0) Buffer3[i]=-1;
                                 if (CurSignal<0) Buffer3[i]=1;
                                   }
                   } 
  if (Buffer2[i]<0){
                     if (Profit>0.000){
                                 if (CurSignal>0) Buffer3[i]=-1;
                                 if (CurSignal<0) Buffer3[i]=1;
                                   }
                     if (Profit<0.000){
                                 if (CurSignal>0) Buffer3[i]=1;
                                 if (CurSignal<0) Buffer3[i]=-1;
                                   }
                   }*/
 /*
  
        LastPF=ProfitFactor;
        LastMO=MO;
        LastZscore=Zscore;
        LastSTD=STD;
        LastKelli=Kelli;
        LastSharp=Sharp;
        LastVolume=Volum;
        LastProfit=Profit;
        LastPF=ProfitFactor;*/
       // Zscore=0;
        
        } 
    
     }
 return(0);    
     }
 

Hello!

Maybe someone has already encountered this problem and knows the cause and solution?

The adviser works clearly on the tester, and when enabled on current quotes, the position opened by the criteria closes on the next LOSSING tick (Plus tick has no effect). The full impression is of an external interference. What may be the problem here? Thank you.

 
rapid_minus:

Hello!

Maybe someone has already encountered this problem and knows the cause and solution?

The adviser works clearly on the tester, and when enabled on current quotes, the position opened by the criteria closes on the next LOSSING tick (Plus tick has no effect). The full impression is of an external interference. What may be the problem here? Thank you.

Without a code, only psychics can help. There's a branch of them somewhere. We should ask a question there.
 
Well certainly if there is outside interference, only to psychics.
 
Vinin:
Without the code only psychics can help. There was a branch of them somewhere. You should ask a question there

A "joke of humour" is always a plus!

The code is too big to post here in its entirety. But it was written using Sleptsov's Expert Advisor as a template. I have only inserted my own indicators and conditions for trading criteria. I think the reason for it lies in some kind of preliminary code settings but they are absolutely identical to the original.

 

Hence a specific question from a beginner - What changes need to be introduced into the code for the EA to work not only in the tester, but also in real life?