[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 221

 

This is one of the functions that are implemented by Expert Advisors. Of course, you can write an EA, which will contain only a trailing stop (and of course such EAs are already written in large quantities)

In the MT terminal there is a standard trailing stop, not associated with any Expert Advisor.

 
alsu:


The MT terminal has in-house trailing, not related to any Expert Advisor.

Thank you. That's exactly what I was asking about. Another question then. How long did it take to understand MQL4? I don't mean to become a pro and write a thoroughly awesome Expert Advisor. I don't mean to become a pro to write a cool EA from A to Z, but at least know what to tweak when writing an already existing one. To make it clearer about myself: At this stage I'm mastering operators. It has been two weeks since I started studying them. What do you think the chances are. I repeat. Teacher is not around to ask no one.

Appreciate the answers.

 

Guys, this is the worst!!!(((

I want to choose a foreign brokerage company, and open an account overseas... I can not find .... on reviews, it feels like a scam and a "shark's office" ....(

Help guys with MT4.... I will be very grateful!!!!!

 
Like, the new Pinocchio is looking for a reliable Field of Wonder. Don't be ridiculous.)
 

One line indicator.

#property indicator_separate_window    
#property indicator_buffers 1        
#property indicator_color1 Aqua      

  int index;
  double TickPrice[1000];
//--------------------------------------------------------------------
int init()                          
  {
   SetIndexBuffer(0,TickPrice);          
   SetIndexStyle (0,DRAW_LINE,STYLE_SOLID,1); 
   return;                          
  }
//--------------------------------------------------------------------
int start()                         
  {
  
      TickPrice[index] = Bid;
      index++;

   return;                         
  }
//--------------------------------------------------------------------

Question.

Why does it draw a line from right to left?

 

How about this?

#property indicator_separate_window    
#property indicator_buffers 1        
#property indicator_color1 Aqua      

  int index=1000;
  double TickPrice[1000];
//--------------------------------------------------------------------
int init()                          
  {
   SetIndexBuffer(0,TickPrice);          
   SetIndexStyle (0,DRAW_LINE,STYLE_SOLID,1); 
   return;                          
  }
//--------------------------------------------------------------------
int start()                         
  {
  
      TickPrice[index] = Bid;
      index--;

   return;                         
  }
//--------------------------------------------------------------------
 

Hello, could you please tell me where to find an indicator that re-draws the daily bars so that they start at a different time.

For example: Terminal time is 00:00. In the input parameters of indicator we put: +4. Now the daily bars start at 4:00.

Thank you in advance.

 
DhP:

What if you do this?


Yes, that's better. Started to draw in the right direction. But if index--, then one day it becomes index==0 and everything is shut down.

How do you make the movement continue?

 
artmedia70:
Where do I increase the size of the array? Where do I write the value? ( ArrayResize() function)


sorting into arrays by oreder and position types worked out:

int OrderStatus() {
   int z1=1, z2=1, z3=1, z4=1;
   if (B>0) {ArrayResize(TicketB,B);}
   if (S>0) {ArrayResize(TicketS,S);}
   if (BS>0) {ArrayResize(TicketBS,BS);}
   if (SS>0) {ArrayResize(TicketSS,SS);}
   int i, k=OrdersTotal();
      for (i=1; i<=k; i++) {
         if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
            if (OrderType()==OP_BUYSTOP && OrderSymbol()==Symbol() && OrderMagicNumber()==MG) {
            TicketBS[z1]=OrderTicket();
            z1++;
            }
            if (OrderType()==OP_SELLSTOP && OrderSymbol()==Symbol() && OrderMagicNumber()==MG) {
            TicketSS[z2]=OrderTicket();
            z2++;
            }
            if (OrderType()==OP_BUY && OrderSymbol()==Symbol() && OrderMagicNumber()==MG) {
            TicketB[z3]=OrderTicket();
            z3++;
            }
            if (OrderType()==OP_SELL && OrderSymbol()==Symbol() && OrderMagicNumber()==MG) {
            TicketS[z4]=OrderTicket();
            z4++;
            }
         }
      }
}

but I can't sort them further by profitability of buy and sell positions: it inserts zeros:

int OrderVBezubitok() {
   int k1=0, k2=0;
   ArrayResize(TicketBez,B+S);
   ArrayResize(TicketTral,B+S);
   int i;
   if (ArraySize(TicketB)>0) {
      for (i=1; i<ArraySize(TicketB)+1; i++) {
            OrderSelect(TicketB[i], SELECT_BY_TICKET, MODE_TRADES);
            if (OrderProfit()>0) {k1++; TicketTral[k1]=TicketB[i];} 
            else {k2++; TicketBez[k2]=TicketB[i];}
                       
         
      }
   }
   if (ArraySize(TicketS)>0) {
      for (i=1; i<ArraySize(TicketS)+1; i++) {
            OrderSelect(TicketS[i], SELECT_BY_TICKET, MODE_TRADES);
            if (OrderProfit()>0) {k1++; TicketTral[k1]=TicketB[i];} 
            else {k2++; TicketBez[k2]=TicketB[i];}
                       
         
      }
   }      
}

Why? I don't understand

 

Hello friends!

I don't know if I'm in the right place, this is my first post on the forum.

I'm asking for help.

Maybe someone has encountered something similar.

The problem is as follows. I'm writing an indicator for finding the maximum and minimum of price for a period. I want to divide max by min and display it in separate_window.

But the window is empty:

When adding, subtracting, multiplying, etc. MAXIMUM and MINIMUM the indicator displays normally.

Here is the code. It is not much at all.

#property indicator_separate_window
#property indicator_buffers 3

#property indicator_color1 MediumSpringGreen
#property indicator_color2 Crimson
#property indicator_color3 LightGray

#property indicator_width1 1
#property indicator_width2 1
#property indicator_width3 1

extern int Buy_bars = 20;           //Количество баров для открытия позиции
extern int Sell_bars = 23;          //Количество баров для закрытия позиции  

double   buf_0[],                   //индикаторныЙ массив максимумов 
         buf_1[],                   //индикаторныЙ массив минимумов 
         buf_sr[] ;                 //индикаторныЙ массив средних значений
//extern int Shift = 0;

int init()
  {
   SetIndexBuffer (0, buf_0);
   SetIndexStyle (0, DRAW_LINE);
   SetIndexLabel (0, "Maximum");
   SetIndexShift (0, 0);
   
   SetIndexBuffer (1, buf_1);
   SetIndexStyle (1, DRAW_LINE);
   SetIndexLabel (1, "Minimum");
   SetIndexShift (1, 0);
   
   SetIndexBuffer (2, buf_sr);
   SetIndexStyle (2, DRAW_LINE);
   SetIndexLabel (2, "Srednyaya");
   SetIndexShift (2, 0);
   
   return;
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int i, k ,t;
   int    counted_bars=IndicatorCounted();
//----
   i = Bars - counted_bars - 1;
   while (i >= 0)
   {
      double max = 0;
      double min = 999999999999.99;
   
   for (k=i ; k<=i+Buy_bars-1; k++)
      {
      if (High[k] > max) max = High[k];
      }
   for (t=i; t<=i+Sell_bars-1; t++)  
      {
      if (Low[t] < min) min = Low[t];
      }
        
   i--;
   

   buf_sr[i] = (max/min);
   }
   return;
  }
//+------------------------------------------------------------------+

Point out the error.

Thank you in advance.

Reason: