[Qualsiasi domanda da principiante, per non ingombrare il forum. Professionisti, non passate oltre. Non potrei andare da nessuna parte senza di te - 2. - pagina 528

 
tol64:


Salva il valore del deposito iniziale in una variabile globale. Create un'altra variabile globale che eguagli il delta con il valore che avete definito (primo rettangolo). E poi secondo la formula.

Se il capitale == deposito iniziale + delta, allora azione certa.

Se il capitale == deposito iniziale + delta*2 (secondo rettangolo), allora azione specifica.

Grazie.
 
artmedia70:
Da qualche parte intorno al sì. Sembra che non ci siano fermate?

È un consigliere tipo kamikaze. Per i veri giocatori.))) O padella o propano.)))
 
tol64:

È un consigliere tipo kamikaze. Per i veri giocatori.))) O con l'amo o con l'inganno.)))
Il drawdown è del 90% - non un sopravvissuto inequivocabilmente...
 

Non sono un programmatore principiante da qualche anno, ho riscritto l'indicatore da un altro linguaggio e mi sono imbattuto in un ridisegno.

Sono un principiante, ho riscritto l'indicatore in un'altra lingua:

#property copyright "Copyright © 2011, Michael Dm Corp."
#property link      "mhs_86@mail.ru"

#property indicator_separate_window
#property indicator_buffers 8
#property indicator_color1 Green
#property indicator_color2 Green
#property indicator_color3 Green
#property indicator_color4 Green
#property indicator_color5 Red
#property indicator_color6 Red
#property indicator_color7 Red
#property indicator_color8 Red

//--- input parameters
extern int        z1=180;
extern int        z2=360;
extern int        z3=720;
extern int        n1=180;
extern int        n2=360;
extern int        n3=8;
extern int        n4=2;
extern int        a11=20;
extern int        a2=10;
extern int        a3=3;
extern int        pm=720;
extern int        t=2;

//--- buffers
double up1[];
double up2[];
double up3[];
double up4[];
double down1[];
double down2[];
double down3[];
double down4[];


//ЭМУЛЯЦИЯ ИНДИКАТОРНЫХ БУФЕРОВ
double NMACD[];
double x[],xx[],xind1[],q1[],q2[],RAZ[],y[],z[],yy[],yy1[];
double yrefa[],yrefa1[],az[],az1[];
double xh[],xl[],tsh[],tsl[];
double a[],b[],h2[],a1[],b1[],l2[],o2[],c2[];
double EMA1[], EMA2[], EMA3[], SMA1[];
double procK[], procD[];
int Reg_Buy[],Reg_Sell[];
int br[],sr[],br2[],sr2[];
int zzz[],rr[],rr1[];
int ai[], a_[], b_[];
int sign[], sign1[];

extern int maxBars=5000;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(0,up1);
   SetIndexLabel (0,"up1");
   SetIndexStyle(1,DRAW_HISTOGRAM,EMPTY,2);
   SetIndexBuffer(1,up2);
   SetIndexLabel (1,"up2");
   SetIndexStyle(2,DRAW_HISTOGRAM,EMPTY,4);
   SetIndexBuffer(2,up3);
   SetIndexLabel (2,"up3");
   SetIndexStyle(3,DRAW_HISTOGRAM,EMPTY,5);
   SetIndexBuffer(3,up4);
   SetIndexLabel (3,"up4");
   SetIndexStyle(4,DRAW_HISTOGRAM);
   SetIndexBuffer(4,down1);
   SetIndexLabel (4,"down1");
   SetIndexStyle(5,DRAW_HISTOGRAM,EMPTY,2);
   SetIndexBuffer(5,down2);
   SetIndexLabel (5,"down2");
   SetIndexStyle(6,DRAW_HISTOGRAM,EMPTY,4);
   SetIndexBuffer(6,down3);
   SetIndexLabel (6,"down3");
   SetIndexStyle(7,DRAW_HISTOGRAM,EMPTY,5);
   SetIndexBuffer(7,down4);
   SetIndexLabel (7,"down4");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
