• Home
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 1:57am
Menu
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 1:57am
Sister Sites
  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Options

Bookmark Thread

First Page First Unread Last Page Last Post

Print Thread

Similar Threads

MT4: Can comments or magic number be modified if order open? 4 replies

Pending order with magic number 1 reply

Change magic number of open trades? 3 replies

Need Script/EA can only generate Magic number 5 replies

Will dealer see order's magic number? 3 replies

  • Platform Tech
  • /
  • Reply to Thread
  • Subscribe
Tags: want script to open order by magic number change
Cancel

want script to open order by magic number change

  • Post #1
  • Quote
  • First Post: Edited 10:15pm Mar 10, 2016 10:04pm | Edited 10:15pm
  •  high321
  • Joined Jul 2015 | Status: 918528845436 | 229 Posts
simple script having option buy, sell true false. and magic number and comment can be adjustable. i forgate lot size is also can be adjestable.
  • Post #2
  • Quote
  • Mar 10, 2016 10:34pm Mar 10, 2016 10:34pm
  •  high321
  • Joined Jul 2015 | Status: 918528845436 | 229 Posts
Inserted Code
#property copyright "Copyright © 2010, Khlystov Vladimir"
#property link      "[email protected]"
#property show_inputs
//--------------------------------------------------------------------
extern int     stoploss    = 0,
               takeprofit  = 0,
               Magic       = 123456;
extern bool    SELL        = false,
               BUY         = false;
extern double  Lot         = 0.1;
extern int     slippage    = 3;
//--------------------------------------------------------------------
double SL,TP;
//--------------------------------------------------------------------
int start()
{
   if (BUY)
   {
      if (takeprofit!=0) TP  = Ask + takeprofit*Point; else TP=0;
      if (stoploss!=0)   SL  = Ask - stoploss*Point; else SL=0;     
      OPENORDER ("Buy");
   }
   if (SELL)
   {  
      if (takeprofit!=0) TP = Bid - takeprofit*Point; else TP=0;
      if (stoploss!=0)   SL = Bid + stoploss*Point;  else SL=0;              
      OPENORDER ("Sell");
   }
return(0);
}
//--------------------------------------------------------------------
void OPENORDER(string ord)
{
   int error,err;
   while (true)
   {  error=true;
      if (ord=="Buy" ) error=OrderSend(Symbol(),OP_BUY, Lot,Ask,slippage,SL,TP,"",Magic,3,Blue);
      if (ord=="Sell") error=OrderSend(Symbol(),OP_SELL,Lot,Bid,slippage,SL,TP,"",Magic,3,Red);
      if (error==-1)
      {  
         ShowERROR();
         err++;Sleep(2000);RefreshRates();
      }
      if (error || err >10) return;
   }
return;
}                  
//--------------------------------------------------------------------
void ShowERROR()
{
   int err=GetLastError();
   switch ( err )
   {                  
      case 1:   return;
      default:  Alert("Error  " ,err," ",Symbol());return;
   }
}
//--------------------------------------------------------------------
 
 
  • Post #3
  • Quote
  • Mar 10, 2016 10:38pm Mar 10, 2016 10:38pm
  •  high321
  • Joined Jul 2015 | Status: 918528845436 | 229 Posts
i find this work . but add in comment option
 
 
  • Post #4
  • Quote
  • Mar 12, 2016 12:29pm Mar 12, 2016 12:29pm
  •  NinoEff
  • | Joined Jan 2016 | Status: Member | 7 Posts
Quoting high321
Disliked
i find this work . but add in comment option
Ignored

Inserted Code
#property copyright "Copyright 2010, Khlystov Vladimir"
#property link      "[email protected]"
#property show_inputs
//--------------------------------------------------------------------
extern int     stoploss    = 0,
               takeprofit  = 0,
               Magic       = 123456;
extern bool    SELL        = false,
               BUY         = false;
extern double  Lot         = 0.1;
extern int     slippage    = 3;
extern string  Text        = "custom comment";
//--------------------------------------------------------------------
double SL,TP;
//--------------------------------------------------------------------
int start()
{
   if (BUY)
   {
      if (takeprofit!=0) TP  = Ask + takeprofit*Point; else TP=0;
      if (stoploss!=0)   SL  = Ask - stoploss*Point; else SL=0;    
      OPENORDER ("Buy");
   }
   if (SELL)
   {  
      if (takeprofit!=0) TP = Bid - takeprofit*Point; else TP=0;
      if (stoploss!=0)   SL = Bid + stoploss*Point;  else SL=0;              
      OPENORDER ("Sell");
   }
return(0);
}
//--------------------------------------------------------------------
void OPENORDER(string ord)
{
   int error,err;
   while (true)
   {  error=true;
      if (ord=="Buy" ) error=OrderSend(Symbol(),OP_BUY, Lot,Ask,slippage,SL,TP,Text,Magic,3,Blue);
      if (ord=="Sell") error=OrderSend(Symbol(),OP_SELL,Lot,Bid,slippage,SL,TP,Text,Magic,3,Red);
      if (error==-1)
      {  
         ShowERROR();
         err++;Sleep(2000);RefreshRates();
      }
      if (error || err >10) return;
   }
return;
}                  
//--------------------------------------------------------------------
void ShowERROR()
{
   int err=GetLastError();
   switch ( err )
   {                  
      case 1:   return;
      default:  Alert("Error  " ,err," ",Symbol());return;
   }
}
//--------------------------------------------------------------------
 
1
  • Post #5
  • Quote
  • Last Post: Mar 30, 2016 1:41am Mar 30, 2016 1:41am
  •  high321
  • Joined Jul 2015 | Status: 918528845436 | 229 Posts
Quoting NinoEff
Disliked
{quote} #property copyright "Copyright 2010, Khlystov Vladimir" #property link "[email protected]" #property show_inputs //-------------------------------------------------------------------- extern int stoploss = 0, takeprofit = 0, Magic = 123456; extern bool SELL = false, BUY = false; extern double Lot = 0.1; extern int slippage = 3; extern string Text = "custom comment"; //-------------------------------------------------------------------- double SL,TP; //-------------------------------------------------------------------- int start() { if (BUY)...
Ignored
thanks very much
 
 
  • Platform Tech
  • /
  • want script to open order by magic number change
  • Reply to Thread
0 traders viewing now
Top of Page
  • Facebook
  • Twitter
About FF
  • Mission
  • Products
  • User Guide
  • Media Kit
  • Blog
  • Contact
FF Products
  • Forums
  • Trades
  • Calendar
  • News
  • Market
  • Brokers
  • Trade Explorer
FF Website
  • Homepage
  • Search
  • Members
  • Report a Bug
Follow FF
  • Facebook
  • Twitter

FF Sister Sites:

  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Forex Factory® is a brand of Fair Economy, Inc.

Terms of Service / ©2023