//+------------------------------------------------------------------+ //| Sell 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 Sell"; extern double Entry = 0.0000; string Input = " Sell 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_SELLSTOP; if (Bid < Entry && Entry > 0) Mode = OP_SELLLIMIT; if (Entry == 0) {Entry = Bid; Mode = OP_SELL;} double SLS1 = Entry+StopLoss1*Point, TPS1 = Entry - TakeProfit1 * Point; if (UseStop1 == false) SLS1 = 0; if (UseTakeProfit1 == false) TPS1 = 0; if(Lots1 > 0) OrderSend(Symbol(),Mode, Lots1, Entry, 2, SLS1, TPS1, "Sell Script 1",0, NULL, Red); // Second Position if (OpenSecondPosition) { double SLS2 = Entry+StopLoss2*Point, TPS2 = Entry - TakeProfit2 * Point; if (UseStop2 == false) SLS2 = 0; if (UseTakeProfit2 == false) TPS2 = 0; if(Lots2 > 0) OrderSend(Symbol(),Mode, Lots2, Entry, 2, SLS2, TPS2, "Sell Script 1",0, NULL, Red); } return(0); } //+------------------------------------------------------------------+
Sample
Analysis
Market Information Used:
Indicator Curves created:
Indicators Used:
Custom Indicators Used:
Order Management characteristics:
It automatically opens orders when conditions are reached
Other Features: