Can any one look into this...

To add comments, please log in or register
Nkechi Sonia Kanu
429
Nkechi Sonia Kanu  

hello guys i tried learning how to write an Indicator, i must say am confused and tired ...am at the verge of giving up...guys if you can spare a minute or two to look into my code and encourage me, i will appreciate


//+------------------------------------------------------------------+
//|                                           Iyke's Pivot Point.mq4 |
//|                                              Copyright 2017, Wik |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, Wik"
#property version   "1.00"
#property strict
#property indicator_chart_window
//----
#property indicator_buffers 7
#property indicator_color1 clrWhite
#property indicator_color2 clrGreen
#property indicator_color3 clrGreen
#property indicator_color4 clrGreen
#property indicator_color5 clrRed
#property indicator_color6 clrRed
#property indicator_color7 clrRed
//---
double PP[],S1[],S2[],S3[],R1[],R2[],R3[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   IndicatorShortName("Iyke's Pivot Point");
//---
   datetime StartingTime=iTime(NULL,PERIOD_MN1,0);
//---
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,PP);
   SetIndexLabel(0,"PP");
//---
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,S1);
//SetIndexDrawBegin(1,StartingTime);
   SetIndexLabel(1,"S1");
   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=prev_calculated; i<rates_total; i++)
     {

      //-----WEEKLY PIVOTS TIME FRAME
      double WeeklyHigh=NormalizeDouble(iHigh(NULL,PERIOD_W1,1),5);
      double WeeklyLow=NormalizeDouble(iLow(NULL,PERIOD_W1,1),5);
      double WeeklyClose=NormalizeDouble(iClose(NULL,PERIOD_W1,1),5);
      //-----WEEKLY PIVOT CALCULATION
      double PivotPoint=NormalizeDouble((WeeklyHigh+WeeklyLow+WeeklyClose)/3,5);
      double Res1=NormalizeDouble((2*PivotPoint)-WeeklyLow,5);
      double Sup1=NormalizeDouble((2*PivotPoint)-WeeklyHigh,5);
      double Res2=NormalizeDouble(PivotPoint+(WeeklyHigh-WeeklyLow),5);
      double Sup2=NormalizeDouble(PivotPoint-(WeeklyHigh-WeeklyLow),5);
      double Res3=NormalizeDouble(WeeklyHigh+2*(PivotPoint-WeeklyLow),5);
      double Sup3= NormalizeDouble(WeeklyLow-2*(WeeklyHigh-PivotPoint),5);
      //---
      PP[i]=PivotPoint;
      S1[i]=high[i];
     }

   return(0);
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+

I tried to make a pivot point indicator, but i don't know whats wrong, because its not displaying any lines but for the high[i] it showing lines.....


i dont know why i find it difficult learning how to do this but am a good programmer when it comes to Expert Advisors

Mladen Rakic
151878
Mladen Rakic  
Nkechi Sonia Kanu:

hello guys i tried learning how to write an Indicator, i must say am confused and tired ...am at the verge of giving up...guys if you can spare a minute or two to look into my code and encourage me, i will appreciate


I tried to make a pivot point indicator, but i don't know whats wrong, because its not displaying any lines but for the high[i] it showing lines.....


i dont know why i find it difficult learning how to do this but am a good programmer when it comes to Expert Advisors

You declared buffers only for pp and s1.
Jack Thomas
1626
Jack Thomas  
Nkechi Sonia Kanu:

hello guys i tried learning how to write an Indicator, i must say am confused and tired ...am at the verge of giving up...guys if you can spare a minute or two to look into my code and encourage me, i will appreciate

I tried to make a pivot point indicator, but i don't know whats wrong, because its not displaying any lines but for the high[i] it showing lines.....

i dont know why i find it difficult learning how to do this but am a good programmer when it comes to Expert Advisors

Documentation

https://docs.mql4.com/


Tutorial Book

https://book.mql4.com/


Custom indicators

https://docs.mql4.com/customind


Creation of custom indicators

https://book.mql4.com/samples/icustom


Those pages above should help you with this problem.

- Jack

Custom Indicators - MQL4 Reference
Custom Indicators - MQL4 Reference
  • docs.mql4.com
