Need guidance for indicator. Tried google for answers but couldn't get

 
Hi,

First of all would like to appologies that i posted here in MQL5 Indicator instead of MQL4 indicator. For unknown reason i couldn't enter the MQL4. everytime i login, it will refresh and change to MQL5. Hope admin could move this thread to MQL4.

I have posted before but with less details. so here i am posting with details. i will try my best to explain

      double MA5H=iMA(_Symbol,PERIOD_M15,5,0,MODE_LWMA,PRICE_HIGH,i+1);
      double MA10H=iMA(_Symbol,PERIOD_M15,10,0,MODE_LWMA,PRICE_HIGH,i+1);
      double MA5L=iMA(_Symbol,PERIOD_M15,5,0,MODE_LWMA,PRICE_LOW,i+1);
      double MA10L=iMA(_Symbol,PERIOD_M15,10,0,MODE_LWMA,PRICE_LOW,i+1);
      double MA20=iMA(_Symbol,PERIOD_M15,20,0,MODE_SMA,PRICE_CLOSE,i+1);
      double CLOSE=iClose(_Symbol,PERIOD_M15,i+1);
      double OPEN=iOpen(_Symbol,PERIOD_M15,i+1);
      double HIGH=iHigh(_Symbol,PERIOD_M15,i+1);
      double LOW=iLow(_Symbol,PERIOD_M15,i+1);
      double TREND=iMA(_Symbol,PERIOD_M15,800,0,MODE_EMA,PRICE_CLOSE,i+1);
      
      double CLOSEh1=iClose(_Symbol,PERIOD_H1,i+1);
      double OPENh1=iOpen(_Symbol,PERIOD_H1,i+1);
      double MA5Hh1=iMA(_Symbol,PERIOD_H1,5,0,MODE_LWMA,PRICE_HIGH,i+1);
      double MA10Hh1=iMA(_Symbol,PERIOD_H1,10,0,MODE_LWMA,PRICE_HIGH,i+1);
      double MA5Lh1=iMA(_Symbol,PERIOD_H1,5,0,MODE_LWMA,PRICE_LOW,i+1);
      double MA10Lh1=iMA(_Symbol,PERIOD_H1,10,0,MODE_LWMA,PRICE_LOW,i+1);
      double MA20h1=iMA(_Symbol,PERIOD_H1,20,0,MODE_SMA,PRICE_CLOSE,i+1);

      if(CLOSEh1<MA5Lh1 && CLOSEh1<MA10Lh1 && CLOSEh1<MA20h1 && OPENh1>MA5Lh1 && OPENh1>MA10Lh1 && OPENh1>MA20h1 && HIGHh1<TRENDh1 && LOWh1<TRENDh1) &&
         CLOSE<MA5L && CLOSE<MA10L && CLOSE<MA20 && OPEN>MA5L && OPEN>MA10L && OPEN>MA20 && HIGH<TREND && LOW<TREND)
           {mess_data[k][j]="C";mess_color[k][j]=clrRed;           
            if(k>0 && !alert[k][j])
           {
            Alert(pair[k]," ","M15 CSAK DOWNTREND");
            SendNotification(pair[k]+"M15 CSAK DOWNTREND");
            alert[k][j]=true;
           }

            }
      if(CLOSEh1>MA5Hh1 && CLOSEh1>MA10Hh1 && CLOSEh1>MA20h1 && OPENh1<MA5Hh1 && OPENh1<MA10Hh1 && OPENh1<MA20h1 && HIGHh1>TRENDh1 && LOWh1>TRENDh1) &&
         CLOSE>MA5H && CLOSE>MA10H && CLOSE>MA20 && OPEN<MA5H && OPEN<MA10H && OPEN<MA20 && HIGH>TREND && LOW>TREND)
           {mess_data[k][j]="C";mess_color[k][j]=clrBlue;           
            if(k>0 && !alert[k][j])
           {
            Alert(pair[k]," ","M15 CSAK UPTREND");
            SendNotification(pair[k]+"M15 CSAK UPTREND");
            alert[k][j]=true;
           }
            }

So basically, above code is working just fine. What i'm trying to do which i couldn't get any answer is as below.

for this part,

i just give a name for each code to roughly understand..


for part of the code,

if(CLOSEh1<MA5Lh1 && CLOSEh1<MA10Lh1 && CLOSEh1<MA20h1 && OPENh1>MA5Lh1 && OPENh1>MA10Lh1 && OPENh1>MA20h1 && HIGHh1<TRENDh1 && LOWh1<TRENDh1) &&

will name it SELLH1

if(CLOSEh1>MA5Hh1 && CLOSEh1>MA10Hh1 && CLOSEh1>MA20h1 && OPENh1<MA5Hh1 && OPENh1<MA10Hh1 && OPENh1<MA20h1 && HIGHh1>TRENDh1 && LOWh1>TRENDh1) &&

will name it BUYH1

CLOSE<MA5L && CLOSE<MA10L && CLOSE<MA20 && OPEN>MA5L && OPEN>MA10L && OPEN>MA20 && HIGH<TREND && LOW<TREND)

will name it SELLM15

CLOSE>MA5H && CLOSE>MA10H && CLOSE>MA20 && OPEN<MA5H && OPEN<MA10H && OPEN<MA20 && HIGH>TREND && LOW>TREND)

----------------------------------------------------------------------

So here's the rules which i'm trying to set

IF SELLH1 appear followed by SELLM15, there will be alert or indications
but if SELLH1 appear followed by BUYH1 appear followed by SELLM15 appear, there won't be alert or indications.

this the rules which i'm trying to set buy can't get the answer. Hope people here could guide me if you don't mind.

Thank You

 

I have did the following for my EA. So i'm trying to do for my indicator. it works well for my EA. Maybe by looking at the code below for my EA you will understand better.

     if(EXTREMEBUY && GVGet("CHBUY")==1){GVSet("EXTREMEBUY",1);}  
     if(EXTREMESELL && GVGet("CHSELL")==1){GVSet("EXTREMESELL",1);} 

     if(BUYSL || BUYTP){GVSet("EXTREMEBUY",0);}  
     if(SELLSL || SELLTP){GVSet("EXTREMESELL",0);} 

     if(CBUY && GVGet("EXTREMEBUY")==1 && MaxOpenOrders > Orders(8) && CurrBar() && ClosedBar() && MarginCheck(0)) 
        {  
         int Ticket = OrderSend(Symbol(), OP_BUY, Lots(), Ask, Slippage*Pip, 0, 0, EAComment, MagicNumber, 0, clrBlue);
         err = GetLastError();if(err!=ERR_NO_ERROR){ Print("Error on Order open = ", ErrorDescription(err));}
         GVSet("buy",0);GVSet("sell",0);if(trigger) { alert(0, "Buy");trigger=false;}
         }       

 above is the rules for opening a buy. This what i manage to do for my EA. it's working fine. Thank You

Reason: