pls help !!! my ea open only sell order - page 2

 
MrLets:

PLease help on the above buy condition. My EA only opens sell


Thank you

I don't find about sell order.

if (true)

    ticket = OrderSend(Symbol(), OP_BUY, BuyLots12, Ask, BuySlippage12, 0, 0, BuyExpertName12, 1, 0, Blue);

    else

    ticket = OrderSend(Symbol(), OP_BUY, BuyLots12, Ask, BuySlippage12, SL, TP, BuyExpertName12, 1, 0, Blue);

Is it typo?


I think 


First, typo.

Second, true is a constant. "if (true)" is always true condition. 

 
Hey guys. I have been struggling with the following code for days. 
1. It was opening trades and closing them immediately, on Journal it says closed by tester. 
2. Then played around with it, then suddenly only opening sell trades only.

I would also like to have it making trades at other times not 00h00. 

Thanks for the help 
Files:
 
Mzantsi:
Hey guys. I have been struggling with the following code for days. 
1. It was opening trades and closing them immediately, on Journal it says closed by tester. 
2. Then played around with it, then suddenly only opening sell trades only.

I would also like to have it making trades at other times not 00h00. 

Thanks for the help 

You have TP set to 0 points - that is causing trades to close immediately. If you want other hours just change 0 to something you want.

if(Hour()== 0)
 
Marcin Madrzak:

You have TP set to 0 points - that is causing trades to close immediately. If you want other hours just change 0 to something you want.

TP set to zero means that there is no TP.

Same for SL

 
Marcin Madrzak:

You have TP set to 0 points - that is causing trades to close immediately. If you want other hours just change 0 to something you want.

I have looked at the code now and I guess that you may have meant that the input TakeProfit is set at zero

The code should be modified to allow for inputs set at zero.

         if(Close[1]<Open[1])
           {
            double tp=0;
            if(TakeProfit>0)
               tp=Bid+TakeProfit*Point;
            double sl=0;
            if(StopLoss>0)
               sl=Bid-StopLoss*Point;
            ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,10,sl,tp,"Set by Open Close System");
            if(ticket<0)
               Alert("Error Sending Buy Order!");
           }
         else
           {
            double tp=0;
            if(TakeProfit>0)
               tp=Ask-TakeProfit*Point;
            double sl=0;
            if(StopLoss>0)
               sl=Ask+StopLoss*Point;
            ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,10,sl,tp,"Set by Open Close System");
            if(ticket<0)
               Alert("Error Sending Sell Order!");
           }