//----
int i;
if(n4>2 || n4<1)
   {
    Alert("n4 может быть равным 1 или 2\nтип средней (1-s/2-e)");
    return(0);
   }
if(t>2 || t<1)
   {
    Alert("t может быть равным 1 или 2\n(1-s/2-e)");
    return(0);
   }
//---- ЭМУЛЯЦИЯ ИНДИКАТОРНЫХ БУФЕРОВ
  int NewSize = iBars(Symbol(), 0);
  //----  Проверка на смену нулевого бара
  if(ArraySize(EMA1) < NewSize)
    {
      //---- Установить прямое направление индексирования в массиве 
      ArraySetAsSeries(EMA1, false);
      ArraySetAsSeries(EMA2, false);
      ArraySetAsSeries(EMA3, false);
      ArraySetAsSeries(SMA1, false);
      ArraySetAsSeries(NMACD, false);
      ArraySetAsSeries(procK, false);
      ArraySetAsSeries(procD, false);
      ArraySetAsSeries(Reg_Buy, false);
      ArraySetAsSeries(Reg_Sell, false);
      ArraySetAsSeries(x, false);
      ArraySetAsSeries(xx, false);
      ArraySetAsSeries(xind1, false);
      ArraySetAsSeries(q1, false);
      ArraySetAsSeries(q2, false);
      ArraySetAsSeries(RAZ, false);
      ArraySetAsSeries(y, false);
      ArraySetAsSeries(z, false);
      ArraySetAsSeries(yy, false);
      ArraySetAsSeries(yy1, false);
      ArraySetAsSeries(yrefa, false);
      ArraySetAsSeries(yrefa1, false);
      ArraySetAsSeries(az, false);
      ArraySetAsSeries(az1, false);
      ArraySetAsSeries(xh, false);
      ArraySetAsSeries(xl, false);
      ArraySetAsSeries(tsh, false);
      ArraySetAsSeries(tsl, false);
      ArraySetAsSeries(br, false);
      ArraySetAsSeries(sr, false);
      ArraySetAsSeries(br2, false);
      ArraySetAsSeries(sr2, false);
      ArraySetAsSeries(a, false);
      ArraySetAsSeries(b, false);
      ArraySetAsSeries(a_, false);
      ArraySetAsSeries(b_, false);
      ArraySetAsSeries(a1, false);
      ArraySetAsSeries(b1, false);
      ArraySetAsSeries(h2, false);
      ArraySetAsSeries(l2, false);
      ArraySetAsSeries(o2, false);
      ArraySetAsSeries(c2, false);
      ArraySetAsSeries(zzz, false);
      ArraySetAsSeries(rr, false);
      ArraySetAsSeries(rr1, false);
      ArraySetAsSeries(ai, false);
      ArraySetAsSeries(sign, false);
      ArraySetAsSeries(sign1, false);
      //---- Изменить размер эмулируемых индикаторных буферов 
      ArrayResize(EMA1, NewSize);  
      ArrayResize(EMA2, NewSize);   
      ArrayResize(EMA3, NewSize);  
      ArrayResize(SMA1, NewSize); 
      ArrayResize(NMACD, NewSize);   
      ArrayResize(procK, NewSize);
      ArrayResize(procD, NewSize); 
      ArrayResize(Reg_Buy, NewSize);
      ArrayResize(Reg_Sell, NewSize);
      ArrayResize(x, NewSize);
      ArrayResize(xx, NewSize);
      ArrayResize(xind1, NewSize);
      ArrayResize(q1, NewSize);
      ArrayResize(q2, NewSize);
      ArrayResize(RAZ, NewSize);
      ArrayResize(y, NewSize);
      ArrayResize(z, NewSize);
      ArrayResize(yy, NewSize);
      ArrayResize(yy1, NewSize);
      ArrayResize(yrefa, NewSize);
      ArrayResize(yrefa1, NewSize);
      ArrayResize(az, NewSize);
      ArrayResize(az1, NewSize);
      ArrayResize(xh, NewSize);
      ArrayResize(xl, NewSize);
      ArrayResize(tsh, NewSize);
      ArrayResize(tsl, NewSize);
      ArrayResize(br, NewSize);
      ArrayResize(sr, NewSize);
      ArrayResize(br2, NewSize);
      ArrayResize(sr2, NewSize);
      ArrayResize(a, NewSize);
      ArrayResize(b, NewSize);
      ArrayResize(a_, NewSize);
      ArrayResize(b_, NewSize);
      ArrayResize(a1, NewSize);
      ArrayResize(b1, NewSize);
      ArrayResize(h2, NewSize);
      ArrayResize(l2, NewSize);
      ArrayResize(o2, NewSize);
      ArrayResize(c2, NewSize);
      ArrayResize(zzz, NewSize);
      ArrayResize(rr, NewSize);
      ArrayResize(rr1, NewSize);
      ArrayResize(ai, NewSize);
      ArrayResize(sign, NewSize);
      ArrayResize(sign1, NewSize);
      //---- Установить обратное направление индексирования в массиве 
      ArraySetAsSeries(EMA1, true);
      ArraySetAsSeries(EMA2, true);
      ArraySetAsSeries(EMA3, true);
      ArraySetAsSeries(SMA1, true); 
      ArraySetAsSeries(NMACD, true);   
      ArraySetAsSeries(procK, true); 
      ArraySetAsSeries(procD, true); 
      ArraySetAsSeries(Reg_Buy, true); 
      ArraySetAsSeries(Reg_Sell, true);
      ArraySetAsSeries(x, true); 
      ArraySetAsSeries(xx, true);
      ArraySetAsSeries(xind1, true);
      ArraySetAsSeries(q1, true); 
      ArraySetAsSeries(q2, true);
      ArraySetAsSeries(RAZ, true);
      ArraySetAsSeries(y, true); 
      ArraySetAsSeries(z, true);
      ArraySetAsSeries(yy, true);
      ArraySetAsSeries(yy1, true);
      ArraySetAsSeries(yrefa, true);
      ArraySetAsSeries(yrefa1, true);
      ArraySetAsSeries(az, true);
      ArraySetAsSeries(az1, true);
      ArraySetAsSeries(xh, true);
      ArraySetAsSeries(xl, true);
      ArraySetAsSeries(tsh, true);
      ArraySetAsSeries(tsl, true);
      ArraySetAsSeries(br, true);
      ArraySetAsSeries(sr, true);
      ArraySetAsSeries(br2, true);
      ArraySetAsSeries(sr2, true);
      ArraySetAsSeries(a, true);
      ArraySetAsSeries(b, true);
      ArraySetAsSeries(a_, true);
      ArraySetAsSeries(b_, true);
      ArraySetAsSeries(a1, true);
      ArraySetAsSeries(b1, true);
      ArraySetAsSeries(h2, true);
      ArraySetAsSeries(l2, true);
      ArraySetAsSeries(o2, true);
      ArraySetAsSeries(c2, true);
      ArraySetAsSeries(zzz, true);
      ArraySetAsSeries(rr, true);
      ArraySetAsSeries(rr1, true);
      ArraySetAsSeries(ai, true);
      ArraySetAsSeries(sign, true);
      ArraySetAsSeries(sign1, true);
    } 
 

