//+------------------------------------------------------------------+
//|                                              Sell with SL and TP |
//|                               Copyright © 2008, smjones          |
//|                                               sjcoinc            |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, smjones"
#property link      "sjcoinc2000@yahoo.com"


#property show_inputs

//extern double StopLoss = 750;


string Input = " Sell Price ";

double Lots = .02;
bool   UseMoneyMgmt = true;
double RiskPercent = .5;
bool   UseStop = true;
bool   UseTakeProfit = true;
int    pipMult = 100000;
double Sentiment=0;

//double TakeProfit = 1500;
//double atrmult = 1.0;


double StopLoss= (pipMult*iATR(NULL,0,20,1))*3;



double TakeProfit = (StopLoss*2);
string Note="0 in Entry field means Market Order Sell";
double Entry = 0.0000;

  
 //declare global her
double Poin;

   
//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start()
 
{ 

//add this here then replace all instances of Point with Poin(other than in this block of code)
//if its an indicator or EA the put this in the Init() function
if (Point == 0.00001) Poin = 0.0001; 
else if (Point == 0.001) Poin = 0.01; 
else Poin = Point;  

  double Risk = RiskPercent / 100;
  if (UseMoneyMgmt)
    Lots = NormalizeDouble( AccountBalance()*Risk/StopLoss/(MarketInfo(Symbol(), MODE_TICKVALUE)),2); 
  int Mode = OP_SELLSTOP;
  if (Bid < Entry && Entry > 0) Mode = OP_SELLLIMIT; 
  if (Entry == 0)  {Entry = Bid; Mode = OP_SELL;}
  double  SLS = Entry+StopLoss*Poin, TPS = Entry - TakeProfit * Poin;
  if (UseStop == false) SLS = 0;
  if (UseTakeProfit == false) TPS = 0;
  if(Lots > 0)
  OrderSend(Symbol(),Mode, Lots, Entry, 2, SLS, TPS, Sentiment,0, NULL, Red);
            
   return(0);
  }
//+------------------------------------------------------------------+
