Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void OnTick() {
- RefreshRates();
- Print("--- tick ---");
- int ord = OrdersTotal();
- int err = 0;
- for(int i = (ord - 1); i >= 0; i--) {
- if ( !OrderSelect( i, SELECT_BY_POS ) ) {
- err = GetLastError();
- Alert( "OrderSelect( ", i, ", SELECT_BY_POS ) - Error #", err );
- continue;
- } else {
- string type = ((OrderType()) ? "Sell" : "Buy");
- Print(i,". ",type,"#",OrderTicket(),": TP = ",OrderTakeProfit());
- // if order type is buy and bid is below take profit
- if((OrderType() == 1) && (Bid <= OrderTakeProfit())) {
- //PlaySound("profit.wav");
- Alert("TP!");
- }
- // if order type is sell and bid is above take profit
- if((OrderType() == 0) && (Bid >= OrderTakeProfit())) {
- //PlaySound("profit.wav");
- Alert("TP!");
- }
- }
- }
- Print("Bid: ",Bid);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement