I hope someone can help with this problem. I am a very new coder and am attempting to create the logic that will recognize a hammer or inverted hammer. Once it's detecting them to my satisfaction I will continue to create the EA for orders and such.
The code is supposed to mark all candles where the close = high or close = Low. It marks some but not others. Any help would be greatly appreciated.
Does the computer see more digits in the price than we do. For example, we see 1.44551 on both the close and the high; does the computer possibly see 1.445519?
Original credit to VMesquita for code...I changed it very little.
The code is supposed to mark all candles where the close = high or close = Low. It marks some but not others. Any help would be greatly appreciated.
Does the computer see more digits in the price than we do. For example, we see 1.44551 on both the close and the high; does the computer possibly see 1.445519?
QuoteDisliked#property copyright "VMesquita"
#property indicator_chart_window // an indicator is drawn in the main chart window
#property indicator_buffers 1
int limit;
int init ()
{
//----
return(0);
}
int deinit()
{
return(0);
}
int start()
{
double O,C,H,L,O1,C1,H1,L1,O2,C2,H2,L2;
string text;
int counted_bars=IndicatorCounted();
limit=Bars-counted_bars;
//---- check for possible errors
if(counted_bars<0) {
Alert("No Bars..");
return(-1);
}
//---- last counted bar will be recounted
for(int i=1; i<limit; i++) {
O=iOpen(NULL,0,i);
C=iClose(NULL,0,i);
H=iHigh(NULL,0,i);
L=iLow(NULL,0,i);
O1=iOpen(NULL,0,i-1);
C1=iClose(NULL,0,i-1);
H1=iHigh(NULL,0,i-1);
L1=iLow(NULL,0,i-1);
O2=iOpen(NULL,0,i+1);
C2=iClose(NULL,0,i+1);
H2=iHigh(NULL,0,i+1);
L2=iLow(NULL,0,i+1);
text="";
if(((H-L)>4*(O-C))&&((C-L)/(0.001+H-L)>=0.75)&&((O-L)/(0.001+H-L)>=0.75)) text="Hang";
if(H==C)text="BUY";
if(C==L)text="SELL";
//If we found a special candlem write in the Chart
if(text!="")
{
ObjectCreate(DoubleToStr(i,0)+" label", OBJ_TEXT, 0, Time[i], H);
ObjectSetText(DoubleToStr(i,0)+" label", text, 15, "Arial", Blue);
PlaySound("wait.wav");
}
}
}
Original credit to VMesquita for code...I changed it very little.