dibujando la línea H en el máximo de los últimos 36 máximos - página 2

 

No me importa el cierre de stoch, así que sólo el K% actual es suficiente.

codigo para comprobar los objetos:

 int i, ot=ObjectsTotal()-1;
string id=ObjectName (i);

for (i=ot;i>=0;i--)
{
   if (StringSubstr(id,0,7)=="tomato ")
      {
      if (StringSubstr(id,7,16)<TimeToStr(Time[96],TIME_DATE|TIME_MINUTES))
         {
         ObjectDelete(id);
         }
      if (StringSubstr(id,7,16)>TimeToStr(Time[96],TIME_DATE|TIME_MINUTES))
      }
   if (StringSubstr(id,0,6)=="olive ")
      {
      if (StringSubstr(id,6,16)<TimeToStr(Time[96],TIME_DATE|TIME_MINUTES))
         {
         ObjectDelete(id);
         }
      }  
}

esto borra la linea id despues de 96 velas. como necesito

lo que tengo que hacer ahora es evitar que ea dibuje nuevas líneas de tomate si una línea de tomate ya está en el gráfico.

estoy pensando en añadir

if (StringSubstr(id,7,16)>TimeToStr(Time[96],TIME_DATE|TIME_MINUTES))
         {
         ..............
         }

......... = stop y desde el principio (pero sigue leyendo las condiciones de oliva)

el código ahora:

int start()
  {
/////////// K% over >75 or under <25 (no waiting for close)
double stoch;
stoch=iStochastic(NULL,0,Kperiod,Dperiod,Stochshift,MODE_SMA,1,MODE_MAIN,0);

double high_price,low_price;
int high_nr,low_nr;
high_nr=iHighest(NULL,0,MODE_HIGH,34,2);  
high_price=High[high_nr];
low_nr=iLowest(NULL,0,MODE_LOW,34,2);
low_price=Low[low_nr];
datetime H=Time[high_nr];
string Hdate = TimeToStr(H,TIME_DATE|TIME_MINUTES);
datetime L=Time[low_nr];
string Ldate = TimeToStr(L,TIME_DATE|TIME_MINUTES);


/////////////////////////////////////////////////////////////////////////////////
//---
 int i, ot=ObjectsTotal()-1;
string id=ObjectName (i);

for (i=ot;i>=0;i--)
{
   if (StringSubstr(id,0,7)=="tomato ")
      {
      if (StringSubstr(id,7,16)<TimeToStr(Time[96],TIME_DATE|TIME_MINUTES))
         {
         ObjectDelete(id);
         }
      if (StringSubstr(id,7,16)>TimeToStr(Time[96],TIME_DATE|TIME_MINUTES))
      }
   if (StringSubstr(id,0,6)=="olive ")
      {
      if (StringSubstr(id,6,16)<TimeToStr(Time[96],TIME_DATE|TIME_MINUTES))
         {
         ObjectDelete(id);
         }
      }  
}
//---


////////////////////////////////////////////////////////////////////////////////

if(Bid<high_price && High[0]<high_price && High[1]<high_price && stoch>75)
     {
      ObjectCreate("tomato "+Hdate,OBJ_TREND,0,H,high_price,Time[0],high_price);
      ObjectSet("tomato "+Hdate,OBJPROP_COLOR,Tomato);
      //Print ("tomato ON"+high_price);
     }
       

///////////////////////////////////////////////////////////////////////////////

if(Bid>low_price && Low[0]>low_price && Low[1]>low_price && stoch<25)
   {
   ObjectCreate("olive "+Ldate,OBJ_TREND,0,L,low_price,Time[0],low_price);
   ObjectSet("olive "+Ldate,OBJPROP_COLOR,Olive);
   //Print ("olive ON"+low_price);
   }
 
   
   
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
 

para decirlo de otra manera:

Quiero que en el gráfico haya como máximo una línea de tomate.

si esa línea se utilizará para OrderSend, eliminar la línea.

si expira (96), eliminar la línea.

lo mismo para olive.

así que si la línea de tomate ya está en el gráfico, no hay más líneas de tomate hasta que no haya ningún tomate en el gráfico

espero que la reformulación ayude a encontrar la solución :)

 
cichichan:

