Buy stop | sell stop script

 

hi, i am looking for a script which can set a buy stop and sell stop 10 pips away from the market price and should have sl at 20 pips. can anyone please help me out here?

thanks a bunch.

regards,

james

 

i have found this on the internet. i think its possible to do some changes and then it will work like it should.

i have tried but i couldnt get it because i am not an expert

#property show_inputs
//#property show_confirm
extern double Lots = 0.1;
extern int Slippage = 3;
extern int Stop_Loss = 20;
extern int Take_Profit = 100;
//+------------------------------------------------------------------+
//| script "Open a new Buy Order" |
//+------------------------------------------------------------------+
int start()
  {
   double Price = WindowPriceOnDropped();
   bool result;
   int cmd, total, error, slippage;
//----
   int NrOfDigits = MarketInfo(Symbol(), MODE_DIGITS); // Nr. of decimals used by Symbol
   int PipAdjust; // Pips multiplier for value adjustment
   if(NrOfDigits == 5 || NrOfDigits == 3) // If decimals = 5 or 3
      PipAdjust = 10; // Multiply pips by 10
   else
      if(NrOfDigits == 4 || NrOfDigits == 2) // If digits = 4 or 3 (normal)
         PipAdjust = 1;
//----
   slippage = Slippage * PipAdjust;
   double stop_loss = Price + Stop_Loss * Point * PipAdjust;
   double take_profit = Price - Take_Profit * Point * PipAdjust;
//int ticket=OrderSend(Symbol(),OP_SELL,0.1,Bid,29,0,0,"Sell more",255,3,CLR_NONE);
   if(Bid > Price)
     {
      result = OrderSend(Symbol(), OP_SELLSTOP, Lots, Price, slippage, stop_loss, take_profit, "", 0, 0, CLR_NONE);
     }
   if(Bid < Price)
     {
      result = OrderSend(Symbol(), OP_SELLLIMIT, Lots, Price, slippage, stop_loss, take_profit, "", 0, 0, CLR_NONE);
     }
//----
   return(0);
  }

i want nothing else then to place the buy or sell stop order 10 pips away from the marketprice.

 

issue has been solved.

 
compiled with errors
 
Nas Haniff #: compiled with errors
There are no compile errors. Only warnings.
 
   double stop_loss = Price + Stop_Loss * Point * PipAdjust;
   double take_profit = Price - Take_Profit * Point * PipAdjust;

You buy at the Ask and sell at the Bid. Pending Buy Stop orders become market orders when hit by the Ask.

  1. Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid / OrderClosePrice reaches it. Using Ask±n, makes your SL shorter and your TP longer, by the spread. Don't you want the specified amount used in either direction?

  2. Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask / OrderClosePrice reaches it. To trigger close at a specific Bid price, add the average spread.
              MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25

  3. The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools → Options (control+O) → charts → Show ask line.)

    Most brokers with variable spreads widen considerably at end of day (5 PM ET) ± 30 minutes.
    My GBPJPY shows average spread = 26 points, average maximum spread = 134.
    My EURCHF shows average spread = 18 points, average maximum spread = 106.
    (your broker will be similar).
              Is it reasonable to have such a huge spreads (20 PIP spreads) in EURCHF? - General - MQL5 programming forum (2022)