Download MetaTrader 5

can anybody help me with this

To add comments, please log in or register
sanders
52
sanders  

hello 

i am trying to make an indicator 
everything is well and good except for one thing 

as you can see when the conditions are true the x sign is appearing in a separate indicator window
but its not fully visible

so how can i move the x sign a little bit above so that the whole sign is visible ?

here is the code



#include <stdlib.mqh>
#include <stderror.mqh>

//--- indicator settings
#property indicator_separate_window
#property indicator_buffers 2

#property indicator_type1 DRAW_ARROW
#property indicator_width1 2
#property indicator_color1 0x00FF00
#property indicator_label1 "Buy"

#property indicator_type2 DRAW_ARROW
#property indicator_width2 2
#property indicator_color2 0x0000FF
#property indicator_label2 "Sell"

//--- indicator buffers
double Buffer1[];
double Buffer2[];

extern int Period1 = 14;
extern double DValue = 0.5;
extern int Period2 = 14;
double myPoint; //initialized in OnInit

void myAlert(string type, string message)
  {
   if(type == "print")
      Print(message);
   else if(type == "error")
     {
      Print(type+" | TEST @ "+Symbol()+","+Period()+" | "+message);
     }
   else if(type == "order")
     {
     }
   else if(type == "modify")
     {
     }
  }

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {   
   IndicatorBuffers(2);
   SetIndexBuffer(0, Buffer1);
   SetIndexEmptyValue(0, 0);
   SetIndexArrow(0, 251);
   SetIndexBuffer(1, Buffer2);
   SetIndexEmptyValue(1, 0);
   SetIndexArrow(1, 251);
   //initialize myPoint
   myPoint = Point();
   if(Digits() == 5 || Digits() == 3)
     {
      myPoint *= 10;
     }
   return(INIT_SUCCEEDED);
  }

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime& time[],
                const double& open[],
                const double& high[],
                const double& low[],
                const double& close[],
                const long& tick_volume[],
                const long& volume[],
                const int& spread[])
  {
   int limit = rates_total - prev_calculated;
   //--- counting from 0 to rates_total
   ArraySetAsSeries(Buffer1, true);
   ArraySetAsSeries(Buffer2, true);
   //--- initial zero
   if(prev_calculated < 1)
     {
      ArrayInitialize(Buffer1, 0);
      ArrayInitialize(Buffer2, 0);
     }
   else
      limit++;
   
   //--- main loop
   for(int i = limit-1; i >= 0; i--)
     {
      if (i >= MathMin(5000-1, rates_total-1-50)) continue; //omit some old rates to prevent "Array out of range" or slow calculation   
      //Indicator Buffer 1
      if(iDeMarker(NULL, PERIOD_CURRENT, Period1, i) > DValue //DeMarker > fixed value
      && iRSI(NULL, PERIOD_CURRENT, Period2, PRICE_CLOSE, i) > 50 //Relative Strength Index > fixed value
      )
        {
         Buffer1[i] = 1; //Set indicator value at Candlestick Low
        }
      else
        {
         Buffer1[i] = 0;
        }
      //Indicator Buffer 2
      if(iDeMarker(NULL, PERIOD_CURRENT, Period1, i) < DValue //DeMarker < fixed value
      && iRSI(NULL, PERIOD_CURRENT, Period2, PRICE_CLOSE, i) < 50 //Relative Strength Index < fixed value
      )
        {
         Buffer2[i] = 1; //Set indicator value at Candlestick High
        }
      else
        {
         Buffer2[i] = 0;
        }
     }
   return(rates_total);
  }
//+------------------------------------------------------------------+
Drazen Penic
2699
Drazen Penic  
sam016:

hello 

i am trying to make an indicator 
everything is well and good except for one thing 

as you can see when the conditions are true the x sign is appearing in a separate indicator window
but its not fully visible

so how can i move the x sign a little bit above so that the whole sign is visible ?

here is the code



All arrows in your indicator have the same value == 1. You have to add maximum and minimum values for the separate window:


   // Insert this in the OnInit()
   IndicatorSetDouble(INDICATOR_MINIMUM,0.5); 
   IndicatorSetDouble(INDICATOR_MAXIMUM,1.5); 


At the beginning of the file, you should add: 

#property strict
sanders
52
sanders  
Drazen Penic:

All arrows in your indicator have the same value == 1. You have to add maximum and minimum values for the separate window:



At the beginning of the file, you should add: 


Thanks a lot bro 
its all looking good now
thanks a lot

To add comments, please log in or register