para decirlo de otra manera:

Quiero que en el gráfico haya como máximo una línea de tomate.

si esa línea se utilizará para OrderSend, eliminar la línea.

si expira (96), eliminar la línea.

lo mismo para olive.

así que si la línea de tomate ya está en el gráfico, no hay más líneas de tomate hasta que no haya ningún tomate en el gráfico

espero que la reformulación ayude a encontrar la solución :)


datetime L=Time[low_nr];
string Ldate = TimeToStr(L,TIME_DATE|TIME_MINUTES);

¿es ese el momento en el que se crea la línea? ¿cómo hacer eso?

 int i, ot=ObjectsTotal()-1;
string id=ObjectName (i);

for (i=ot;i>=0;i--)
{
   if (StringSubstr(id,0,7)=="tomato ")
      {
       //  line found
      }
}

Entonces, ¿cómo se puede evitar dibujar otras líneas....?

 

estaba pensando en volver a cambiar el nombre del objeto como inicial para que el script deje de dibujar líneas debido a la limitación del mismo nombre... pero no tengo ninguna función para cambiar el nombre.

hmm.... no lo entiendo.

mi mente está atascada, me siento estúpido y frustrado.

 
cichichan:

estaba pensando en volver a cambiar el nombre del objeto como inicial para que el script deje de dibujar líneas debido a la limitación del mismo nombre... pero no tengo ninguna función para cambiar el nombre.

hmm.... no lo entiendo.

mi mente está atascada, me siento estúpido y frustrado

¿cuándo se crea una nueva línea?

no en el momento de la barra que se encuentra más alta o más baja

y tienes que crear solo si no hay linea

entonces si creas una nueva línea usa el tiempo de Time[0]

si encuentras tu objeto entonces que nombre tiene ?? ==> string id=ObjectName (i);

Entonces, ¿qué tienes que hacer? obtener este nombre cuando su han StringSubstr(id,0,7)=="tomate "

 

Vuelve a tu primer post :

"Cuando ejecuto esto obtengo la primera configuración para el tomate y para la aceituna ok, entonces aunque en el diario obtengo "tomate ON" diferente lvl de precio, no obtengo nueva línea de tomate en el gráfico. lo mismo para la aceituna".

No obtienes una nueva línea porque la antigua ya existe. Bórrala y se dibujará una nueva.

 

de momento lo he hecho así :

y parece que funciona como debería, sólo una línea, y después de 96 barras de borrar, el redibujo cuando la condición de reaparecer.

int start()
  {
/////////// K% over >75 or under <25 (no waiting for close)
double stoch;
stoch=iStochastic(NULL,0,Kperiod,Dperiod,Stochshift,MODE_SMA,1,MODE_MAIN,0);

double high_price,low_price;
int high_nr,low_nr;
high_nr=iHighest(NULL,0,MODE_HIGH,34,2);  
high_price=High[high_nr];
low_nr=iLowest(NULL,0,MODE_LOW,34,2);
low_price=Low[low_nr];
datetime H=Time[high_nr];
string Hdate = TimeToStr(H,TIME_DATE|TIME_MINUTES);
datetime L=Time[low_nr];
string Ldate = TimeToStr(L,TIME_DATE|TIME_MINUTES);


/////////////////////////////////////////////////////////////////////////////////
//---
int i, ot=ObjectsTotal()-1;
string id=ObjectName (i);

for (i=ot;i>=0;i--)
{
   if (StringSubstr(id,0,7)=="tomato ")
      {
      if (StringSubstr(id,7,16)<TimeToStr(Time[96],TIME_DATE|TIME_MINUTES))
         {
         ObjectDelete(id);
         }
      if (StringSubstr(id,7,16)>TimeToStr(Time[96],TIME_DATE|TIME_MINUTES))
         {
         Print ("tomato valid");
         break;
         }
      }
}

 if (ot==-1)
      {
      if(Bid<high_price && High[0]<high_price && High[1]<high_price && stoch>75)
         {
         ObjectCreate("tomato "+Hdate,OBJ_TREND,0,H,high_price,Time[0],high_price);
         ObjectSet("tomato "+Hdate,OBJPROP_COLOR,Tomato);
         //Print ("tomato ON"+high_price);
         }
      }  
//---


////////////////////////////////////////////////////////////////////////////////
for (i=ot;i>=0;i--)
{
 if (StringSubstr(id,0,6)=="olive ")
      {
      if (StringSubstr(id,6,16)<TimeToStr(Time[96],TIME_DATE|TIME_MINUTES))
         {
         ObjectDelete(id);
         }
      if (StringSubstr(id,6,16)>TimeToStr(Time[96],TIME_DATE|TIME_MINUTES))
         {
         Print ("olive valid");
         break;
         }   
      }  
 }      

///////////////////////////////////////////////////////////////////////////////
if (ot==-1)
{
if(Bid>low_price && Low[0]>low_price && Low[1]>low_price && stoch<25)
   {
   ObjectCreate("olive "+Ldate,OBJ_TREND,0,L,low_price,Time[0],low_price);
   ObjectSet("olive "+Ldate,OBJPROP_COLOR,Olive);
   //Print ("olive ON"+low_price);
   }
}
   
   
//----
   
//----
   return(0);
  }
 

