//+------------------------------------------------------------------+ //| script "send pending sell stop order with expiration data" //| Variable spacing function added //| Variable TP function added //| Inputs added //| Bug fixed to make sure only MaxTrades are open //+------------------------------------------------------------------+ #property show_inputs // change the a value to set how many buy stop pending order extern int maxtrade = 5; // change the b value to set your lot size extern double lotsize = 0.20; // change the c value to set how many hours from now until your pending expired extern double exphours = 440; // change the d value to set the spacing for the first position from the current ask price extern int pipspace1 = 200; // you can change this e value with your expected price extern double ExpectedPrice = 0; // change the f value to set the spacing for the second position upward extern int pipspace2 = 750; // change the g value to set your take profit extern int takeprofit = 400; extern string UserComment = "some comment"; extern int MagicNumber = 16384; double myPoint; int start() { int ticket,expiration; //double point; // added to handle 5 digit pricing myPoint = SetPoint(Symbol()); // you can change this e value with your expected price double e; if (ExpectedPrice < 0.1) e = Ask ; else e = ExpectedPrice; //---- //point=MarketInfo(Symbol(),MODE_POINT); expiration=TimeCurrent()+PERIOD_D1*(exphours*2.5); for(int i=maxtrade-1;i>=0;i--) //---- while(true) { ticket=OrderSend(Symbol(),OP_SELLSTOP,lotsize,e-(pipspace1*myPoint),0,0,e-((pipspace1+takeprofit)*myPoint),UserComment,MagicNumber,expiration,Red); pipspace1=pipspace1+pipspace2; if(ticket<=0) Print("Error = ",GetLastError()); else { Print("ticket = ",ticket); break; } //---- 5 seconds wait Sleep(5000); } //---- return(0); } //+------------------------------------------------------------------+ // Function to handle 5 digit pricing // Changes value of myPoint to use 4 digit pricing to replace myPoint in code double SetPoint(string mySymbol) { double myPoint, myDigits; myDigits = MarketInfo (mySymbol, MODE_DIGITS); if (myDigits < 4) myPoint = 0.01; else myPoint = 0.0001; return(myPoint); }