problems with the EA .

 
#include <IncludeExample.mqh>



/* External variables*/
extern int Slippage= 1;
extern int MagicNumber;
extern bool CheckOncePerBar = true;


/*Global*/ 
int BuyTicket;
int SellTicket;
int UseSlippage;
datetime CurrentTimeStamp;
double SUM;
double LotSize = 1;
double StopLoss;
double TakeProfit;



int deinit()
  {
 
   return(0);
  }

int start()
{  

                /* Execute on bar open*/
                if(CheckOncePerBar == true)
             {
                                int BarShift = 1;
                                if(CurrentTimeStamp != Time[0]) 
                                        {
                                                CurrentTimeStamp = Time[0];
                                        bool NewBar = true;
                                        }
                                else NewBar = false;
                        }
                else 
                        {
                                NewBar = true;
                                BarShift = 0;
                } 
                
                        /*Exp Moving Avg*/
                        double EMA = iMA(NULL,0,20,0,MODE_EMA,0,BarShift);
                                                
          /*Calculate StopLoss*/
        int LowestShift = iLowest(NULL,0,MODE_LOW,4,0);
        StopLoss = Low[LowestShift];

      
        /*Calculate TakePorfit*/
         int HighestShift = iHighest(NULL,0,MODE_HIGH,9,0);
        TakeProfit = High[HighestShift];

                   /*risk menager*/
         double profit = TakeProfit - Bid ;
         double lose = Ask - StopLoss;
         SUM = lose / profit;           
         
                /* Begin trade block*/
                if(NewBar == true && SUM <= 1.2)
        
                          
                
                                /* Buy order*/ 
                                if(****/*check some terms*/*** && BuyMarketCount(Symbol(),MagicNumber) == 0)
                                
                                        {
                                                /* Close sell orders*/
                                                if(SellMarketCount(Symbol(),MagicNumber) > 0)
                                                        { 
                                                                CloseAllSellOrders(Symbol(),MagicNumber,Slippage);
                                                        }

                                                /* Open buy order*/
                                                BuyTicket = OpenBuyOrder(Symbol(),LotSize,UseSlippage,MagicNumber);
                                        
                                                /* Order modification*/
                                                if(BuyTicket > 0 && (StopLoss > 0 || TakeProfit > 0))
                                                        {
                                                                // Add stop loss and take profit
                                                                AddStopProfit(BuyTicket,StopLoss,TakeProfit);
                                                  }  
                                        }
                
                                   RefreshRates ();     
                                return(0);
                        }
        

The functions are in include file.

Also i couldnt see the Arrow on the visual graph at BackTesting,

Which script canceling StopLoss\TP  since one of the has been fiiled ? 

In order im not sure that my RiskManger and the using with Array in takeprofit\StopLoss is fine (efficient\write correct) 

the compilor didnt make any problem with the syntax buy im affrid there are problems with the program

May anyone help me ? i'm new at EA . 

Thanks!!! 

 
vushel:

The functions are in include file.

Also i couldnt see the Arrow on the visual graph at BackTesting,

Which script canceling StopLoss\TP  since one of the has been fiiled ? 

In order im not sure that my RiskManger and the using with Array in takeprofit\StopLoss is fine (efficient\write correct) 

the compilor didnt make any problem with the syntax buy im affrid there are problems with the program

May anyone help me ?

  1. Which you didn't post. No mind-readers here.
  2. What arrow are you talking about. No mind-readers here.
  3. You didn't post any scripts. No mind-readers here.
  4. Which you didn't post. No mind-readers here.
  5. Not a question.
  6. Fix your indenting. Check your return values. Post/attach your code. Ask a specific question(s) not vague statements.
 
WHRoeder:
  1. Which you didn't post. No mind-readers here.
  2. What arrow are you talking about. No mind-readers here.
  3. You didn't post any scripts. No mind-readers here.
  4. Which you didn't post. No mind-readers here.
  5. Not a question.
  6. Fix your indenting. Check your return values. Post/attach your code. Ask a specific question(s) not vague statements.

when i'm talking about "arrow" , i mean the arrow that's show buy\sell order execution .

thos script write correct ? (the using with Arrays and lose\profit function)

       /*Calculate StopLoss*/
        int LowestShift = iLowest(NULL,0,MODE_LOW,4,0);
        StopLoss = Low[LowestShift];

      
        /*Calculate TakePorfit*/
         int HighestShift = iHighest(NULL,0,MODE_HIGH,9,0);
        TakeProfit = High[HighestShift];

                   /*risk menager*/
         double profit = TakeProfit - Bid ;
         double lose = Ask - StopLoss;
         SUM = lose / profit;           
         
                /* Begin trade block*/
                if(NewBar == true && SUM <= 1.2)
Files:
 
vushel: when i'm talking about "arrow" , i mean the arrow that's show buy\sell order execution .
Those arrows come from some indicator, nothing to do with open orders. Tester arrows look like this
Reason: