Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1828

 
SanAlex #:

just enter your Indicator correctly


Thank you very much! I will look into it)
 
soleg #:

Greetings Professionals and Beginners, need help.

How to insert an alert in this indicator that would signal when a given upper and lower level is crossed/touched?

Tried it myself, but it doesn't work((

So, give me an example, how did you try it and where did you put the alert. It will be interesting for all to see and maybe give you the right solution.

 
Mihail Matkovskij #:

So give me an example of how you tried it and where you entered the alert. It would be interesting for everyone to see and maybe give you the right solution.

Yes, I deleted everything at once.

 
SanAlex #:

just enter your Indicator correctly


didn't work, 8 errors in debugging)

I guess it's not my thing((.

 
soleg #:

didn't work, 8 errors in debugging)

probably not my thing((.

Thanks! I think I've got it sorted out, the alert when the zero level is crossed and the arrows in the direction of the crossing. but how do I make it signal at other levels?
 
soleg #:
Thanks! I think I got it, the alert when the zero level is crossed and the arrows point in the direction of crossing.

in your code - here is where to pick up the numbers

         if(Vertex_Buffer[i] > 9.9999)
            UpHisto_Buffer[i] = Vertex_Buffer[i];
         else
            UpHisto_Buffer[i] = EMPTY_VALUE;
         if(Vertex_Buffer[i] < -9.9999)
            DnHisto_Buffer[i] = Vertex_Buffer[i];
         else
            DnHisto_Buffer[i] = EMPTY_VALUE;

in the signal indicator - which has an alert . here to have more signals - remove a couple of lines

      if(CUSTOM[bar]<CUSTOMS[bar])
        {
         //if(OldTrend<0)   
            BuyBuffer[bar]=low[bar];
         //if(bar!=0)   
           // OldTrend=+1;   
        }
      if(CUSTOM[bar]>CUSTOMS[bar])
        {
         //if(OldTrend>0)   
            SellBuffer[bar]=high[bar];
         //if(bar!=0)   
            //OldTrend=-1;   
        }
     }
//---

EURUSDM1

 
SanAlex #:

in your code - here is where to pick up the numbers

in the signal indicator - which has an alert . here to have more signals - remove a couple of lines


Thank you!
 

hello!

Decided to make owls a bit more complicated.

I want to do something like trailing, but with a single / double action

idea:

price passed 75% to take - stop decreased (for example) by 20 pips and take increased by 20 pips.

price passed 90% to take - stop decreased (for example) by 30p and take increased by 10p.

I see the scheme like this (.....function...)=> (TP - Mparametr)

where: TP - TakeProfit

Mparametr- set in external EA variables (e.g. number of points)

What functions should be used to solve this problem?

I've read about predefined variables bid,ask - should we use them as a base?

or should we use MarketInfo or SymbolInfoTick?

I have a similar solution, but its shift of stop and take depends on lots:

  if((iOTy == OP_BUY)&& (LOT()>LotControl))
             {
              dSL = NormalizeDouble(dOOP - StopLoss * Point+DownLoss * Point, Digits);
              dTP = NormalizeDouble(dOOP + TakeProfit * Point+DownProfit * Point, Digits);

              bool bOM = OrderModify(iOTi, dOOP, dSL, dTP, 0, clrNONE);
             }

I want to do something similar. relatively simple.


MarketInfo - Получение рыночной информации - Справочник MQL4
MarketInfo - Получение рыночной информации - Справочник MQL4
  • docs.mql4.com
MarketInfo - Получение рыночной информации - Справочник MQL4
 
Tretyakov Rostyslav #:

Or like this

I've been writing this board for almost a week and here's the problem: if I also set the pending leveller to close on the button by analogy with the approach, which was a point below when the price was reached, then for some reason it closes automatically without asking, without pressing the button, which should do it a point above (after pressing and after reaching a level as in theory you should)


//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
  

  
  
  
//--- 
     ObjectCreate(0,"Button_1",OBJ_BUTTON,0,0,0);
   ObjectSetInteger(0,"Button_1",OBJPROP_XDISTANCE,20);
   ObjectSetInteger(0,"Button_1",OBJPROP_YDISTANCE,120);
   ObjectSetInteger(0,"Button_1",OBJPROP_XSIZE,100);
   ObjectSetInteger(0,"Button_1",OBJPROP_YSIZE,20);
   ObjectCreate(0,"Label_1",OBJ_LABEL,0,0,0);
   ObjectSetInteger(0,"Label_1",OBJPROP_XDISTANCE,20);
   ObjectSetInteger(0,"Label_1",OBJPROP_YDISTANCE,40);
   ObjectSetInteger(0,"Label_1",OBJPROP_CORNER,CORNER_LEFT_UPPER);
   ObjectSetString(0,"Label_1",OBJPROP_TEXT,"Price");
   ObjectSetInteger(0,"Label_1",OBJPROP_COLOR,clrBlack);
   
   
   //--- CLOSE BUY +1
   ObjectCreate(0,"Button_21",OBJ_BUTTON,0,0,0);
   ObjectSetInteger(0,"Button_21",OBJPROP_XDISTANCE,240);
   ObjectSetInteger(0,"Button_21",OBJPROP_YDISTANCE,120);
   ObjectSetInteger(0,"Button_21",OBJPROP_XSIZE,100);
   ObjectSetInteger(0,"Button_21",OBJPROP_YSIZE,20);
   ObjectSetString(0,"Button_21",OBJPROP_TEXT,"CLOSE BUY +1");
   ObjectSetInteger(0,"Button_21",OBJPROP_BGCOLOR,Beige);
   ObjectSetInteger(0,"Button_21",OBJPROP_COLOR,Green);
   ObjectCreate(0,"Label_21",OBJ_LABEL,0,0,0);
   ObjectSetInteger(0,"Label_21",OBJPROP_XDISTANCE,20);
   ObjectSetInteger(0,"Label_21",OBJPROP_YDISTANCE,40);
   ObjectSetInteger(0,"Label_21",OBJPROP_CORNER,CORNER_LEFT_UPPER);
   ObjectSetInteger(0,"Label_21",OBJPROP_COLOR,clrBlack);
//---
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
//---
   if(sparam=="Button_1")
     {
      ObjectSetString(0,"Label_1",OBJPROP_TEXT,DoubleToString(Ask-1*_Point,Digits));
      Comment("цена на момент нажатия кнопки: "+Ask, " ждем цены для входа: "+(Ask-1*_Point));
     }
     
        if(sparam=="Button_21")
     {

      ObjectSetString(0,"Label_21",OBJPROP_TEXT,DoubleToString(Bid+1*_Point,Digits));
      ObjectSetText("MSG","цена Bid в момент нажатия кнопки: "+ DoubleToString(Bid,Digits),8,"Verdana", White);
      ObjectSetText("MSG2","ждем цены Bid для закрытия: "+ DoubleToString(Bid+1*_Point,Digits),8,"Verdana", White);

     }
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   int ticket;
   double price=StringToDouble(ObjectGetString(0,"Label_1",OBJPROP_TEXT));
   if(Ask<=price)
     {
      ticket = OrderSend(_Symbol,OP_BUY,0.01,Ask,0,0,0,NULL,0,0,clrGreen);
      ObjectSetString(0,"Label_1",OBJPROP_TEXT,DoubleToString(DBL_MAX,Digits));
      ObjectSetInteger(0,"Button_1",OBJPROP_STATE,false);
      Comment("цена ожидания была: "+price, " зашли по: "+Ask, " TakeProfit на: "+(Ask+4*_Point));
     }
     
     
     
       //-----close buy +1

   double priceclosebuyplus1=StringToDouble(ObjectGetString(0,"Label_21",OBJPROP_TEXT));
   if(Bid>=priceclosebuyplus1)
     {

      
      ObjectSetString(0,"Label_21",OBJPROP_TEXT,DoubleToString(DBL_MAX,Digits));
      ObjectSetInteger(0,"Button_21",OBJPROP_STATE,false);
      ObjectSetText("MSG","ожидали цену закрытия Bid: "+DoubleToString(priceclosebuyplus1,Digits),8,"Verdana", White);
      ObjectSetText("MSG2","закрыли по цене Bid: "+ DoubleToString(Bid,Digits),8,"Verdana", White);
      CloseBuyPositions1();
     }
     
     
     
  }
  
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void CloseBuyPositions1()
  {

   for(int i=OrdersTotal()-1; i>=0; i--)
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))



         if(OrderType()==OP_BUY)
           {
            if(OrderClose(OrderTicket(), OrderLots(), Bid, 3, NULL))
              {
               Print("Order Close");
              }
           }

  }

help me out

 
Порт-моне тв #:

Anyway, I've been writing this board for almost a week and here's the problem - if I also set the most pending leveller to close on a button analogous to the approach, which was a point below when the price is reached, then for some reason without asking it closes immediately, without pressing the button, which should do it a point above (after pressing and reaching a level as in theory you need)


help me out


if(Bid>=priceclosebuyplus1&&priceclosebuyplus1>0)
Reason: