how to add indicator code into expertadvisor code ?? - page 5

 

i can post,

but please help me to finish my project.

ok ?

 

my project just a MA program, and trying to add zigzag into it.

 
albert_lim83:

i can post,

but please help me to finish my project.

ok ?

No promises from me, but when this finish you should say Big Thanks to RaptorUK, who helps you this far :)
 
albert_lim83:

i can post,

but please help me to finish my project.

ok ?

Without seeing your full code it's hard to tell you what is causing . . . . " ExistPositions - expression on global scope not allowed " if you don't want to post your full code then don't, but you will get more accurate advice if we can see the problem instead of guessing, and that means less work for everyone.
 
Why don't you attach that instead :)
 

so far i backtest from year 1970 till today,

the result is burned account.

 

OK . . . some comments . . .

      for(shift=Bars-1; shift>=0; shift--)   //  <-----  this loop does nothing at all ! !

      double ZigZagHigh=iCustom(NULL,0,"ZigZag",MODE_HIGH,0);
      double ZigZagLow=iCustom(NULL,0,"ZigZag",MODE_LOW,0);    
      double LowestBar=Low[Lowest(NULL,0,MODE_LOW,ExtDepth,sh

. . .

   bool a=false, b=false;                                  //  Note:  b is a bool . . .
   int shift, BlueArrowIndex, RedArrowIndex, Index = 0;
   double zag, zig; b=0; 
   
   while(a<2) 
      {
      if(zig>0) zag=zig;
      zig=iCustom(NULL, 0, "ZigZag", 0, b);
      if(zig>0) a+=1;
      b++;                                                 //  how can you increment a bool ??

. . .

      if(AccountFreeMargin()<(SafetyPercent/100)*AccountBalance())
         {
         Print("We have no money. Free Margin = ", AccountFreeMargin());
         return(0);
         }
      }
   }                             //  <-----  this is the closing brace of start()
  
 if (!ExistPositions()){         // <-----  so this give this error  'ExistPositions' - expression on global scope not allowed

      if(diClose0<diMA1 && (ZigZagLow) )
      {
         OpenBuy();
         return(0);
 
if(zig>0) {a += 1; b += 1;}

Put this one step up

    
    
    

  // <<=== ... here                   
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
if(!ExistPositions())  // <<<==== This goes one step up ....
  {

   if(diClose0<diMA1 && (ZigZagLow))
     {
      OpenBuy();
      return(0);
     }
   else //
     {
      if(diClose2>diMA3 && (ZigZagHigh))
        {
         OpenSell();
         return(0);
        }
     }

  }
 

i trying to modify escape ea.

so i just use all the code inside it.

 
albert_lim83:

i trying to modify escape ea.

so i just use all the code inside it.

You need to understand what you are doing if you want it to work . . . you can't just copy & paste here and there . . . you need to learn.
Reason: