how to calculate price of the signal candle

 

Hi

My query is , " how to calculate price of the signal candle?"

Can any one help me please?


Below is my code for indicator.

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

#property indicator_type1 DRAW_ARROW
#property indicator_width1 5
#property indicator_color1 0x00CF22
#property indicator_label1 "Buy"

#property indicator_type2 DRAW_ARROW
#property indicator_width2 5
#property indicator_color2 0xE600FF
#property indicator_label2 "Sell"

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

int TOD_From_Hour = 10; //time of the day (from hour)
int TOD_From_Min = 30; //time of the day (from min)
int TOD_To_Hour = 21; //time of the day (to hour)
int TOD_To_Min = 00; //time of the day (to min)
datetime time_alert; //used when sending alert
extern bool Audible_Alerts = true;
extern bool Push_Notifications = true;
double myPoint; //initialized in OnInit

bool inTimeInterval(datetime t, int From_Hour, int From_Min, int To_Hour, int To_Min)
  {
   string TOD = TimeToString(t, TIME_MINUTES);
   string TOD_From = StringFormat("%02d", From_Hour)+":"+StringFormat("%02d", From_Min);
   string TOD_To = StringFormat("%02d", To_Hour)+":"+StringFormat("%02d", To_Min);
   return((StringCompare(TOD, TOD_From) >= 0 && StringCompare(TOD, TOD_To) <= 0)
     || (StringCompare(TOD_From, TOD_To) > 0
       && ((StringCompare(TOD, TOD_From) >= 0 && StringCompare(TOD, "23:59") <= 0)
         || (StringCompare(TOD, "00:00") >= 0 && StringCompare(TOD, TOD_To) <= 0))));
  }

void myAlert(string type, string message)
  {
   int handle;
   if(type == "print")
      Print(message);
   else if(type == "error")
     {
      Print(type+" | Parasar2 @ "+Symbol()+","+IntegerToString(Period())+" | "+message);
     }
   else if(type == "order")
     {
     }
   else if(type == "modify")
     {
     }
   else if(type == "indicator")
     {
      Print(type+" | Parasar2 @ "+Symbol()+","+IntegerToString(Period())+" | "+message);
      if(Audible_Alerts) Alert(type+" | Parasar2 @ "+Symbol()+","+IntegerToString(Period())+" | "+message);
      handle = FileOpen("Parasar2.txt", FILE_TXT|FILE_READ|FILE_WRITE|FILE_SHARE_READ|FILE_SHARE_WRITE, ';');
      if(handle != INVALID_HANDLE)
        {
         FileSeek(handle, 0, SEEK_END);
         FileWrite(handle, type+" | Parasar2 @ "+Symbol()+","+IntegerToString(Period())+" | "+message);
         FileClose(handle);
        }
      if(Push_Notifications) SendNotification(type+" | Parasar2 @ "+Symbol()+","+IntegerToString(Period())+" | "+message);
     }
  }

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {   
   IndicatorBuffers(2);
   SetIndexBuffer(0, Buffer1);
   SetIndexEmptyValue(0, EMPTY_VALUE);
   SetIndexArrow(0, 241);
   SetIndexBuffer(1, Buffer2);
   SetIndexEmptyValue(1, EMPTY_VALUE);
   SetIndexArrow(1, 242);
   //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(Low[i] > iSAR(NULL, PERIOD_CURRENT, 0.10, 1, i)
      && Low[i+1] < iSAR(NULL, PERIOD_CURRENT, 0.10, 1, i+1) //Candlestick Low crosses above Parabolic SAR
      && iMA(NULL, PERIOD_CURRENT, 20, 0, MODE_SMA, PRICE_CLOSE, i) > iBands(NULL, PERIOD_CURRENT, 20, 2, 0, PRICE_CLOSE, MODE_LOWER, i) + 15 * myPoint //Moving Average > Bollinger Bands + fixed value
      )
        {
         if(!inTimeInterval(Time[i], TOD_From_Hour, TOD_From_Min, TOD_To_Hour, TOD_To_Min)) continue; //draw indicator only at specific times of the day
         Buffer1[i] = Close[1+i] - 15; //Set indicator value at Candlestick Close - fixed value
         if(i == 0 && Time[0] != time_alert) { myAlert("indicator", "Buy"); time_alert = Time[0]; } //Instant alert, only once per bar
        }
      else
        {
         Buffer1[i] = EMPTY_VALUE;
        }
      //Indicator Buffer 2
      if(High[i] < iSAR(NULL, PERIOD_CURRENT, 0.10, 1, i)
      && High[i+1] > iSAR(NULL, PERIOD_CURRENT, 0.10, 1, i+1) //Candlestick High crosses below Parabolic SAR
      && iMA(NULL, PERIOD_CURRENT, 20, 0, MODE_SMA, PRICE_CLOSE, i) < iBands(NULL, PERIOD_CURRENT, 20, 2, 0, PRICE_CLOSE, MODE_UPPER, i) - 15 * myPoint //Moving Average < Bollinger Bands - fixed value
      )
        {
         if(!inTimeInterval(Time[i], TOD_From_Hour, TOD_From_Min, TOD_To_Hour, TOD_To_Min)) continue; //draw indicator only at specific times of the day
         Buffer2[i] = Close[1+i] + 15; //Set indicator value at Candlestick Close + fixed value
         if(i == 0 && Time[0] != time_alert) { myAlert("indicator", "Sell"); time_alert = Time[0]; } //Instant alert, only once per bar
        }
      else
        {
         Buffer2[i] = EMPTY_VALUE;
        }
     }
   return(rates_total);
  }
//+------------------------------------------------------------------+
 
Pravinkumar Khairnar :

Hi

My query is , " how to calculate price of the signal candle?"

Can any one help me please?


Below is my code for indicator.

Please use the 'Code' button  Code.

 
I want to show the opening candle price of signal candle, how to do it please..
 
Pravinkumar Khairnar:
I want to show the opening candle price of signal candle, how to do it please..
 
Vladimir Karputov:


I dint get you, can you please clarify,,
 
Pravinkumar Khairnar :
I dint get you, can you please clarify,,

Paste your indicator code into messages. Use the button  Code to insert code.

 
Vladimir Karputov:

Paste your indicator code into messages. Use the button   to insert code

By submitting code, how my query will get solved.??

 
Pravinkumar Khairnar :

By submitting code, how my query will get solved.??

Sorry, all of our wizards and telapats are on vacation right now. Without them, We cannot read your thoughts. There is only one way left: you must attach the code of your indicator using the button  Code.

 
Pravinkumar Khairnar:

Hi

Below is my code for indicator.

there is nothing below!

 
Ahmet Metin Yilmaz:

there is nothing below!

Posted again..
 

If you talking about the Bid / Ask Price of the signal at the moment that signal candle alert comes out then you need to put something in your code to output to your alert. 

Something like:
Print(Ask) or Print(Buy) to give you the price at that moment. 

Then use that data to put it where ever you need it or send it to your alert as well. 
Anyhow just what little I know and that is not much. 


Here is docs. 

https://docs.mql4.com/predefined

Predefined Variables - MQL4 Reference
Predefined Variables - MQL4 Reference
  • docs.mql4.com
For each executable mql4-program a set of predefined variables is supported, which reflect the state of the current price chart by the moment a mql4-program (Expert Advisor, script or custom indicator) is started. Values of predefined variables are set by the...
Reason: