Download MetaTrader 5
To add comments, please log in or register
Add our Twitter channel to friends and follow the news!
Sven Hohmann
Sven Hohmann 2014.11.10 11:29 


Im new in MQL4 and i wrote a indicator with just global variables and int start() function. It works, but when i start the MT4 again the Indicator is dissapeared..

Which Code i need in my indicator that it is still in the Chart after New Starting MT4?


Keith Watford
Keith Watford 2014.11.10 11:40  

I am not sure whether you mean that the indicator has disappeared from the navigator window or that it is no longer attached to the chart.

You can check the Experts tab and see if there was a problem with the indicator on loading MT4.

Also, when you shut down your computer, make sure that you shut down MT4 first. If you don't, you may find that a lot of recent work has not been saved. 

SYED NAUFAL GADDAFI 2014.11.10 12:07  
Usually when any indicator or ea disappear when starting terminal, most likely there is error occurs during initialization which leads to de-attachment.
whroeder1 2014.11.10 12:15  
tools -> options -> server -> Keep personal settings = checked
SYED NAUFAL GADDAFI 2014.11.10 13:02  
Check the Journal tab and see if any errors. Please also edit your post and use SRC (besides video icon) when posting codes.
Sven Hohmann
Sven Hohmann 2014.11.10 13:13  
The indicator works and there is no Error after Compiling; it isnt in the chart any more after i closed the terminal and started MT4 again.  At the moment i have to put it every time again on the chart..

The Code is this:

//Screener Hammer & Shooting Star
extern double Docht = 0.00015;
extern double Lunte = 0.00025;
extern double Koerper = 0.00015;

extern double Impuls_Long = 0.0008;
extern double Impuls_Short = 0.0008;
extern int sec = 3;

//Timeframe des Signals
extern int Timeframe = PERIOD_M5;

int start()                      

//Screener Hammer & Shooting Star
   double  F0;
   double  C0;
   double  D0;
   double  E0;
   double E00;
   double D00;
   double  F1;
   double  C1;
   double  D1;
   double  E1;
   double E11;
   double D11;
   double  F2;
   double  C2;
   double  D2;
   double  E2;
   double E22;
   double D22;
   double  F3;
   double  C3;
   double  D3;
   double  E3;
   double E33;
   double D33;
   double  F4;
   double  C4;
   double  D4;
   double  E4;
   double E44;
   double D44;
   double  F5;
   double  C5;
   double  D5;
   double  E5;
   double E55;
   double D55;
        F0 = iClose("EURUSD",Timeframe,1);
        C0 = iOpen("EURUSD",Timeframe,1);
        D0 = iHigh("EURUSD",Timeframe,1);
        E0 = iLow("EURUSD",Timeframe,1);
        E00 = iLow("EURUSD",Timeframe,2);
        D00 = iHigh("EURUSD",Timeframe,2);
        F1 = iClose("GBPUSD",Timeframe,1);
        C1 = iOpen("GBPUSD",Timeframe,1);
        D1 = iHigh("GBPUSD",Timeframe,1);
        E1 = iLow("GBPUSD",Timeframe,1);
        E11 = iLow("GBPUSD",Timeframe,2);
        D11 = iHigh("GBPUSD",Timeframe,2);
        F2 = iClose("EURJPY",Timeframe,1);
        C2 = iOpen("EURJPY",Timeframe,1);
        D2 = iHigh("EURJPY",Timeframe,1);
        E2 = iLow("EURJPY",Timeframe,1);
        E22 = iLow("EURJPY",Timeframe,2);
        D22 = iHigh("EURJPY",Timeframe,2);
        F3 = iClose("USDJPY",Timeframe,1);
        C3 = iOpen("USDJPY",Timeframe,1);
        D3 = iHigh("USDJPY",Timeframe,1);
        E3 = iLow("USDJPY",Timeframe,1);
        E33 = iLow("USDJPY",Timeframe,2);
        D33 = iHigh("USDJPY",Timeframe,2);
        F4 = iClose("EURAUD",Timeframe,1);
        C4 = iOpen("EURAUD",Timeframe,1);
        D4 = iHigh("EURAUD",Timeframe,1);
        E4 = iLow("EURAUD",Timeframe,1);
        E44 = iLow("EURAUD",Timeframe,2);
        D44 = iHigh("EURAUD",Timeframe,2);
        F5 = iClose(".JAPANCash",Timeframe,1);
        C5 = iOpen(".JAPANCash",Timeframe,1);
        D5 = iHigh(".JAPANCash",Timeframe,1);
        E5 = iLow(".JAPANCash",Timeframe,1);
        E55 = iLow(".JAPANCash",Timeframe,2);
        D55 = iHigh(".JAPANCash",Timeframe,2);

       if((TimeCurrent()-300-iTime("EURUSD",PERIOD_M5,1)<sec) && ((C0/E0)-1>=Lunte) && ((D0/F0)-1<=Docht) && ((F0/C0)-1<=Koerper) && (E00>E0)) Alert ("EURUSD:Hammer:Grün");          
       if((TimeCurrent()-300-iTime("EURUSD",PERIOD_M5,1)<sec) && ((F0/E0)-1>=Lunte) && ((D0/C0)-1<=Docht) && ((C0/F0)-1<=Koerper) && (E00>E0)) Alert ("EURUSD:Hammer:Rot");         
       if((TimeCurrent()-300-iTime("EURUSD",PERIOD_M5,1)<sec) && ((D0/F0)-1>=Lunte) && ((C0/E0)-1<=Docht) && ((F0/C0)-1<=Koerper) && (D00<D0)) Alert ("EURUSD:Shooting Star:Grün");   //EURUSD
       if((TimeCurrent()-300-iTime("EURUSD",PERIOD_M5,1)<sec) && ((D0/C0)-1>=Lunte) && ((F0/E0)-1<=Docht) && ((C0/F0)-1<=Koerper) && (D00<D0)) Alert ("EURUSD:Shooting Star:Rot");
       if((TimeCurrent()-300-iTime("GBPUSD",PERIOD_M5,1)<sec) && ((C1/E1)-1>=Lunte) && ((D1/F1)-1<=Docht) && ((F1/C1)-1<=Koerper) && (E11>E1)) Alert ("GBPUSD:Hammer:Grün");          
       if((TimeCurrent()-300-iTime("GBPUSD",PERIOD_M5,1)<sec) &&((F1/E1)-1>=Lunte) && ((D1/C1)-1<=Docht) && ((C1/F1)-1<=Koerper) && (E11>E1)) Alert ("GBPUSD:Hammer:Rot");         
       if((TimeCurrent()-300-iTime("GBPUSD",PERIOD_M5,1)<sec) &&((D1/F1)-1>=Lunte) && ((C1/E1)-1<=Docht) && ((F1/C1)-1<=Koerper) && (D11<D1)) Alert ("GBPUSD:Shooting Star:Grün");   // GBPUSD
       if((TimeCurrent()-300-iTime("GBPUSD",PERIOD_M5,1)<sec) &&((D1/C1)-1>=Lunte) && ((F1/E1)-1<=Docht) && ((C1/F1)-1<=Koerper) && (D11<D1)) Alert ("GBPUSD:Shooting Star:Rot");
       if((TimeCurrent()-300-iTime("EURJPY",PERIOD_M5,1)<sec) &&((C2/E2)-1>=Lunte) && ((D2/F2)-1<=Docht) && ((F2/C2)-1<=Koerper) && (E22>E2)) Alert ("EURJPY:Hammer:Grün");          
       if((TimeCurrent()-300-iTime("EURJPY",PERIOD_M5,1)<sec) &&((F2/E2)-1>=Lunte) && ((D2/C2)-1<=Docht) && ((C2/F2)-1<=Koerper) && (E22>E2)) Alert ("EURJPY:Hammer:Rot");         
       if((TimeCurrent()-300-iTime("EURJPY",PERIOD_M5,1)<sec) &&((D2/F2)-1>=Lunte) && ((C2/E2)-1<=Docht) && ((F2/C2)-1<=Koerper) && (D22<D2)) Alert ("EURJPY:Shooting Star:Grün");   //EURJPY
       if((TimeCurrent()-300-iTime("EURJPY",PERIOD_M5,1)<sec) &&((D2/C2)-1>=Lunte) && ((F2/E2)-1<=Docht) && ((C2/F2)-1<=Koerper) && (D22<D2)) Alert ("EURJPY:Shooting Star:Rot");

       if((TimeCurrent()-300-iTime("USDJPY",PERIOD_M5,1)<sec) &&((C3/E3)-1>=Lunte) && ((D3/F3)-1<=Docht) && ((F3/C3)-1<=Koerper) && (E33>E3)) Alert ("USDJPY:Hammer:Grün");          
       if((TimeCurrent()-300-iTime("USDJPY",PERIOD_M5,1)<sec) &&((F3/E3)-1>=Lunte) && ((D3/C3)-1<=Docht) && ((C3/F3)-1<=Koerper) && (E33>E3)) Alert ("USDJPY:Hammer:Rot");         
       if((TimeCurrent()-300-iTime("USDJPY",PERIOD_M5,1)<sec) &&((D3/F3)-1>=Lunte) && ((C3/E3)-1<=Docht) && ((F3/C3)-1<=Koerper) && (D33<D3)) Alert ("USDJPY:Shooting Star:Grün");   //USDJPY
       if((TimeCurrent()-300-iTime("USDJPY",PERIOD_M5,1)<sec) &&((D3/C3)-1>=Lunte) && ((F3/E3)-1<=Docht) && ((C3/F3)-1<=Koerper) && (D33<D3)) Alert ("USDJPY:Shooting Star:Rot");

       if((TimeCurrent()-300-iTime("EURAUD",PERIOD_M5,1)<sec) &&((C4/E4)-1>=Lunte) && ((D4/F4)-1<=Docht) && ((F4/C4)-1<=Koerper) && (E44>E4)) Alert ("EURAUD:Hammer:Grün");          
       if((TimeCurrent()-300-iTime("EURAUD",PERIOD_M5,1)<sec) &&((F4/E4)-1>=Lunte) && ((D4/C4)-1<=Docht) && ((C4/F4)-1<=Koerper) && (E44>E4)) Alert ("EURAUD:Hammer:Rot");         
       if((TimeCurrent()-300-iTime("EURAUD",PERIOD_M5,1)<sec) &&((D4/F4)-1>=Lunte) && ((C4/E4)-1<=Docht) && ((F4/C4)-1<=Koerper) && (D44<D4)) Alert ("EURAUD:Shooting Star:Grün");   //EURAUD
       if((TimeCurrent()-300-iTime("EURAUD",PERIOD_M5,1)<sec) &&((D4/C4)-1>=Lunte) && ((F4/E4)-1<=Docht) && ((C4/F4)-1<=Koerper) && (D44<D4)) Alert ("EURAUD:Shooting Star:Rot");

       if((TimeCurrent()-300-iTime(".JAPAN.Cash",PERIOD_M5,1)<sec) &&((C5/E5)-1>=Lunte) && ((D5/F5)-1<=Docht) && ((F5/C5)-1<=Koerper) && (E55>E5)) Alert ("NIKKEI:Hammer:Grün");          
       if((TimeCurrent()-300-iTime(".JAPAN.Cash",PERIOD_M5,1)<sec) &&((F5/E5)-1>=Lunte) && ((D5/C5)-1<=Docht) && ((C5/F5)-1<=Koerper) && (E55>E5)) Alert ("NIKKEI:Hammer:Rot");         
       if((TimeCurrent()-300-iTime(".JAPAN.Cash",PERIOD_M5,1)<sec) &&((D5/F5)-1>=Lunte) && ((C5/E5)-1<=Docht) && ((F5/C5)-1<=Koerper) && (D55<D5)) Alert ("NIKKEI:Shooting Star:Grün");   //NIKKEI
       if((TimeCurrent()-300-iTime(".JAPAN.Cash",PERIOD_M5,1)<sec) &&((D5/C5)-1>=Lunte) && ((F5/E5)-1<=Docht) && ((C5/F5)-1<=Koerper) && (D55<D5)) Alert ("NIKKEI:Shooting Star:Rot");


   double  FF0;
   double  CC0;
   double  FF1;
   double  CC1;
   double  FF2;
   double  CC2;
   double  FF3;
   double  CC3;
   double  FF4;
   double  CC4;
   double  FF5;
   double  CC5;  
        FF0 = iClose("EURUSD",Timeframe,1);
        CC0 = iOpen("EURUSD",Timeframe,1);
        FF1 = iClose("USDJPY",Timeframe,1);
        CC1 = iOpen("USDJPY",Timeframe,1);
        FF2 = iClose("EURJPY",Timeframe,1);
        CC2 = iOpen("EURJPY",Timeframe,1);
        FF3 = iClose("GBPUSD",Timeframe,1);
        CC3 = iOpen("GBPUSD",Timeframe,1);
        FF4 = iClose("EURAUD",Timeframe,1);
        CC4 = iOpen("EURAUD",Timeframe,1);
        FF5 = iClose(".JAPANCash",Timeframe,1);
        CC5 = iOpen(".JAPANCash",Timeframe,1);
       if((TimeCurrent()-300-iTime("EURUSD",PERIOD_M5,1)<sec) &&(FF0/CC0)-1>=  Impuls_Long ) Alert("EURUSD:Impuls Long; Bewegung entsteht!");
       if((TimeCurrent()-300-iTime("EURUSD",PERIOD_M5,1)<sec) &&(CC0/FF0)-1>= Impuls_Short ) Alert("EURUSD:Impuls Short;Bewegung entsteht!");  
       if((TimeCurrent()-300-iTime("USDJPY",PERIOD_M5,1)<sec) &&(FF1/CC1)-1>=  Impuls_Long ) Alert("USDJPY:Impuls Long; Bewegung entsteht!");
       if((TimeCurrent()-300-iTime("USDJPY",PERIOD_M5,1)<sec) &&(CC1/FF1)-1>= Impuls_Short ) Alert("USDJPY:Impuls Short;Bewegung entsteht!");  
       if((TimeCurrent()-300-iTime("EURJPY",PERIOD_M5,1)<sec) &&(FF2/CC2)-1>=  Impuls_Long ) Alert("EURJPY:Impuls Long; Bewegung entsteht!");
       if((TimeCurrent()-300-iTime("EURJPY",PERIOD_M5,1)<sec) &&(CC2/FF2)-1>= Impuls_Short ) Alert("EURJPY:Impuls Short;Bewegung entsteht!");  
       if((TimeCurrent()-300-iTime("GBPUSD",PERIOD_M5,1)<sec) &&(FF3/CC3)-1>=  Impuls_Long ) Alert("GBPUSD:Impuls Long; Bewegung entsteht!");
       if((TimeCurrent()-300-iTime("GBPUSD",PERIOD_M5,1)<sec) &&(CC3/FF3)-1>= Impuls_Short ) Alert("GBPUSD:Impuls Short;Bewegung entsteht!");  
       if((TimeCurrent()-300-iTime("EURAUD",PERIOD_M5,1)<sec) &&(FF4/CC4)-1>=  Impuls_Long ) Alert("EURAUD:Impuls Long; Bewegung entsteht!");
       if((TimeCurrent()-300-iTime("EURAUD",PERIOD_M5,1)<sec) &&(CC4/FF4)-1>= Impuls_Short ) Alert("EURAUD:Impuls Short;Bewegung entsteht!");  
       if((TimeCurrent()-300-iTime(".JAPANCash",PERIOD_M5,1)<sec) &&(FF5/CC5)-1>=  Impuls_Long ) Alert("NIKKEI:Impuls Long; Bewegung entsteht!");
       if((TimeCurrent()-300-iTime(".JAPANCash",PERIOD_M5,1)<sec) &&(CC5/FF5)-1>= Impuls_Short ) Alert("NIKKEI:Impuls Short;Bewegung entsteht!");         
   //PivotPoint-Bounce Signal
   double H0;
   double L0;
   double PP0;
   double H1;
   double L1;
   double PP1;
   double H2;
   double L2;
   double PP2;
   double H3;
   double L3;
   double PP3;
   double H4;
   double L4;
   double PP4;
   double H5;
   double L5;
   double PP5;
   H0 = iHigh("EURUSD",Timeframe,1);
   L0 = iLow("EURUSD",Timeframe,1);
   PP0 = (iClose("EURUSD",1440,1)+iLow("EURUSD",1440,1)+iHigh("EURUSD",1440,1))/3;
   H1 = iHigh("GBPUSD",Timeframe,1);
   L1 = iLow("GBPUSD",Timeframe,1);
   PP1 = (iClose("GBPUSD",1440,1)+iLow("GBPUSD",1440,1)+iHigh("GBPUSD",1440,1))/3;
   H2 = iHigh("USDJPY",Timeframe,1);
   L2 = iLow("USDJPY",Timeframe,1);
   PP2 = (iClose("USDJPY",1440,1)+iLow("USDJPY",1440,1)+iHigh("USDJPY",1440,1))/3;
   H3 = iHigh("EURJPY",Timeframe,1);
   L3 = iLow("EURJPY",Timeframe,1);
   PP3 = (iClose("EURJPY",1440,1)+iLow("EURJPY",1440,1)+iHigh("EURJPY",1440,1))/3;
   H4 = iHigh("EURAUD",Timeframe,1);
   L4 = iLow("EURAUD",Timeframe,1);
   PP4 = (iClose("EURAUD",1440,1)+iLow("EURAUD",1440,1)+iHigh("EURAUD",1440,1))/3;
   H5 = iHigh(".JAPANCash",Timeframe,1);
   L5 = iLow(".JAPANCash",Timeframe,1);
   PP5 = (iClose(".JAPANCash",1440,1)+iLow(".JAPANCash",1440,1)+iHigh(".JAPANCash",1440,1))/3;
   if((TimeCurrent()-300-iTime("EURUSD",PERIOD_M5,1)<sec) && H0>PP0 && L0<PP0) Alert("EURUSD am Daily Pivot");
   if((TimeCurrent()-300-iTime("GBPUSD",PERIOD_M5,1)<sec) && H1>PP1 && L1<PP1) Alert("GBPUSD am Daily Pivot");
   if((TimeCurrent()-300-iTime("USDJPY",PERIOD_M5,1)<sec) && H2>PP2 && L2<PP2) Alert("USDJPY am Daily Pivot");
   if((TimeCurrent()-300-iTime("EURJPY",PERIOD_M5,1)<sec) && H3>PP3 && L3<PP3) Alert("EURJPY am Daily Pivot");
   if((TimeCurrent()-300-iTime("EURAUD",PERIOD_M5,1)<sec) && H4>PP4 && L4<PP4) Alert("EURAUD am Daily Pivot");
   if((TimeCurrent()-300-iTime(".JAPANCash",PERIOD_M5,1)<sec) && H5>PP5 && L5<PP5) Alert("NIKKEI am Daily Pivot");
    //Textlabel auf dem Chart

//ObjectCreate("LabelName", OBJ_LABEL, 0, 0, 0);
//ObjectSetText("LabelName", "se: "+se+"", 20, "Arial", White);
//ObjectSet("LabelName", OBJPROP_CORNER, 0);
//ObjectSet("LabelName", OBJPROP_XDISTANCE, 50);
//ObjectSet("LabelName", OBJPROP_YDISTANCE, 50);
Carl Schreiber
Carl Schreiber 2014.11.10 21:38  

As far as I have understood you deleted init() - correct?

Have you tried your indicator with int init(){.. - if you don't need it, leave it empty except the return(0)?

Sven Hohmann
Sven Hohmann 2014.11.11 09:54  

I never used a init() function; Im new in MQL4 and I just know that the start() function is important.

You mean I should use the init for the start function? I Changed it, but it still doesnt work . How the code is changed?

Sven Hohmann
Sven Hohmann 2014.11.11 10:38  
#property indicator_separate_window

is all what is needed...

To add comments, please log in or register