Why can't I attach this EA to a chart?

 

Dear all

 

When I try to drag this EA to EURUSD M5 chart or choose "Attach to a chart" command, MT4 just gave me no response. 

 

Does anybody know why?

 

Thanks for your kind help!

 

wing 

 

int old_tt1, old_tt2, old_tt3;
double old_bid1, old_bid2, old_bid3;
datetime time, time1;
int signal_up;

int start()
  {
   int    counted_bars=IndicatorCounted();
//----
   int start=GetTickCount();

   double a = MarketInfo("EURUSD",MODE_BID);
   
   if( signal_up == 0 )
   {
      if( a > iBands(NULL,5,20,1,0,0,MODE_UPPER,0) )
      {
         if( a < old_bid1 && old_bid1 < old_bid2 && old_bid2 < old_bid3 && old_bid3 != 0 )
         {
            if( start - old_tt1 == 0 && old_tt1 - old_tt2 == 0 && old_tt2 - old_tt3 == 0 )
            {
               signal_up = 1; 
               time = iTime(NULL,1,0);
            }
         }
      }
   }
   
   if( signal_up == 1 )
   {
      if( a < old_bid1 && old_bid1 < old_bid2 && old_bid2 < old_bid3 && old_bid3 != 0 )
      {
         if( start - old_tt1 == 0 && old_tt1 - old_tt2 == 0 && old_tt2 - old_tt3 == 0 )
         {
            if( iTime(NULL,1,0) > time && iTime(NULL,1,0) <= (time+1*60*2) )
            {
               signal_up = 2;
            }
         }
      }
   }
   
   if( signal_up > 0 && a > 50*Point )  { signal_up = 0; }
   if( signal_up > 0 && a < 50*Point )  { signal_up = 0; }

   old_tt3 = old_tt2;
   old_bid3 = old_bid2;
   
   old_tt2 = old_tt1;
   old_bid2 = old_bid1;
   
   old_tt1 = start;
   old_bid1 = a;
   
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
 
wing:


When I try to drag this EA to EURUSD M5 chart or choose "Attach to a chart" command, MT4 just gave me no response. 



I'm sorry to say but I have to say  There is nothing inside this coding where the EA has to do giving some kind of output

The only output it might can give is a smile face  and  EAname   load successful

 

It looks like you still have to learn how to program

 for example

  if( signal_up > 0 && a > 50*Point )  { signal_up = 0; }
  if( signal_up > 0 && a < 50*Point )  { signal_up = 0; }

 i can tell you that 'a' will never be < 50*Point  it is always > 50*Point

it has no sense to compare 4 following Bid prices the way you do  

and why do you not use TimeCurrent() instead of   iTime(NULL,1,0); 

 

if someone has to guide you step by step then it will take lot of time

this moment i am teaching that way  at   Jobs a client 

with help of teamviewer and skype you can communicate directly 

maybe you need someone to guide you the same way....

 

and if you ask me to do it that way then i wanna be paid like other client is doing

and your english has to be good enough to communicate  So that has to be the first to be checked

before i start with you a job 

 

otherwise take a easie short program that is working and try to understand every line inside of the code 

check all commands what it is doing

Make use of 

PrintAlert and Comment  to see what happens 

 
wing:

Dear all

 

When I try to drag this EA to EURUSD M5 chart or choose "Attach to a chart" command, MT4 just gave me no response. 

 

Does anybody know why?

 

Thanks for your kind help!

 

wing 

 

hi' can you add the full header of the script?

 
wing:

Dear all

 When I try to drag this EA to EURUSD M5 chart or choose "Attach to a chart" command, MT4 just gave me no response. 

Does anybody know why? 

It's not an EA,  you cannot use Indicator functions in an EA.
 
RaptorUK:
It's not an EA,  you cannot use Indicator functions in an EA.

might be you right about that
but it will load like an EA  giving a smiling face if you do attach it on your chart
 

deVries,

 

logic is not relevant in this case, but thanks for your advice.

 

RaptorUK,

 

by luck, I finally find out the solution.  It is because of a line which I missed when I posted my code here last time: 

 

#property indicator_chart_window

 

After I deleted this line, I can add the EA to the chart.

 

Thanks for your advice. 

 

cubye,

 

Thanks for your kind help too! 

 

wing  

We all replied on your code first message 

in that code you showed there was no line attached

#property indicator_chart_window

 It is this function IndicatorCounted   I think RaptorUK was talking about

int    counted_bars=IndicatorCounted();

 that doesn't belong inside your EA

 
deVries:

wing  

We all replied on your code first message 

in that code you showed there was no line attached

 It is this function IndicatorCounted   I think RaptorUK was talking about

 that doesn't belong inside your EA

 


Yes, that's why I said I "miss" it.

 

and if I was not lucky (and continue to did try and error), I will never know the solution.

 

anyway, thanks again for your advice.

Reason: