//+------------------------------------------------------------------+ //| OpenTiks.mq4 | //| Copyright © 2008, ZerkMax | //| | //+------------------------------------------------------------------+ #property copyright "Copyright © 2008, befi" extern int StopLoss = 7; extern double Lots = 0.2; extern int magicnumber = 777; extern int MaxOrders = 1; extern bool ContinueTrading=true; int prevtime,total, OrderCnt, ticket; double iBuyPrice, iSellPrice; bool closing = true; bool Enter = true; color Color=CLR_NONE; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- Print("Total Pending Orders (start): ", GetTotalPendingOrders()); } int GetTotalPendingOrders() { int iCounter = 0; int iSelectedOrderType = 0; int iPendingOrders = 0; for(iCounter = 0; iCounter < OrdersTotal(); iCounter++) { if ( OrderSelect(iCounter, SELECT_BY_POS, MODE_TRADES) == true ) { iSelectedOrderType = OrderType(); if ( iSelectedOrderType == OP_BUYLIMIT || iSelectedOrderType == OP_BUYSTOP || iSelectedOrderType == OP_SELLLIMIT || iSelectedOrderType == OP_SELLSTOP ) { // iPendingOrders = iPendingOrders + 1; } } else { Print("Unable to select order: ", iCounter); } } // Create some Orders { double iBuyPrice = 0; double iSellPrice = 0; iBuyPrice = Ask; iSellPrice = Bid; iBuyPrice = iBuyPrice - 0.0005; iSellPrice = iSellPrice + 0.0005; // OrderSend(Symbol(), OP_BUYLIMIT, 0.1, iBuyPrice, 4, 0, 0, "", 123456789, 0 ,Blue); OrderSend(Symbol(), OP_BUYLIMIT, 0.1, iBuyPrice, 4, 0, 0, "", magicnumber, 0 ,Blue); // OrderSend(Symbol(), OP_SELLLIMIT, 0.1, iSellPrice, 4, 0, 0, "", 123456789, 0 ,Blue); OrderSend(Symbol(), OP_SELLLIMIT, 0.1, iSellPrice, 4, 0, 0, "", magicnumber, 0 ,Blue); iBuyPrice = iBuyPrice - 0.0003; iSellPrice = iSellPrice + 0.0003; OrderSend(Symbol(), OP_SELLSTOP, 0.1,iBuyPrice, 4, 0, 0, "", magicnumber, 0 ,Yellow); OrderSend(Symbol(), OP_BUYSTOP, 0.1,iSellPrice , 4, 0, 0, "", magicnumber, 0 ,Yellow); Print("Total Pending Orders (init): OrdersTotal()"); } // ----- Close all Pending orders after TP / SL is hit ----- { int OrderCnt; for(OrderCnt=0;OrderCntiBuyPrice){closing = true; OrderDelete(OrderTicket());return(0);} if(AskOpen[1]&&High[1]>High[2]) BuyOp=true; if (Open[0]>=Close[0]&&Open[0]