la continuazione del codice:

int limit;
int counted_bars = IndicatorCounted();
//---- последний посчитанный бар будет пересчитан
if(counted_bars > 0) 
counted_bars--;
limit = Bars - counted_bars - 1;
if (limit > maxBars) limit=maxBars;
//---- основной цикл
for( i = limit; i >= 0; i--)
{                                                        
//TREND_ASI
//------------------- 
EMA1[i]=iMA(Symbol(),0,z1,0,1,0,i);
EMA2[i]=iMA(Symbol(),0,z2,0,1,0,i);
EMA3[i]=iMA(Symbol(),0,z3,0,1,0,i);
SMA1[i]=iMA(Symbol(),0,1,0,0,0,i);   
//-------------------    
//MACDSCALP_ASI
//-------------------
if (n4==1)
   {
    NMACD[i]=iMA(Symbol(),0,n1,0,0,4,i)-iMA(Symbol(),0,n2,0,0,4,i); 
   }
if (n4==2)
   {
    NMACD[i]=iMACD(Symbol(),0,n1,n2,n3,4,0,i);
   }
//-------------------
//STOCH_ASI
//------------------- 
procK[i]=iStochastic(Symbol(), 0,a11,a3,a2,1,0,0,i);
procD[i]=iStochastic(Symbol(), 0,a11,a3,a2,1,0,1,i);
//-------------------
if (SMA1[i]>EMA1[i] && EMA3[i]<EMA2[i] && EMA2[i]<EMA1[i] && NMACD[i]>0 && procK[i]<49) {Reg_Buy[i] = 1;}      
if (SMA1[i]<EMA1[i] && EMA1[i]<EMA2[i] && EMA2[i]<EMA3[i] && NMACD[i]<0 && procK[i]>51) {Reg_Sell[i] = -1;}
//-------------------
//SETUP_ASI
//------------------- 
xx[i]=Close[i];
if (t==1)
   {
    x[i]=iMA(Symbol(),0,pm,0,0,0,i);
   }else
      {
       x[i]=iMA(Symbol(),0,pm,0,1,0,i);
      }
xind1[i]=(xx[i]-x[i])/xx[i]*100; 
q1[i]=xind1[i+1];
q2[i]=(xind1[i]+q1[i])/2;
RAZ[i]=q2[i];  
y[i]=RAZ[i+1];
z[i]=RAZ[i];
if(RAZ[i]>y[i])
   {
    yy[i]=1;
   }
if(RAZ[i]<y[i])
   {
    yy1[i]=-1;
   }
yrefa[i]=yy[i+1];
yrefa1[i]=yy1[i+1];
if(yrefa1[i]<0 && yy[i]>0)
   {
    az[i]=yy[i];
   }
if(yrefa[i]>0 && yy1[i]<0)
   {
    az1[i]=yy1[i];
   }
if(Close[i]>Open[i])
   {
    xh[i]=High[i]-Close[i];
   }else 
      {
       xh[i]=High[i]-Open[i];
      }
if(Close[i]>Open[i])
   {
    xl[i]=Open[i]-Low[i];
   }else 
      {
       xl[i]=Close[i]-Low[i];
      }
}
for( i = limit; i >= 0; i--)
{
tsh[i]=iMAOnArray(xh,0,6,0,0,i);
tsl[i]=iMAOnArray(xl,0,6,0,0,i);
}
 