Indicator properties can be set using the compiler directives or using functions. To better understand this, it is recommended that you study indicator styles in examples.
William Roeder
19857
William Roeder  
  1. for(int i=prev_calculated; i<rates_total; i++){
          double WeeklyHigh=NormalizeDouble(iHigh(NULL,PERIOD_W1,1),5);
    There is no such function iHigh. Why did you post your MT4 question in the Root / MT5 Indicators section instead of the MQL4 section, (bottom of the Root page?)
              General rules and best pratices of the Forum. - General - MQL5 programming forum

  2. Do NOT use NormalizeDouble, EVER. For ANY Reason. It's a kludge, don't use it. It's use is always wrong

  3. for(int i=prev_calculated; i<rates_total; i++){
          double WeeklyHigh=iHigh(NULL,PERIOD_W1,1);
    Unless you are running on the W1 chart, you are mixing apples and oranges. Your bar index is i but you are looking at the weekly 1 not the corresponding weekly index.
Nkechi Sonia Kanu
429
Nkechi Sonia Kanu  
Mladen Rakic:
You declared buffers only for pp and s1.

yes, i stopped and got discouraged when i saw it wasn't showing any lines

Nkechi Sonia Kanu
429
Nkechi Sonia Kanu  
Jack Thomas:

Documentation

https://docs.mql4.com/


Tutorial Book

https://book.mql4.com/


Custom indicators

https://docs.mql4.com/customind


Creation of custom indicators

https://book.mql4.com/samples/icustom


Those pages above should help you with this problem.

- Jack


Thanks jack, i already read most of those stuff, what i need is just someone to ask some qustions...like currently i need someone to show me my mistake with those piece of code above- why isnt it showing any lines on the chart.

Nkechi Sonia Kanu
429
Nkechi Sonia Kanu  
whroeder1:
  1. There is no such function iHigh. Why did you post your MT4 question in the Root / MT5 Indicators section instead of the MQL4 section, (bottom of the Root page?)
              General rules and best pratices of the Forum. - General - MQL5 programming forum

  2. Do NOT use NormalizeDouble, EVER. For ANY Reason. It's a kludge, don't use it. It's use is always wrong

  3. Unless you are running on the W1 chart, you are mixing apples and oranges. Your bar index is i but you are looking at the weekly 1 not the corresponding weekly index.

1) No such function as iHigh(); really? 

sorry about not posting the topic in the right section, i didnt know here is strictly for Mt5 indicators.

2)i will read that up, but if NormalizeDouble isnt used, there will be a warning message when i use the #property strict.

3)i didnt understand what you said there, remember, am learning how to write indicators on my own.

Jack Thomas
1626
Jack Thomas  
Nkechi Sonia Kanu:

1) No such function as iHigh(); really? 

sorry about not posting the topic in the right section, i didnt know here is strictly for Mt5 indicators.

2)i will read that up, but if NormalizeDouble isnt used, there will be a warning message when i use the #property strict.

3)i didnt understand what you said there, remember, am learning how to write indicators on my own.

Answers:

1) MQL4 has iHigh,iLow,IOpen,iClose, iTime

Read the documentation. It has the API specifications for each of item.


2) There is NOTHING wrong with using NormalizeDouble() if it is appropriate for the situation.

NormalizeDouble() is used for used for rounding numbers to a specific accuracy.

https://docs.mql4.com/convert/normalizedouble


Do you have specific questions about what you struggling with?

- Jack

NormalizeDouble - Conversion Functions - MQL4 Reference
NormalizeDouble - Conversion Functions - MQL4 Reference
  • docs.mql4.com
Calculated values of StopLoss, TakeProfit, and values of open prices for pending orders must be normalized with the accuracy, the value of which can be obtained by Digits(). Please note...
Nkechi Sonia Kanu
429
Nkechi Sonia Kanu  

hello jack, what i need now is just for someone to pin point my mistake in my code above though am not finish and no sign to show am making progress( no line displayed) i just became discouraged and lack interest to continue.

Jack Thomas
1626
Jack Thomas  
Nkechi Sonia Kanu:

hello jack, what i need now is just for someone to pin point my mistake in my code above though am not finish and no sign to show am making progress( no line displayed) i just became discouraged and lack interest to continue.


I'm not going to do the work for you, but I am willing to help you learn how to fix it yourself.

You've not bothered to post any changes to your code, or explained what you did to try and fix it.

There are numerous programmers who can help you.

https://www.mql5.com/en/job

Freelance service at MQL5.com
Freelance service at MQL5.com
  • www.mql5.com
Dear Coder, I have my EA, but it is in EX4 format, but I want to make some changes into it, can anyone help me to change from EX4 to MQ4 file? Thanks, hi dear, i have one indicator based on its BUY/SELL signal i want to build a scalping EA with SL, TP, PENDING ORDER, AUTO LOT INCREASE, MONEY MANAGEMENT, CURRENT TIME & PROFIT DISPLAY  ON...
Nkechi Sonia Kanu
429
Nkechi Sonia Kanu  

hello guys still on that issue, i used the object create to create the lines but as usual there is a glitch, i notice that it doesn't work on all currency pair that is, it doesn't display lines and secondly, when i remove the indicator, the object is till on the chart.


Tomorrow, i will try to work on the indicator using the buffer the proper way.


i attached the indicator, any one that has a minute or two should go through it and help figure my mistake, because to me it looked perfect. 

thanks.

Files:
To add comments, please log in or register