Script for StopOrders On Mouse Function.

To add comments, please log in or register
Yui kimitokawa
106
Yui kimitokawa  

hi

i need to add number of orders = 5 to this script, but unable to do so as price is not considered because it's a drag and drop on mouse script, i do not want to change the script of mouse simplicity, but want to add "number of orders" to the script, meaning multiple pending orders such as (BUYSTOP OR SELLSTOP) will be created of the same price.
kindly help.

#property show_inputs

//--------------------------------------------------------------------
extern int     Stoploss          = 50,     //
               Takeprofit        = 80;     //
extern double  Lot               = 0.01;   //
extern int     Magic             = 0;     //
extern bool    comment           = true;  //display information on screen
//--------------------------------------------------------------------
int start()
{
   double SL,TP;
   double Price = NormalizeDouble(WindowPriceOnDropped(),Digits);
   string txt=StringConcatenate("Stop the script issuing a warrant ",DoubleToStr(Price,Digits)," ñòàðò ",TimeToStr(TimeCurrent(),TIME_DATE|TIME_SECONDS));
   RefreshRates();
   if(Price>Ask) 
   {
      if (Takeprofit!=0) TP = NormalizeDouble(Price + Takeprofit * Point,Digits); else TP=0;
      if (Stoploss!=0)   SL = NormalizeDouble(Price - Stoploss   * Point,Digits); else SL=0;
      if (OrderSend(Symbol(),OP_BUYSTOP,Lot,Price,0,SL,TP,"StopOrders",Magic,0,CLR_NONE)!=-1)
           txt = StringConcatenate(txt,"\nSet BUYSTOP ",DoubleToStr(Price,Digits));
      else txt = StringConcatenate(txt,"\nError ",GetLastError()," BUYSTOP ");
   }
   if(Price<Bid) 
   {
      if (Takeprofit!=0) TP = NormalizeDouble(Price - Takeprofit * Point,Digits); else TP=0;
      if (Stoploss!=0)   SL = NormalizeDouble(Price + Stoploss   * Point,Digits); else SL=0;
      if (OrderSend(Symbol(),OP_SELLSTOP,Lot,Price,0,SL,TP,"StopOrders",Magic,0,CLR_NONE)==-1)
           txt = StringConcatenate(txt,"\nSet SELLSTOP ",DoubleToStr(Price,Digits));
      else txt = StringConcatenate(txt,"\nError ",GetLastError()," SELLSTOP ");
   }
   if (comment) Comment(txt,"\nThe script has finished its work ",TimeToStr(TimeCurrent(),TIME_DATE|TIME_SECONDS));
   return(0);
}
//--------------------------------------------------------------------


//--------------------------------------------------------------------

William Roeder
21915
William Roeder  
Yui kmitokawa: i need… kindly help.
Help you with what? You haven't stated a problem, you stated a want. Show us your attempt (using the CODE button) and state the nature of your problem.
          No free help 2017.04.21

Or pay someone. Top of every page is the link Freelance.
          Hiring to write script - General - MQL5 programming forum 2018.05.12

Pavel Shutovskiy
49079
Pavel Shutovskiy  
Yui kmitokawa:

hi

i need to add number of orders = 5 to this script, but unable to do so as price is not considered because it's a drag and drop on mouse script, i do not want to change the script of mouse simplicity, but want to add "number of orders" to the script, meaning multiple pending orders such as (BUYSTOP OR SELLSTOP) will be created of the same price.
kindly help.

#property show_inputs

//--------------------------------------------------------------------
extern int     Stoploss          = 50,     //
               Takeprofit        = 80;     //
extern double  Lot               = 0.01;   //
extern int     Magic             = 0;     //
extern bool    comment           = true;  //display information on screen
//--------------------------------------------------------------------
int start()
{

   double point = _Point;
   if(Digits == 3 || Digits == 5)point = 10.0 * point;
   
   
   double SL,TP;
   double Price = NormalizeDouble(WindowPriceOnDropped(),Digits);
   string txt=StringConcatenate("Stop the script issuing a warrant ",DoubleToStr(Price,Digits)," ñòàðò ",TimeToStr(TimeCurrent(),TIME_DATE|TIME_SECONDS));
   RefreshRates();
   if(Price>Ask) 
   {
      if (Takeprofit!=0) TP = NormalizeDouble(Price + Takeprofit * point,Digits); else TP=0;
      if (Stoploss!=0)   SL = NormalizeDouble(Price - Stoploss   * point,Digits); else SL=0;
      if (OrderSend(Symbol(),OP_BUYSTOP,Lot,Price,0,SL,TP,"StopOrders",Magic,0,CLR_NONE)!=-1)
           txt = StringConcatenate(txt,"\nSet BUYSTOP ",DoubleToStr(Price,Digits));
      else txt = StringConcatenate(txt,"\nError ",GetLastError()," BUYSTOP ");
   }
   if(Price<Bid) 
   {
      if (Takeprofit!=0) TP = NormalizeDouble(Price - Takeprofit * point,Digits); else TP=0;
      if (Stoploss!=0)   SL = NormalizeDouble(Price + Stoploss   * point,Digits); else SL=0;
      if (OrderSend(Symbol(),OP_SELLSTOP,Lot,Price,0,SL,TP,"StopOrders",Magic,0,CLR_NONE)==-1)
           txt = StringConcatenate(txt,"\nSet SELLSTOP ",DoubleToStr(Price,Digits));
      else txt = StringConcatenate(txt,"\nError ",GetLastError()," SELLSTOP ");
   }
   if (comment) Comment(txt,"\nThe script has finished its work ",TimeToStr(TimeCurrent(),TIME_DATE|TIME_SECONDS));
   return(0);
}
//--------------------------------------------------------------------


