简体   繁体   English

专家每天自动下订单

[英]placing an Order everyday automatically by an expert

i write an expert in mql4.and i want to place an order(BuyStop Order) everyday at exactly everyday opening.我写了一个 mql4 的专家。我想每天在每天开盘时下订单(BuyStop Order)。 i write the following codes but the expert does not work.please help me我写了以下代码,但专家不工作。请帮助我

// y means yesterday
double yHigh=iHigh(Symbol(),PERIOD_D1,1);
double yLow=iLow(Symbol(),PERIOD_D1,1);
double yOpen=iOpen(Symbol(),PERIOD_D1,1);
double yClose=iClose(Symbol(),PERIOD_D1,1);
double yRange=yHigh-yLow;
double P=NormalizeDouble(((yHigh+yLow+yClose)/3),5);

double R3=NormalizeDouble((P+yRange*1.000),5) ;
double R2=NormalizeDouble((P+yRange*0.618),5) ;
double R1=NormalizeDouble((P+yRange*0.382),5) ;

double S1=NormalizeDouble((P-yRange*0.382),5) ;
double S2=NormalizeDouble((P-yRange*0.618),5) ;
double S3=NormalizeDouble((P-yRange*1.000),5) ;

void OnTick()
  {
   if (iVolume(Symbol(),PERIOD_D1,0)<=1)
   int buyTicket=OrderSend(Symbol(),OP_BUYSTOP,0.01,P,3,S1,R1,"MyBuyPosition",7777,0,clrGreen);
  {

// P and R1 and S1 are pivot points and calculated at the top

this expert calculates daily Pivot points and place a buystop order at exactly starting the new day.(exactly at starting daily candle)这位专家每天计算 Pivot 点,并在新的一天恰好开始时下止损订单。(恰好在每日蜡烛开始时)

why this Expert does not work?为什么这个 Expert 不起作用? :( :(

i tried more and more.but it does not work.i think there is a problem with line below:我尝试了越来越多。但它不起作用。我认为下面一行有问题:

if (iVolume(Symbol(),PERIOD_D1,0)<=1)

is there the other way to show starting new day instead of this code line??有没有其他方式来显示开始新的一天而不是这个代码行?

Using iVolume to determine a new day would be very unreliable.使用iVolume来确定新的一天是非常不可靠的。 Instead simply use iTime .而是简单地使用iTime Try the following:尝试以下操作:

datetime currentDay;

void OnTick()
{
   if(currentDay!=iTime(NULL, PERIOD_D1,0))
   {
      int buyTicket=OrderSend(Symbol(),OP_BUYSTOP,0.01,P,3,S1,R1,"MyBuyPosition",7777,0,clrGreen);
      currentDay=iTime(NULL, PERIOD_D1, 0);
   }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM