Need help with my custom indicator

 

Hello!

A total MQL programming newbie here. I decided to create my first custom indicator in MQL4 based on pin bars. When i finished the writing and compiled the code everything was allright, but when i decided to use it on chart i got the message in expert chart:

2020.02.06 14:33:38.665 Custom indicator PB_final EURUSD,M15: removed

2020.02.06 14:33:38.665 Custom indicator PB_final EURUSD,M15: loaded successfully

-and ofcourse nothing visible is loaded. 

My indicator should create an arrow for buy and sell on/below the pinbar candle (i set my own conditions for pin bars which you can see in code below), but sadly it does nothing.

I am posting the code here and hopefully someone can teach me a thing or two about the issue im dealing with. If you have the time to help me please use the tactic of "speaking to a child" as i am a beginner in these things.

#property indicator_chart_window

void OnTick()

 
{
if(Close[1]>Open[1])                                                             //Typ 1. klesajúci
 if((High[1]-Close[1]>Close[1]-Low[1]))                                              //51% podmienka       
  if((Close[1]>=Low[2])&&(Open[1]>=Low[2])&&(Close[1]<=High[2])&&(Open[1]<=High[2])) //telo vedľa

{
ObjectCreate("kladivo1",OBJ_ARROW_BUY,0,Time[1],Low[1]);
}

if(Close[1]<Open[1])                                                                 //Typ 1. rastúci
 if((High[1]-Open[1]>Open[1]-Low[1]))                                                 //51% podmienka
  if((Close[1]>=Low[2])&&(Open[1]>=Low[2])&&(Close[1]<=High[2])&&(Open[1]<=High[2]))      //telo vedľa

{
ObjectCreate("kladivo2",OBJ_ARROW_BUY,0,Time[1],Low[1]);
}

if(Close[1]>Open[1])                                                                                   //Typ 2. rastúci
 if((Open[1]-Low[1]>High[1]-Open[1]))                                                                     //51% podmienka
  if((Open[1]<=High[2])&&(Close[1]<=High[2])&&(Open[1]>=Low[2])&&(Close[1]>=Low[2]))                        //telo vedľa

{
ObjectCreate("obesenec1",OBJ_ARROW_SELL,0,Time[1],High[1]);
} 

if(Close[1]<Open[1])                                                            //Typ 2. klesajúci         
  if((Close[1]-Low[1]>High[1]-Close[1]))                                             //51% podmienka
  if((Close[1]>=Low[2])&&(Open[1]>=Low[2])&&(Close[1]<=High[2])&&(Open[1]<=High[2]))      //telo vedľa

{
ObjectCreate("obesenec2",OBJ_ARROW_SELL,0,Time[1],High[1]);
} 


if(Close[1]>Open[1])                                                                            //Typ 3.rastúci
 if((High[1]-Close[1])>(Close[1]-Low[1]))                                                       //51% podmienka
  if((Close[1]<=High[2])&&(Open[1]<=High[2])&&(Open[1]>=Low[2])&&(Close[1]>=Low[2]))                //telo vedľa
  
{
ObjectCreate("kladivo3",OBJ_ARROW_SELL,0,Time[1],High[1]);
}  

if(Close[1]<Open[1])                                                                            //Typ 3.klesajúci
 if((High[1]-Open[1])>(Open[1]-Low[1]))                                                       //51% podmienka
  if((High[2]>=Open[1])&&(High[2]>=Close[1])&&(Low[2]<=Open[1])&&(Low[2]<=Close[1]))                //telo vedľa
  
{
ObjectCreate("kladivo4",OBJ_ARROW_SELL,0,Time[1],High[1]);
}

if(Open[1]>Close[1])                                                             //Typ 4. klesajúci
 if((Close[1]-Low[1])>(High[1]-Close[1]))                                          //51% podmiennka
  if((Low[2]<=Open[1])&&(Low[2]<=Close[1])&&(High[2]>=Open[1])&&(High[2]>=Close[1]))   //telo vedľa
  
{
ObjectCreate("obesenec3",OBJ_ARROW_BUY,0,Time[1],High[1]);
}

if(Close[1]>Open[1])                                                             //Typ 4.rastúci
 if((Open[1]-Low[1])>(High[1]-Open[1]))                                          //51% podmienka
  if((High[2]>=Close[1])&&(High[2]>=Open[1])&&(Low[2]<=Close[1])&&(Low[2]<=Open[1]))   //telo vedľa
  
{
ObjectCreate("obesenec4",OBJ_ARROW_BUY,0,Time[1],High[1]);
}
}
 
obchodnik123:

Hello!

A total MQL programming newbie here. I decided to create my first custom indicator in MQL4 based on pin bars. When i finished the writing and compiled the code everything was allright, but when i decided to use it on chart i got the message in expert chart:

An indicator does not use OnTick, it uses OnCalculate.

 

It seems that it got deinitialized some some reasons...

Keep in mind that you are creating object with always the same name, in case of object already exists you will have some issues.

It's better for you need to build a custom indicator for that, not an EA.