¿funciona esto?

if (StringSubstr(id,7,16)<TimeToStr(Time[96],TIME_DATE|TIME_MINUTES))

las cadenas pueden ser < o > entre ellas, esa es una pregunta, no lo sé.

Lo estás complicando, porque giol te dice que si quieres varias líneas, tienes que darle a las líneas diferente nombre. Y tenía razón en ese momento.

Si supiera que sólo quieres una línea, no habría dicho eso. La solución que ha dado devries es muy buena en caso de que uno tenga varias líneas, gracias devries

Pero si quieres una sola línea llámala "tomate" o "aceituna", entonces ObjectFind("tomate") ObjectDelete ("tomate"), resuelve los problemas de separación de tiempos con Time[96] y Time[0] almacenados cuando se dibuja la línea.

El siguiente problema es que la condición stoch> 75 puede durar 20 Bares o 50 Bares, entonces, cuando borres tu línea, la condición para dibujar la línea seguirá siendo válida y tan pronto como la línea se haya borrado, o se haya tomado una orden, se dibujará una nueva línea. suerte, no es tan difícil.

 

hola

como el tema de los objetos me pareció demasiado complicado para mis dos semanas de lectura de código, decidí establecer el precio de nivel para la venta y la compra. en este proceso me encuentro con un problema:

void LevelSset()
{

stoch=iStochastic(NULL,0,Kperiod,Dperiod,Stochshift,MODE_SMA,1,MODE_MAIN,0);


high_bar=iHighest(NULL,0,MODE_HIGH,34,2);
string H=TimeToStr(Time[high_bar],TIME_DATE|TIME_MINUTES);
LSell=High[iHighest(NULL,0,MODE_HIGH,34,2)];


if(Bid<LSell && High[0]<LSell && High[1]<LSell && stoch>75 && LevelSset==false)
         {
         ObjectCreate("tomato "+H,OBJ_ARROW,0,Time[high_bar],LSell+Point*20);
         ObjectSet("tomato "+H,OBJPROP_ARROWCODE,242);
         ObjectSet("tomato "+H,OBJPROP_COLOR,Tomato);
         LevelSset=true;
         Print("LevelSset on "+LSell);
         }
if (Close[2]>LSell && Close[1]>LSell && LevelSset==true)
   {
      LSell=0;
      LevelSset=false;
      Print ("LSell"+LSell+"expired due to close");
   }
}

el "if (Close[2]>LSell && Close[1]>LSell && LevelSset==true) no funciona.

si quito el if (Close[2]>LSell && Close[1]>LSell) y dejo (LevelSset==true), o si cambio (Close[2]<LSell && Close[1]<1) la función parece funcionar correctamente.

gracias

 

algunas ideas, lo que está mal ... ¿alguien?

gracias