- alarm possible when any horizontal line is touched?
- Trend indicators
- Step MA Indicator
- Of course it's possible. A line has a price, a bar has H/L price. If they overlap do what you want. If you really had begun programming this you wouldn't have asked the question.
- No image attached.
- Since there are no slaves here, you have only three choices: Search for it, learn to code it, or pay someone. We're not going to code it FOR you. We are willing to HELP you when you post your attempt and the nature of your problem.
Thanks for the response, here is the code I have constructed so far:
//+------------------------------------------------------------------+
//| Attempt1.mq4 |
//| Aramide Shobande |
//| aramide_s@hotmail.co.uk |
//+------------------------------------------------------------------+
#property copyright "Aramide Shobande"
#property link "aramide_s@hotmail.co.uk"
#property indicator_chart_window
#property indicator_buffers 5
#property indicator_color1 Lime
#property indicator_color2 Red
#property indicator_color3 Blue
#property indicator_color4 Lime
#property indicator_color5 Red
extern int numOfBars=100;
//--- buffers
double ExtMapBuffer1Up[];
double ExtMapBuffer2Down[];
double PivotBuffer[];
double S1Buffer[];
double R1Buffer[];
string Pivot="Pivot Point", Sup1="S 1", Res1="R 1";
int fontsize=15;
double P,S1,R1;
double LastHigh, LastLow, x;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(0,241);
SetIndexBuffer(0,ExtMapBuffer1Up);
SetIndexEmptyValue(0,0.0);
SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1,242);
SetIndexBuffer(1,ExtMapBuffer2Down);
SetIndexEmptyValue(1,0.0);
string short_name;
SetIndexStyle(2,DRAW_LINE,0,1,Blue);
SetIndexStyle(3,DRAW_LINE,0,1,Lime);
SetIndexStyle(4,DRAW_LINE,0,1,Red);
SetIndexBuffer(2,PivotBuffer);
SetIndexBuffer(3,S1Buffer);
SetIndexBuffer(4,R1Buffer);
short_name="Pivot Point";
IndicatorShortName(short_name);
SetIndexLabel(2,short_name);
SetIndexDrawBegin(2,1);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
ObjectDelete("Pivot");
ObjectDelete("Sup1");
ObjectDelete("Res1");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
int maximum;
int i;
double MakeArrow;
if(counted_bars==0)
{
x=Period();
if(x>240) return(-1);
ObjectCreate("Pivot",OBJ_TEXT,0,0,0);
ObjectSetText("Pivot", "Pivot Point",fontsize,"Arial",White);
ObjectCreate("Sup1",OBJ_TEXT,0,0,0);
ObjectSetText("Sup1","S 1",fontsize,"Arial",White);
ObjectCreate("Res1",OBJ_TEXT,0,0,0);
ObjectSetText("Res1","R 1",fontsize,"Arial",White);
}
if(counted_bars<0) return(-1);
maximum=(Bars-counted_bars)-1;
for(i=maximum; i>0;i--)
{
if (High[i+1]>LastHigh)
LastHigh=High[i+1];
if (Low[i+1]<LastLow)
LastLow=Low[i+1];
if (TimeDay(Time[i])!=TimeDay(Time[i+1]))
{
P=(LastHigh+LastLow+Close[i+1])/3;
R1 = (2*P)-LastLow;
S1 = (2*P)-LastHigh;
LastLow=Open[i];
LastHigh=Open[i];
ObjectMove("Pivot",0,Time[i],P);
ObjectMove("Sup1",0,Time[i],S1);
ObjectMove("Res1",0,Time[i],R1);
}
PivotBuffer[i]=P;
S1Buffer[i]=S1;
R1Buffer[i]=R1;
//This is where the interaction between the pivot point lines
//and the bars touching them should take place
MakeArrow=Bars;
if(MakeArrow<R1Buffer[i])
ExtMapBuffer1Up[i]=Low[i]+5*Point;
else
ExtMapBuffer1Up[i]=0.0;
}
//----
//----
return(0);
}
//+------------------------------------------------------------------+
The section I have highlighted in yellow is where I attempted to make the arrows appear when the bar exceeds or touches R1 in this case a arrow should appear pointing down. Now what is currently happening is that an arrow appears on all the bars not just the ones that have exceeded R1 so what is the approach I should take here?
I have also attached the source code.
Thanks for the response, here is the code I have constructed so far:
<CODE REMOVED>
The section I have highlighted in yellow is where I attempted to make the arrows appear when the bar exceeds or touches R1 in this case a arrow should appear pointing down. Now what is currently happening is that an arrow appears on all the bars not just the ones that have exceeded R1 so what is the approach I should take here?
I have also attached the source code.
Thanks for the response, here is the code I have constructed so far:
The section I have highlighted in yellow is where I attempted to make the arrows appear when the bar exceeds or touches R1 in this case a arrow should appear pointing down. Now what is currently happening is that an arrow appears on all the bars not just the ones that have exceeded R1 so what is the approach I should take here?
Why are you comparing a bar count, Bars, against a price, R1Buffer[i] ?
MakeArrow = Bars; if(MakeArrow < R1Buffer[i])
Play videoPlease edit your post.
For large amounts of code, attach it.
- comparing bar count against a price
- never updating MakeArrow
- Just compare the bar high vs R
I have made some amendments as can be seen below, the program tries to take in the Price_close and if the arrows variable (MakeArrow) price is less than R1Buffer price (which is resistance 1 in my pivot points) an arrow should be outputted, if not then no arrow should be outputted. This is just a test to see if the arrows would output as seen below: MakeArrow[i]=PRICE_CLOSE; if(MakeArrow[i]<R1Buffer[i]) ExtMapBuffer2Down[i]=High[i]+5*Point; else ExtMapBuffer2Down[i]=0.0; Am I on the right track here now? As what I need to do now is to make it so if the price of most recent bar is at the same price as where R1Buffer is (Resistance 1) then an arrow should appear. Any extra tips?
PRICE_CLOSE is what ? maybe it is zero ? PRICE_CLOSE
Coding is not about guessing, you need to read, learn and think.
Price close is the closed price of a bar is it not? So what I am trying to get the code to do here is to output an arrow above a bar which has closed above the price of where the R1Buffer was generated using the pivot point calculations. What keeps occurring here now is that once the closed bar closes above R1 an arrow is still not displayed and I can't seem to figure out why.
Anyways since then I've opted to use the following method:
MakeArrow[i]=Open[i]; if(MakeArrow[i]>=R1Buffer[i]) ExtMapBuffer2Down[i]=High[i]+5*Point; else ExtMapBuffer2Down[i]=0.0;
Which means the variable array MakeArrow[i] is assigned the value of Open[i], meaning that when the Open[i] opens above R1 an arrow should be outputted. This is a syntax that would be accepted in usual C++/C# but MQL4 is not performing the function as I would expect.
As Can be seen in the attached image, several arrows should have been outputted where the bars opened above R1 but they have not appeared.
This is what should occur when the lines are touched or exceeded. Am I using the wrong approach as I am running out of time, I can only test this indicator while the market remains open.
Price close is the closed price of a bar is it not?
Did you click the link I posted ? PRICE_CLOSE is a constant and has a value of zero. Click this link: PRICE_CLOSE
Anyways since then I've opted to use the following method:
Which means the variable array MakeArrow[i] is assigned the value of Open[i], meaning that when the Open[i] opens above R1 an arrow should be outputted. This is a syntax that would be accepted in usual C++/C# but MQL4 is not performing the function as I would expect.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use