//+------------------------------------------------------------------+ //| Buy with SL and TP | //| Copyright © 2008, smjones | //| sjcoinc | //+------------------------------------------------------------------+ #property copyright "Copyright © 2008, smjones" #property link "sjcoinc2000@yahoo.com" #property show_inputs extern bool OpenSecondPosition = true; extern double Lots1 = 0.3; extern double Lots2 = 0.7; extern bool UseMoneyMgmt = false; extern double RiskPercent1 = 1.2; extern double RiskPercent2 = 0.8; extern bool UseStop1 = true; extern bool UseTakeProfit1 = true; extern bool UseStop2 = true; extern bool UseTakeProfit2 = true; extern double StopLoss1 = 1000; extern double StopLoss2 = 1000; extern double TakeProfit1 = 250; extern double TakeProfit2 = 150; extern string Note="0 in Entry field means Market Order Buy"; extern double Entry = 0.0000; string Input = " Buy Price "; //+------------------------------------------------------------------+ //| script program start function | //+------------------------------------------------------------------+ int start() { double Risk1 = RiskPercent1 / 100; double Risk2 = RiskPercent2 / 100; if (UseMoneyMgmt) { Lots1 = NormalizeDouble( AccountBalance()*Risk1/StopLoss1/(MarketInfo(Symbol(), MODE_TICKVALUE)),2); Lots2 = NormalizeDouble( AccountBalance()*Risk2/StopLoss2/(MarketInfo(Symbol(), MODE_TICKVALUE)),2); } int Mode = OP_BUYSTOP; if (Ask > Entry && Entry > 0) Mode = OP_BUYLIMIT; if (Entry == 0) {Entry = Ask; Mode = OP_BUY;} double SLB1 = Entry - StopLoss1*Point, TPB1 = Entry + TakeProfit1*Point; if (UseStop1 == false) SLB1 = 0; if (UseTakeProfit1 == false) TPB1 = 0; if(Lots1 > 0) OrderSend(Symbol(),Mode, Lots1, Entry, 2,SLB1 , TPB1, "Buy Script 1", 0, NULL, LimeGreen); // Second Position if (OpenSecondPosition) { double SLB2 = Entry - StopLoss2*Point, TPB2 = Entry + TakeProfit2*Point; if (UseStop2 == false) SLB2 = 0; if (UseTakeProfit2 == false) TPB2 = 0; if(Lots2 > 0) OrderSend(Symbol(),Mode, Lots2, Entry, 2,SLB2 , TPB2, "Buy Script 2", 0, NULL, LimeGreen); } return(0); } //+------------------------------------------------------------------+