/*[[ Name := bullbear Author := Copyright © 2003, Company Link := http://www.company.com/ Lots := 1.00 Stop Loss := 30 Take Profit := 40 Trailing Stop := 5 ]]*/ //previous position var: pos1pre(0); //current position var: pos2cur(0); var: cnt(0); pos1pre = iBullsPower(13,PRICE_WEIGHTED,1); pos2cur = iBullsPower(13,PRICE_WEIGHTED,0); if pos1pre >pos2cur then { //close long position for cnt=1 to TotalTrades { If OrderValue(cnt,VAL_TYPE)=OP_BUY then // buy position open { if Bid>(OrderValue(cnt,VAL_OPENPRICE)+TrailingStop*Point) then { CloseOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_LOTS),Bid,3,Violet); // close long Exit; }; }; }; }; if pos2cur<0 then //close short position { for cnt=1 to TotalTrades { if Ask<(OrderValue(cnt,VAL_OPENPRICE)-TrailingStop*Point) then { If OrderValue(cnt,VAL_TYPE)=OP_SELL then // sell position open { CloseOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_LOTS),Ask,3,Violet); // close short Exit; }; }; }; }; If TotalTrades<1 then { //no current orders. Check for possible short conditions. print("pos1pre = "+pos1pre+" pos2cur ="+pos2cur); if pos1pre>pos2cur and pos2cur>0 then { SetOrder(OP_SELL,Lots,Bid,3,Bid+StopLoss,Bid-TakeProfit*Point,RED); // open short Exit; }; //check for long conditions. If pos2cur<0 then { SetOrder(OP_BUY,Lots,Ask,3,Ask-StopLoss,Ask+TakeProfit*Point,RED); // open long Exit; }; };