Sell with SL and TP

Author: Copyright � 2008, smjones
Orders Execution
It automatically opens orders when conditions are reached
0 Views
0 Downloads
0 Favorites

Profitability Reports

AUD/USD Oct 2024 - Jan 2025
0.00 %
Total Trades 0
Won Trades 0
Lost trades 0
Win Rate 0.0 %
Expected payoff 0.00
Gross Profit 0.00
Gross Loss 0.00
Total Net Profit 0.00
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
0.00 %
Total Trades 0
Won Trades 0
Lost trades 0
Win Rate 0.0 %
Expected payoff 0.00
Gross Profit 0.00
Gross Loss 0.00
Total Net Profit 0.00
-100%
-50%
0%
50%
100%
Sell with SL and TP
//+------------------------------------------------------------------+
//|                                              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);
  }
//+------------------------------------------------------------------+

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---