how to place arrow at high of the candle(blue) and low of the candle(sell)

 

hi friends,

am trying to code ma oscillator cross above 0 ubove/below,

there is appearing arrows but i need them at high of the candle(blue arrow) and low of the candle (red arrow),

and also need alert functions in all time frames,

plzz help me,to code

thanks

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 DarkBlue
#property indicator_color2 Red
#property indicator_width1 3
#property indicator_width2 3

extern int       FastEMA = 12;
extern int       SlowEMA = 26;
extern int       SignalSMA = 9;
extern int       ARROWWIDTH = 3;

double buy[];
double sell[];
double m;


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_ARROW,EMPTY,4,DarkBlue);
   SetIndexArrow(0,217);
   SetIndexBuffer(0,buy);
   SetIndexEmptyValue(0,0.0);
   SetIndexStyle(1,DRAW_ARROW,EMPTY,4,Red);
   SetIndexArrow(1,218);
   SetIndexBuffer(1,sell);
   SetIndexEmptyValue(1,0.0);
//----
   return(0);
  }
 
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
  double Osma0,Osma1;
  for (int i = Bars - 1; i >= 0; i --)
  {
    Osma0 = iOsMA(NULL , 0 , FastEMA , SlowEMA ,SignalSMA , PRICE_WEIGHTED ,i);
    Osma1 = iOsMA(NULL , 0 , FastEMA , SlowEMA ,SignalSMA , PRICE_WEIGHTED ,i+1);
    buy [i] = 0; sell [i] = 0;
    if (Osma0 > 0 && Osma1 < 0)
    {
      buy [i] = Low [i] - 5 * Point;
      if (Period () >= PERIOD_M30) buy [i] -= 8 * Point;
      if (Period () >= PERIOD_H1) buy [i] -= 8 * Point;
      if (Period () >= PERIOD_H4) buy [i] -= 8 * Point;
      if (Period () >= PERIOD_D1) buy [i] -= 8 * Point;
      if (Period () >= PERIOD_W1) buy [i] -= 12 * Point;
      if (Period () >= PERIOD_MN1) buy [i] -= 60 * Point;
    }
    if (Osma0 < 0 && Osma1 > 0)
    {
      sell [i] = High [i] + 5 * Point;
      if (Period () >= PERIOD_M30) sell [i] += 8 * Point;
      if (Period () >= PERIOD_H1) sell [i] += 8 * Point;
      if (Period () >= PERIOD_H4) sell [i] += 8 * Point;
      if (Period () >= PERIOD_D1) sell [i] += 8 * Point;
      if (Period () >= PERIOD_W1) sell [i] += 12 * Point;
      if (Period () >= PERIOD_MN1) sell [i] += 60 * Point;
    }     
  }
return(0);
}
 
//+------------------------------------------------------------------+
 

Like this ?

 

When I was trying to figure this out I studied the program Fractals - it comes with MT4.

Pay attention to this line of code from Fractals:

ExtUpFractalsBuffer[i]=dCurrent;

Also some arrows will point directly at a price and some arrows will only point close to a price.

Special Arrow codes that exactly points to price and time. It can be one of the following values:

Constant Value Description
1 Upwards arrow with tip rightwards ().
2 Downwards arrow with tip rightwards ().
3 Left pointing triangle ().
4 En Dash symbol (–).
SYMBOL_LEFTPRICE 5 Left sided price label.
SYMBOL_RIGHTPRICE 6 Right sided price label.
 

If you want them exactly at a price, you must use one of the above arrow codes.

Approximately use

    switch(Period())
    {
        case     1: nShift = 1;   break;    
        case     5: nShift = 3;   break; 
        case    15: nShift = 5;   break; 
        case    30: nShift = 10;  break; 
        case    60: nShift = 15;  break; 
        case   240: nShift = 20;  break; 
        case  1440: nShift = 80;  break; 
        case 10080: nShift = 100; break; 
        case 43200: nShift = 200; break;               
    }
From https://www.mql5.com/en/code/10647
 
RaptorUK:

Like this ?


yes
RaptorUK:

Like this ?

yes exactly
 
makkala:

yes yes exactly

OK, change this . . .

    if (Osma0 > 0 && Osma1 < 0)
    {
      buy [i] = Low [i] - 5 * Point;
      if (Period () >= PERIOD_M30) buy [i] -= 8 * Point;
      if (Period () >= PERIOD_H1) buy [i] -= 8 * Point;
      if (Period () >= PERIOD_H4) buy [i] -= 8 * Point;
      if (Period () >= PERIOD_D1) buy [i] -= 8 * Point;
      if (Period () >= PERIOD_W1) buy [i] -= 12 * Point;
      if (Period () >= PERIOD_MN1) buy [i] -= 60 * Point;
    }
    if (Osma0 < 0 && Osma1 > 0)
    {
      sell [i] = High [i] + 5 * Point;
      if (Period () >= PERIOD_M30) sell [i] += 8 * Point;
      if (Period () >= PERIOD_H1) sell [i] += 8 * Point;
      if (Period () >= PERIOD_H4) sell [i] += 8 * Point;
      if (Period () >= PERIOD_D1) sell [i] += 8 * Point;
      if (Period () >= PERIOD_W1) sell [i] += 12 * Point;
      if (Period () >= PERIOD_MN1) sell [i] += 60 * Point;
    }     
  }

to this . . .

    if (Osma0 > 0 && Osma1 < 0)
    {
      buy [i] = High [i];
    }

    if (Osma0 < 0 && Osma1 > 0)
    {
      sell [i] = Low [i];
    }     
  }
 
RaptorUK:

OK, change this . . .

to this . . .


thanks for u r help,

makkala

 
It is a beautiful thing; when you remove lines of code and the program works better.
 
makkala:

hi friends,

am trying to code ma oscillator cross above 0 ubove/below,

there is appearing arrows but i need them at high of the candle(blue arrow) and low of the candle (red arrow),

and also need alert functions in all time frames,

plzz help me,to code

thanks

please is this an EA

 
3011:

please is this an EA



#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 DarkBlue
#property indicator_color2 Red
#property indicator_width1 3
#property indicator_width2 3
What does it say ???
Reason: