Add Vlines to custom indicator arrows

 

Can someone please help me to add vlines at the same place that the arrows are placed.


Documentation on MQL5: Constants, Enumerations and Structures / Indicator Constants / Indicators Lines
Documentation on MQL5: Constants, Enumerations and Structures / Indicator Constants / Indicators Lines
  • www.mql5.com
Indicators Lines - Indicator Constants - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 

Forum on trading, automated trading systems and testing trading strategies

When you post code please use the CODE button (Alt-S)!

Use the CODE button


 
Sergey Golubev:
#property indicator_label1  "CallSignal"
#property indicator_type1   DRAW_ARROW
#property indicator_color1  Yellow
#property indicator_style1  STYLE_SOLID
#property indicator_width1  3

#property indicator_label2  "PutSignal"
#property indicator_type2   DRAW_ARROW
#property indicator_color2  Yellow
#property indicator_style2  STYLE_SOLID
#property indicator_width2  3

double CallSignal[], PutSignal[];
string LastTrade = "";
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0, CallSignal);
   SetIndexArrow(0, 217);
   SetIndexBuffer(1, PutSignal);
   SetIndexArrow(1, 218);
//---
   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[])
  {
//---
   
for(int i=5000; i >= 0; i--)      
   { 
        if ( Open[i+1]<Close[i+1] 
                      
           && Close[i+1] > iBands(NULL,0,29,2,0,PRICE_CLOSE,MODE_UPPER,i+1)
           && LastTrade != "CALL")
         
         {     
      
         CallSignal[i] = Low[i]- (35 * Point);
         LastTrade = "CALL";
 
     }
      
      else if ( Open[i+1]>Close[i+1]
              
              && Close[i+1] < iBands(NULL,0,29,2,0,PRICE_CLOSE,MODE_LOWER,i+1)
              && LastTrade != "PUT")
       {      
 
         PutSignal[i] = High[i]+ (35 * Point);
         LastTrade = "PUT";
         }
         
         
                                                   //RESET
                                          
                                                 if (Close[i+2] < iBands(NULL,0,29,2,0,PRICE_CLOSE,MODE_MAIN,i+2)
                                                 && Close[i+1] > iBands(NULL,0,29,2,0,PRICE_CLOSE,MODE_MAIN,i+1))
                                                 
                                                 LastTrade = "PUT";
                                                 
                                                 
                                                 if (Close[i+2] > iBands(NULL,0,29,2,0,PRICE_CLOSE,MODE_MAIN,i+2)
                                                 && Close[i+1] < iBands(NULL,0,29,2,0,PRICE_CLOSE,MODE_MAIN,i+1))
                                                 
                                                 LastTrade = "CALL";                                                   
         
         
         
      
   }
//--- return value of prev_calculated for next call
   return(rates_total);
  }

//+------------------------------------------------------------------+
 
  1. You should have edited your original post; not posted again.
              Messages Editor

  2. forreal7: Can someone please help me to add vlines at the same place that the arrows are placed.

    Help you with what? You haven't stated a problem, you stated a want. Show us your attempt (using the CODE button) and state the nature of your problem.
              No free help 2017.04.21

    Or pay someone. Top of every page is the link Freelance.
              Hiring to write script - General - MQL5 programming forum 2018.05.12

    We're not going to code it for you (although it could happen if you are lucky or the problem is interesting).
              No free help 2017.04.21

 
forreal7:

Can someone please help me to add vlines at the same place that the arrows are placed.


You have to use a global variable
 
ffoorr: You have to use a global variable

Wrong. OP has to create a Vline when the arrow buffer gets set. Remember the original question:

forreal7: Can someone please help me to add vlines at the same place that the arrows are placed.
Reason: