[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 387

 
biragr:

Thank you for your attention, but I do not understand your question. You can set the line for any date, and when the chart reaches it, the EA will trigger? Or maybe I do not understand something, if you don't mind explaining it.
Okay, you have set the line on the daily chart. What if it's on the watch? Will the time of order opening be set by the line or strictly set? Do you need to set the schedule for a month with lines or is an Expert Advisor following my link enough?
 
kolyango:

Help, please! The https://www.mql5.com/ru/code/10067 indicator needs to be converted into a simple working EA (as an example). Prinzip of action:

On the pair on which the EA will be thrown, as soon as the value is equal to 0.9570, open a market order to sell 0.1 lot with a majic number (so that EAs in different windows do not confuse orders), Stop-Loss 100p, Take-Profit 200p.

Professionals, we cannot do without you!



Help a beginner!
 

kolyango:

On the pair on which the EA will be thrown, as soon as the value equals 0.9570, open a market order to sell 0.1 lot with a majic number (so that EAs in different windows do not confuse orders), Stop-Loss 100p, Take-Profit 200p.

Help for a beginner!
What is the point of writing a one-time EA? Put a pending order and it will work the way you want. And set up EAs on the majors, because the pause will have zero majors.
 
Reshetov:
What is the point of writing a one-off EA? Put a pause and it will trigger itself the way you want it to. And configure the EAs for the majors, because the pause will have zero majors.

I need to figure out how to make this out of an indicator...
 

what is the problem? The problem is that the order does not always open when the line is crossed, i.e. sometimes it does and sometimes it does not... Although it works on the same principle...

//+------------------------------------------------------------------+
//|                                                      Вайкофф.mq4 |
//|                                                   Sergey Kodolov |
//|                                              84232676421@mail.ru |
//+------------------------------------------------------------------+
#property copyright "Sergey Kodolov"
#property link      "84232676421@mail.ru"



int total,sum,sumr;  
datetime TimeBarH, TimeBarL;

int Crossed (double nach, double kon, double cenaniz, double cenaverh)
{
   static int last_dir = 0;
   static int cur_dir = 0;
   
   if(nach<cenaverh && kon>cenaverh)cur_dir=1;
   if(nach>cenaniz && kon<cenaniz)cur_dir=2;
   
   if(cur_dir != last_dir)
   {
      last_dir=cur_dir;
      return(last_dir);
   }
   else
      return(0);
}


  
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }

  
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
                     
bool NewBar = New(); //работаем только с нового бара

int volot = volotilnost(NewBar); //определяем волотильность
Hfr(NewBar,volot); //определяем фрактал верхний
Lfr(NewBar,volot); //определяем фрактал нижний

      double BuyLine, SellLine;
   
      BuyLine = ObjectGet("upline",OBJPROP_PRICE1);
      SellLine = ObjectGet("downline",OBJPROP_PRICE1);

int isCrossed = Crossed(Open[0],Bid,SellLine,BuyLine); //говорит о пересечении баром линии
OrderOpenFunction(isCrossed);



//----
   return(0);
  }
//+------------------------------------------------------------------+


bool New()
{
   static datetime lastbar = 0;
   datetime curbar = Time[0];
   //Print("lastbar = ",lastbar," curbar = ",curbar);
   if(lastbar!=curbar)
   {
      lastbar = curbar;
      //Print("ypa");
      return(true);
   }
   else
      return(false);
}

int volotilnost (bool NewBar)
{
   if(NewBar == true)
   {
      for(int i=0;i<=kolbar;i++)
      {
         sum = sum + MathAbs(High[i]-Low[i])*1000;
         //Print(sum);
      }
      sumr = sum/kolbar;
      Print(sumr);
      return(sumr);
   }   
}

void Hfr(bool NewBar, int volot)
{
   if(NewBar == true)
   {
      if(volot > kolbarv)
      {
         if(iHigh(Symbol(),TF,5)<iHigh(Symbol(),TF,4))
         {
            if(iHigh(Symbol(),TF,4)<iHigh(Symbol(),TF,3))
            {
               if(iHigh(Symbol(),TF,2)<iHigh(Symbol(),TF,3))
               {
                  if(iHigh(Symbol(),TF,1)<iHigh(Symbol(),TF,2))
                  {
                     ObjectDelete("upline");
                     ObjectCreate("upline",OBJ_HLINE,0,0,(iHigh(Symbol(),TF,3)));
                     TimeBarH = iTime(Symbol(),TF,3);
                  }
               }
            }
         }
      }   
   }   
}
         

void Lfr(bool NewBar, int volot)
{
   if(NewBar == true)
   {
      if(volot > kolbarv)
      {
         if(iLow(Symbol(),TF,5)>iLow(Symbol(),TF,4))
         {
            if(iLow(Symbol(),TF,4)>iLow(Symbol(),TF,3))
            {
               if(iLow(Symbol(),TF,2)>iLow(Symbol(),TF,3))
               {
                  if(iLow(Symbol(),TF,1)>iLow(Symbol(),TF,2))
                  {
                     ObjectDelete("downline");
                     ObjectCreate("downline",OBJ_HLINE,0,0,(iLow(Symbol(),TF,3)));
                     TimeBarL = iTime(Symbol(),TF,3);
                  }
               }
            }
         }
      }   
   }   
}

void OrderOpenFunction(int isCrossed)
{
   total = OrdersTotal();
   if(total<1)
   {
      if(isCrossed == 1)
      {
         OrderSend(Symbol(),OP_BUY,lots,Ask,slip,Bid-TS*Point,Bid+TP*Point,"Покупка",Magic,0,Green);
      }
      if(isCrossed == 2)
      {
         OrderSend(Symbol(),OP_SELL,lots,Bid,slip,Ask+TS*Point,Ask-TP*Point,"Продажа",Magic,0,Red);
      }
   }   
}
I think the error is in isCrossed, but i cannot find it there... I deleted some part of the code (where I save some data into arrays), because it overloads the code, but if i need it, i will also be glad to share it with you
 
Good evening! I put a pending bylimit order, no stop, error 130 !!!! What can it be? Or am I messing up again? Please, advise me!
 

Hello.

Can you tell me how to describe the crossing of the main line and the signal line of the stochastic?

 

Something like this, in my mind

F=iStochastic( Symbol(), 0, 5, 3, 3, MODE_SMA, 1,MODE_MAIN , 0) ;
   SIGNAL=iStochastic( Symbol(), 0, 5, 3, 3, MODE_SMA, 1,MODE_SIGNAL , 0) ;
   if (F==SIGNAL) {Урра!!!!; }
 

one more question, why program says that object exists, when in fact it doesn't (I just look at monitor and don't see object clearly)

void DrawLines()
{
   ObjectCreate("line1",OBJ_TREND,0,ArrayH[1],iHigh(Symbol(),TF,iBarShift(Symbol(),TF,ArrayH[1])),ArrayH[2],iHigh(Symbol(),TF,iBarShift(Symbol(),TF,ArrayH[2])));
   Print(GetLastError());
}

iBarShift(Symbol(),TF,ArrayH[1]) - gives the bar number, I checked it all through Print(). But GetLastError gives me error 4200 - I don't understand what's what =)

 
kolyango:

I need to figure out how to make this from an indicator...

You can't do it from an indicator