breakout price and stop order in EA

 

Hello,

I open the order based on Richard Donchian 4 weeks high/low on weekly chart

Can I place buy/sell stop entry order?

or how to place order at exact the breakout point, which can be used for back test.

Any sample code?

I used Bid/Ask price comparing to 4 weeks high/low to determine the break out point.

However, I got lots of order close error 131 during EA test.

Here pasted my code:

//--- sell conditions, prev_low is the previous 4 weeks low

   if((Bid <= prev_low))

     {

      res=OrderSend(Symbol(),OP_SELL,LotsOptimized(),Bid,3,0,0,"",MAGICMA,0,Red);

      return;

     }

//--- buy conditions, prev_high is the previous 4 weeks high

   if((Ask>=prev_high))

     {

      res=OrderSend(Symbol(),OP_BUY,LotsOptimized(),Ask,3,0,0,"",MAGICMA,0,Blue);

      return;

     }



Thanks,

Albert