Help Su Trand Magic

Sezione dedicata a metatrader (ed altre piattaforme) ed al suo linguaggio di programmazione per il trading automatico
Rispondi
texcs
Messaggi: 144
Iscritto il: 29/05/2014, 23:08

Help Su Trand Magic

Messaggio da texcs »

Codice: Seleziona tutto

HP Code:
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_color3 Black
#property indicator_color4 Black

extern int CCPeriod = 50;
extern int ATRPeriod = 5;

double g_ibuf_76[];
double g_ibuf_80[];
int gi_84 = 0;

int init() {
  { SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 4);
   SetIndexBuffer(0, g_ibuf_76);
   SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 4);
   SetIndexBuffer(1, g_ibuf_80);}
   return (0);
}

int deinit() {
   return (0);
}


void AllertBuy()
{
 ObjectCreate(ChartID(),IntegerToString(Time[0],0,0),OBJ_VLINE,0,Time[0],0);
 ObjectSetInteger(ChartID(),IntegerToString(Time[0],0,0),OBJPROP_COLOR,clrDarkGreen);
// Alert("Teo_CI rialzista su "+Symbol()+" a TF "+IntegerToString(Period(),0,0));
}

void AllertSell()
{
 ObjectCreate(ChartID(),IntegerToString(Time[0],0,0),OBJ_VLINE,0,Time[0],0);
 ObjectSetInteger(ChartID(),IntegerToString(Time[0],0,0),OBJPROP_COLOR,clrDarkRed);
 //Alert("Teo_CI ribassista su "+Symbol()+" a TF "+IntegerToString(Period(),0,0));
}
int BuySell=0;
int start() {
   int li_8;
   double ld_12;
   double ld_20;
   double l_icci_28;
   double l_icci_36;
   int li_52 = IndicatorCounted();
   if (li_52 < 0) return (-1);
   if (li_52 > 0) li_52--;
   int li_0 = Bars - li_52;
   for (int li_4 = li_0; li_4 >= 0; li_4--) {
      l_icci_28 = iCCI(NULL, 0, CCPeriod, PRICE_TYPICAL, li_4);
      l_icci_36 = iCCI(NULL, 0, CCPeriod, PRICE_TYPICAL, li_4 + 1);
      li_8 = li_4;
      ld_12 = 0;
      ld_20 = 0;
      for (li_8 = li_4; li_8 >= li_4 - 9; li_8--) ld_20 += MathAbs(High[li_8] - Low[li_8]);
      ld_12 = ld_20 / 10.0;
      if (l_icci_28 >= gi_84 && l_icci_36 < gi_84) g_ibuf_76[li_4 + 1] = g_ibuf_80[li_4 + 1];
      if (l_icci_28 <= gi_84 && l_icci_36 > gi_84) g_ibuf_80[li_4 + 1] = g_ibuf_76[li_4 + 1];
      if (l_icci_28 >= gi_84) 
      {
         g_ibuf_76[li_4] = Low[li_4] - iATR(NULL, 0, ATRPeriod, li_4);
         if (g_ibuf_76[li_4] < g_ibuf_76[li_4 + 1]) g_ibuf_76[li_4] = g_ibuf_76[li_4 + 1];
         BuySell = +1;
      }
      else 
      {
         if (l_icci_28 <= gi_84) 
         {
            g_ibuf_80[li_4] = High[li_4] + iATR(NULL, 0, ATRPeriod, li_4);
            if (g_ibuf_80[li_4] > g_ibuf_80[li_4 + 1]) g_ibuf_80[li_4] = g_ibuf_80[li_4 + 1];
            BuySell = -1;
         }
      }
   alert(BuySell);
   }
   return (0);
}

void alert(int BuySellInt)
{
   if (BuySellInt != +1)
   {
      Comment ("Buy");
      AllertBuy();
     BuySell = +1;
   }
   if (BuySellInt != -1)
   {
      Comment ("Sell");
      AllertSell();
      BuySell = -1; 
   } 
praticamente io vorrei che mi da l'allert buy o sell solo al cambio di colore non a ogni candela, per fare questo ho inserito la variabile buysell per fare da filtro ma nonostante ciò non funziona, mi sapete aiutare?
Rispondi

Chi c’è in linea

Visitano il forum: Nessuno e 3 ospiti