l'ultima parte del codice:

for( i = limit; i >= 0; i--)
{
if ((xl[i]>2*tsl[i] && xh[i]<1.5*tsh[i]) || (Close[i]-Open[i])>2*tsh[i] || (xl[i]>2*xh[i] && xl[i]>tsl[i]))
   {
    br[i]=3;
   }else
      {
       br[i]=0;
      }
if((Open[i]-Close[i])>2*tsl[i])
   {
    br[i]=0;
   }
if((xh[i]>2*tsh[i] && xl[i]<1.5*tsl[i]) || (Open[i]-Close[i])>2*tsl[i] || (xh[i]>2*xl[i] && xh[i]>tsh[i]))
   {
    sr[i]=-3;
   }else
      {
       sr[i]=0;
      }
if(MathAbs(xh[i]-xl[i])<((tsh[i]+tsl[i])/2) && MathAbs(Open[i]-Close[i])<((tsh[i]+tsl[i])/2))
   {
    br[i]=0;
    sr[i]=0;
   }
if((Close[i]-Open[i])>2*tsh[i])
   {
    sr[i]=0;
   }
a[i]=High[i];
b[i]=High[i+1];
if(a[i]>b[i])
   {
    h2[i]=a[i];
   }else
      {
       h2[i]=b[i];
      }
a1[i]=Low[i];
b1[i]=Low[i+1];
if(a1[i]<b1[i])
   {
    l2[i]=a1[i];
   }else
      {
       l2[i]=b1[i];
      }
o2[i]=Open[i+1];
c2[i]=Close[i];
if(c2[i]>h2[i]-(h2[i]-l2[i])/3)
   {
    br2[i]=1;
   }else
      {
       br2[i]=0;
      }
if(c2[i]<l2[i]+(h2[i]-l2[i])/3)
   {
    sr2[i]=-1;
   }else
      {
       sr[i]=0;
      }
zzz[i]=sr2[i]+br2[i]+br[i]+sr[i];
if(zzz[i]>0)
   {
    rr[i]=zzz[i];
   }else
      { 
       rr[i]=0;
      }
if(zzz[i]<0)
   {
    rr1[i]=zzz[i];
   }else
      {
       rr1[i]=0;
      }
if(rr[i]>0)
   {
    a_[i]=1;
   }else
      {
       a_[i]=0;
      }
if(rr1[i]<0)
   {
    b_[i]=-1;
   }else
      {
       b_[i]=0;
      }
if (rr[i]==0 && rr1[i]==0)
   {
    ai[i]=1;
   }else 
      {
       ai[i]=0;
      }
if (az[i]==1 && a_[i]==1 && Reg_Buy[i]==1)
   {
    sign[i]=1;
   }
if (az1[i]==-1 && b_[i]==-1 && Reg_Sell[i]==-1)
   {
    sign1[i]=-1;
   }
if (az1[i]==-1 && ai[i]==1 && Reg_Sell[i]==-1)
   {
    sign1[i]=-1;
   }
if(az[i]==1 && ai[i]==1 && Reg_Buy[i]==1)
   {
    sign[i]=1;
   }
// анализ положения Stochastic для up
if (sign[i]==1 && procK[i]<50 && procK[i]>=35)
   {
    up1[i]=0;
   }
if (sign[i]==1 && procK[i]<35 && procK[i]>=20)
   {
    up2[i]=1;
   }
if (sign[i]==1 && procK[i]<20 && procK[i]>=10)
   {
    up3[i]=1;
   }
if (sign[i]==1 && procK[i]<10 && procK[i]>=0)
   {
   up4[i]=1;
   }
// анализ положения Stochastic для down
if (sign1[i]==-1 && procK[i]>50 && procK[i]<=65)
   {
    down1[i]=0;
   }
if (sign1[i]==-1 && procK[i]>65 && procK[i]<=80)
   {
    down2[i]=-1;
   }
if (sign1[i]==-1 && procK[i]>80 && procK[i]<=90)
   {
    down3[i]=-1;
   }
if (sign1[i]==-1 && procK[i]>90 && procK[i]<=100)
   {
    down4[i]=-1;
   }
//----
}                                        
   return(0);
  }
//+------------------------------------------------------------------+
 
Potete per favore consigliarmi come specificare correttamente in un ordine pendente in un EA di cancellarlo automaticamente alle 23:00?
 

Questa opzione dà un errore:

  datetime Tim=D'23:00';
   int    Cur_Hour=Hour();             // Серверное время в часах   
   double Cur_Min =Minute();           // Серверное время в минутах   
   double Cur_time= Cur_Hour + Cur_Min/100; // Текущее время   
   if (Cur_time>=20.00&&Cur_time<=20.00&&order==false)
  {

ticket=OrderSend(Symbol(),OP_BUYLIMIT,0.1,Bid-Spread,2,Bid-Spread-SL,Bid, Tim);
 
dmmikl86:

l'ultima parte del codice:


Perché così tanti array?
 
Puoi dirmi se c'è un auto-ottimizzatore che ottimizza i parametri durante il test? Devo controllare l'idea.