在过去36个高点中的最高点上画出H_线 - 页 2

 

我不关心STOCH收盘价,所以只关心当前的K%就够了。

检查 对象的代码。

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

在96根蜡烛之后删除ID线。

我现在要做的是,如果图表上已经有一条番茄线,就阻止EA绘制新的番茄线。

我正在考虑添加

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

......... = 停止,并从头开始(但仍然读取橄榄球条件)。

现在的代码。

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);
  }
//+------------------------------------------------------------------+
 

重新表述一下。

我想在图表中最多有一条番茄线。

如果该行将被用于发送订单,则删除该行。

如果它过期了(96),则删除该行。

橄榄也一样。

因此,如果图表上已经有了番茄线,就不会再有番茄线,直到图表上没有番茄为止。

希望重新措辞能帮助找到解决方案 :)

 
cichichan:

重新表述一下。

我想在图表中最多有一条番茄线。

如果该行将被用于发送订单,则删除该行。

如果它过期了(96),则删除该行。

橄榄也一样。

因此,如果图表上已经有了番茄线,就不会再有番茄线,直到图表上没有番茄为止。

希望重新措辞会有助于找到解决方案 :)


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 ")
      {
       //  line found
      }
}

那么你如何避免画其他的线....?

 

我想把对象的名称改回初始名称,以阻止脚本因同名限制而画线......但我没有改变名称的功能。

hmm.... 我不明白。

我的思想被卡住了!我感到很愚蠢,很沮丧。

 
cichichan:

我想把对象的名称改回初始名称,以阻止脚本因同名限制而画线......但我没有改变名称的功能。

hmm....,我不明白。

我的脑子被卡住了!我觉得自己很愚蠢,很沮丧。

你什么时候创建一个新的线条?

不是在你找到最高或最低的条形图的时候。

而且只有在没有线的情况下你才需要创建

所以如果你创建一个新的线,使用Time[0]的时间。

如果你找到了你的对象,那么它的名字是什么呢?

那么你需要做什么呢?当它有StringSubstr(id,0,7)=="tomato " 时得到这个名字。

 

请回到你的第一个帖子。

"当我运行这个程序时,我得到了番茄和橄榄的第一个设置,然后即使在日志中我得到 "番茄开 "不同的价格水平,我也没有在图表上得到新的番茄线。

你没有得到一个新的线,因为旧的线已经存在。删除它,新的线就会被画出来。

 

目前,我是这样做的。

它看起来就像它应该做的那样,只有一行,在删除96个柱子后,当条件重新出现时就会重绘。

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

这是否可行?

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

字符串之间是否可以<或>,这是个问题,我不知道。

你把事情搞复杂了,因为Giol告诉你,如果你想要几条线,你必须给这些线起不同的名字。他在那个时候是对的。

如果他知道你只想要一条线,他就不会这么说了。devries给出的解决方案是非常好的,如果一个人有几行的话,谢谢devries。

但是如果你只想要一条线,叫它 "番茄 "或 "橄榄",那么ObjectFind("番茄")ObjectDelete("番茄"),是否可以解决在画线的时候用Time[96]和Time[0]分开的问题。

接下来会发生的问题是,条件stoch>75可能持续20个Bars或50个Bars,那么,当你删除你的线时,画线的条件仍然有效,一旦线被删除,或有订单,新的线将被画出来。

 

由于对象的事情对我两周的代码阅读来说似乎太复杂了,我决定为卖出和买入设置水平价格。在这个过程中我遇到了一个问题。

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

if (Close[2]>LSell && Close[1]>LSell && LevelSset==true)不起作用。

如果我删除if (Close[2]>LSell && Close[1]>LSell)并保留(LevelSset==true),或者如果我改变(Close[2]<LSell && Close[1]<1),该函数 似乎可以正常工作。

谢谢你

 

一些想法,什么是错的...任何人?

谢谢你