[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 253

 
DDFedor >> :

kogda je budet MQL5?

If not, ask us. Not everyone likes to read transliteration, so transliteration also limits your ability to answer you.

Thanks, DDFedor, and when I had to find something in google I used to make appliqué of the letters of the text in russian.

 

help me colour the indicator, I want it to be green if the value goes up, red if it goes down

Here is the code:

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Green


int BarsCount = 10000;

//---- buffers
double buf_1[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
    SetIndexStyle(0,DRAW_HISTOGRAM);
    SetIndexBuffer(0, buf_1);
//    SetIndexStyle(1,DRAW_HISTOGRAM);
//    SetIndexBuffer(1, buf_2);
    //----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
int i;
//----
   int limit = BarsCount;
    if ( limit > Bars)
        limit = Bars;
        
   for ( i = limit; 0 <= i; i--) {

        buf_1[ i] = High[ i]-Low[ i];
   
        
        
        }
//----
   return(0);
  }
//+------------------------------------------------------------------+
 

I want a pending order to be placed at 15:00, if there is no open position at that time,

I write the following:

if (Hour()=15 || Minute()=0)

double max_level=High[iHighest(NULL,0,MODE_HIGH,13,0)]; //define maximum price for the last 13 bars
double min_level=Low[iLowest(NULL,0,MODE_LOW,13,0)]; //define minimum price for the last 13 bars
int Dist_SL =60; // Set SL (pt)
int Dist_TP =60; // set TP (pt)
//--------------------Цикл установки ордера BUY STOP---------------------------------------------------------------------
while(true) //Opening order cycle.
{
int Min_Dist1=MarketInfo(Symbol(),MODE_STOPLEVEL); // Min_Dist.
double Price_B=max_level; // Bid price

//----------------Устанавливаем ордер на покупку---------------------------------------------------------------------------
if (NormalizeDouble(Price_B,Digits)< // If less than allowed.
NormalizeDouble(Ask+Min_Dist1*Point,Digits))
{ // Only for BuyStop!
Price_B=Ask+Min_Dist1*Point; // it can not get any closer
Alert("Declared Buy price has been changed: Price = ", Price_B);
}
double SL_B=Price_B - Dist_SL*Point; // Declared SL price to buy
double TP_B=Price_B + Dist_TP*Point; // The declared TP price to buy
Alert("Trade order has been sent to the server. Waiting for reply...");
int ticket1=OrderSend(Symbol(), OP_BUYSTOP, 0.1, Price_B, 0, SL_B, TP_B); //Set Buy order
if (ticket1>0) // It worked :)
{
Alert ("Buy order opened ",ticket1);
break; // Exit the loop
}

I must be writing something wrong, can you tell me how to open a position at a given time?

 

Well, point by point:

1. If the tick is at zero minute, the script will start. It's better to set the zero minute as the starting minute, and then set a flag to prevent the script from starting again. But in principle this is not critical.

2. You only check when the price level is less than what is allowed, and when it is more, you don't.

3. You use normalisation when checking the price, but not when substituting, there may be errors.

 
Roger >> :

Well, point by point:

1. If the tick is at zero minute, the script will start. It's better to set the zero minute as the starting minute, and then set a flag to prevent the script from starting again. But in principle this is not critical.

2. You only check when the price level is less than what is allowed, and when it is more, you don't.

3. You use normalisation when checking the price and not when substituting, there may be errors.

Thank you for your reply. I am a complete beginner in programming, I just started studying the help file and decided to write my EA. I understand that the frame.

if (Hour()=15 || Minute()=0) is not correct at all, each character causes an error when compiling, please tell me how to write it correctly?

 
albon >> :

I want a pending order to be placed at 15:00, if there is no open position at that time,


I must be writing something wrong, can you tell me how to open a position at a given time?

Search the forum, I borrowed from KimiV, there's a function in there that limits the operation by time

 
albon писал(а) >>

Thanks for the reply. I'm a complete novice in programming, just started studying the help file and immediately decided to write my EA. I understand that the frame

if (Hour()=15 || Minute()=0) is not correct at all, in compiling every character causes an error, please advise how to write it correctly?

Change it to

if (Hour()==15 || Minute()==0)

PS If you don't know anything, why bother, better send it to someone else.

 
dmmikl86 >> :

Help me colour the indicator, I want the value to go up in green, and go down in red.

here is the code:

This should be done with two different coloured buffers.

If price rises, then the value is assigned to one buffer if falls to another,

and the second is kept in the black body (e.g. SetIndexEmptyValue(0,0.0);)

0 is assigned to both buffers before it fills, and after that, you distribute buffers to whom you want to bank and whom you don't want to bother.

Vinin seems to have had such an indicator, search through the codebase profile.

 
Can you tell me whether it is possible to insert a small picture in the main window of the terminal?
 
IlyaA >> :
Can you tell me if it's possible to insert a small picture in the main window of the terminal?

Not yet in 5 they promise (at least by standard means)