//--------------------------------------------------------------------
Yui kimitokawa
106
Yui kimitokawa  
Pavel Shutovskiy:

i tried the point function but it's not working, i even tried modifying normalize function but it's not creating multiple orders.

Keith Watford
Moderator
23533
Keith Watford  

Add

extern int     NumberOfOrders       = 5; //Number of Orders

and before each OrderSend()

for(int x=0;x<NumberOfOrders;x++)

Not tested

Yui kimitokawa
106
Yui kimitokawa  
Keith Watford:

Add

and before each OrderSend()

Not tested

yes i did tried that too, thanks Keith, but it's not working.
Keith Watford
Moderator
23533
Keith Watford  
Yui kmitokawa:
yes i did tried that too, thanks Keith, but it's not working.

What errors are you getting?

Your original script did work did it?

Yui kimitokawa
106
Yui kimitokawa  
Keith Watford:

What errors are you getting?

Your original script did work did it?

there are no errors, but output is not affected.
Keith Watford
Moderator
23533
Keith Watford  
Yui kmitokawa:
there are no errors, but output is not affected.

Please show your updated code

Yui kimitokawa
106
Yui kimitokawa  
Keith Watford:

Please show your updated code

kindly have a look,

#property show_inputs

//--------------------------------------------------------------------
extern int     Stoploss          = 50,     //
               Takeprofit        = 80;     //
extern double  Lot               = 0.01;   //
extern int     NumberOfOrders    = 5;   //Number of Orders
extern int     Magic             = 0;      //
extern bool    comment           = true;   //display information on screen
//--------------------------------------------------------------------
int start()
{
   double SL,TP;
   double Price = NormalizeDouble(WindowPriceOnDropped(),Digits);
   string txt=StringConcatenate("Stop the script issuing a warrant ",DoubleToStr(Price,Digits)," ñòàðò ",TimeToStr(TimeCurrent(),TIME_DATE|TIME_SECONDS));
   RefreshRates();
   for(int x=0;x<NumberOfOrders;x++)
   double MoneyRisked = NumberOfOrders * MODE_LOTSIZE;

   if(Price>Ask) 
   {
      if (Takeprofit!=0) TP = NormalizeDouble(Price + Takeprofit * Point,Digits); else TP=0;
      if (Stoploss!=0)   SL = NormalizeDouble(Price - Stoploss   * Point,Digits); else SL=0;
      if (OrderSend(Symbol(),OP_BUYSTOP,Lot,Price,0,SL,TP,"StopOrders",Magic,0,CLR_NONE)!=-1)
           txt = StringConcatenate(txt,"\nSet BUYSTOP ",DoubleToStr(Price,Digits));
      else txt = StringConcatenate(txt,"\nError ",GetLastError()," BUYSTOP ");
   }
   if(Price<Bid) 
   {
      if (Takeprofit!=0) TP = NormalizeDouble(Price - Takeprofit * Point,Digits); else TP=0;
      if (Stoploss!=0)   SL = NormalizeDouble(Price + Stoploss   * Point,Digits); else SL=0;
      if (OrderSend(Symbol(),OP_SELLSTOP,Lot,Price,0,SL,TP,"StopOrders",Magic,0,CLR_NONE)==-1)
           txt = StringConcatenate(txt,"\nSet SELLSTOP ",DoubleToStr(Price,Digits));
      else txt = StringConcatenate(txt,"\nError ",GetLastError()," SELLSTOP ");
   }
   
   if (comment) Comment(txt,"\nThe script has finished its work ",TimeToStr(TimeCurrent(),TIME_DATE|TIME_SECONDS));
   return(0);
}
//--------------------------------------------------------------------


//--------------------------------------------------------------------

Keith Watford
Moderator
23533
Keith Watford  
Yui kmitokawa:
kindly have a look,

Keith Watford:

Add

extern int     NumberOfOrders       = 5; //Number of Orders

and before each OrderSend()

for(int x=0;x<NumberOfOrders;x++)

Not tested

You have not put the loop in.

     for(int x=0;x<NumberOfOrders;x++)
      if (OrderSend(Symbol(),OP_BUYSTOP,Lot,Price,0,SL,TP,"StopOrders",Magic,0,CLR_NONE)!=-1)
         for(int x=0;x<NumberOfOrders;x++)
          if (OrderSend(Symbol(),OP_SELLSTOP,Lot,Price,0,SL,TP,"StopOrders",Magic,0,CLR_NONE)==-1)
12
To add comments, please log in or register