Negative Buy trades being returned

 

Hi, I am writing an expert advisor. The problem I have is that on Strategy Tester, SELL trades are positive, which is correct, but the BUY trades are all negative. That is across over 700 trades. All trades should result in at least a $5 profit. All small profits are disregarded.

Can anyone help ? 

 
grahambl: Can anyone help ? 

Do you really expect an answer? There are no mind readers here and our crystal balls are cracked. Always post all relevant code (using Code button) or attach the source file.
     How To Ask Questions The Smart Way. (2004)
          Be precise and informative about your problem

We can't see your broken code.

 
William Roeder #:

Do you really expect an answer? There are no mind readers here and our crystal balls are cracked. Always post all relevant code (using Code button) or attach the source file.
     How To Ask Questions The Smart Way. (2004)
          Be precise and informative about your problem

We can't see your broken code.

 Please find attached the BUY coding.

Files:
 

Forum on trading, automated trading systems and testing trading strategies

When you post code please use the CODE button (Alt-S)!

Use the CODE button


 
Sergey Golubev #:

Sorry about that, I will do it properly now.

if((Open[0]>=Open[1]))

{ GetNextBuy(); CompleteBuy(); }

void GetNextBuy()
{
            RefreshRates();     
            Lots = AutoLotSize();
            result=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,0,0,"BFG EA",MagicNumber,0,Blue);
//
//                                                             If there was an error, log it.
//                                            
            if(result < 0)Print("ERROR - Unable to access the order - ", OrderTicket(), " - ", GetLastError());  


                                                                                   // If there was an error, log it.
            if (result < 0) Print("ERROR - Unable to access order - ", ticket, " - ", GetLastError());
//
}

void CompleteBuy() { if(result>=0) { TheStopLoss=0; TheTakeProfit=0; if(TakeProfit>0) TheTakeProfit=Ask-TakeProfit*MyPoint; if(StopLoss>0) TheStopLoss=Ask+StopLoss*MyPoint; OrderSelect(result,SELECT_BY_TICKET); OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green); } return; }