//+------------------------------------------------------------------+
//|																Open_position.mq4 |
//|																		  Blowysoft |
//|																						|
//+------------------------------------------------------------------+
#property copyright "Blowysoft"
#property link		""
#property show_inputs
#include <stdlib.mqh>
#include <WinUser32.mqh>
#include <Money_mgmnt.mqh>

  extern double	Risk			= 2;
  extern int		MAGIC			= 323232;
  int	 				Stopsize		= 15;
  
//+------------------------------------------------------------------+
//| script program start function												|
//+------------------------------------------------------------------+
int start()
  {
  

  double riskratio		= 1;
  double Lots				= 0;
  double Stopsize			= 15;
  int	 Ticket1, Ticket2	= 0;
  
  double Pips = Point;
  if(Digits==3 || Digits==5)Pips=10*Point;
  
//----

	if(MessageBox("Do you want to execute a long Dance trade?", "Open Dance Long", MB_YESNO|MB_ICONWARNING) == IDYES) 
		{
		Lots=Get_Lot_Size(Stopsize,Risk/2,AccountBalance(),true);
		if(Lots>0) 
			{
			//First order with TP
			Ticket1=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,0,"Opened position at "+DoubleToStr(Risk,2)+"%",MAGIC,0,CLR_NONE);
			if(Ticket1 == -1)
				{
				MessageBox("Error opening trade Code :"+GetLastError(),"Error!",MB_OK);
				Print("Error opening long trade: Lots: ",Lots," Price: ",Bid," Slippage: ",3);
				}
			OrderSelect(Ticket1,SELECT_BY_TICKET);
			OrderModify(Ticket1,OrderOpenPrice(),OrderOpenPrice()-Stopsize*Pips,OrderOpenPrice()+Stopsize*Pips*riskratio,0,CLR_NONE);
			Ticket2=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,0,"Opened position at "+DoubleToStr(Risk,2)+"%",MAGIC,0,CLR_NONE);
			if(Ticket2 == -1)
				{
				MessageBox("Error opening trade Code :"+GetLastError(),"Error!",MB_OK);
				Print("Error opening long trade: Lots: ",Lots," Price: ",Bid," Slippage: ",3);
				}
			OrderSelect(Ticket2,SELECT_BY_TICKET);
			OrderModify(Ticket2,OrderOpenPrice(),OrderOpenPrice()-Stopsize*Pips,OrderTakeProfit(),0,CLR_NONE);
			MessageBox("Trade opened with Ticket numbers "+Ticket1," "+Ticket1,MB_OK);
			}
		}
	return(0);
}
//+------------------------------------------------------------------+