Delete SL_TP

Author: Copyright 2022, cmillion@narod.ru
Orders Execution
It automatically opens orders when conditions are reached
2 Views
0 Downloads
0 Favorites
Delete SL_TP
ÿþ//+------------------------------------------------------------------+

#property copyright "Copyright 2022, cmillion@narod.ru"

#property link      "http://www.cmillion.ru"

#property version   "1.2"

#property description "!:@8?B C40;O5B AB>?;>AA  8 B59:?@>D8B C 2A5E >B:@KBKE ?>78F89. The script resets the stop loss and take profit of orders."

#property description "---"

#property description "Telegram:  @ea_cmillion - #Convenient trading tools ##4>1=K5 8=AB@C<5=BK B>@3>2;8."

#property description "WhatsApp   +79283690333"

#property description "---"

#property description "0@0<5B@K "

#property description "NoLoss - ?5@52>4 2 157C1KB>:, 5A;8 0, B> =5B ?5@52>40 2 157C1KB>:"

#property description "MinProfitNoLoss - <8=8<0;L=0O ?@81K;L ?@8 ?5@52>45 2157C1KB>:"

//--------------------------------------------------------------------

MqlTick tick;

MqlTradeRequest request;

MqlTradeResult result;

MqlTradeCheckResult check;

MqlDateTime tm;

//--------------------------------------------------------------------

void OnStart()

{

   bool LANGUAGE=TerminalInfoString(TERMINAL_LANGUAGE)=="Russian";

   Comment(LANGUAGE?"#40;O5B AB>?;>AA  8 B59:?@>D8B C 2A5E >B:@KBKE ?>78F89.":"Removes stop loss and take profit from all open positions.");



   if (!TerminalInfoInteger(TERMINAL_TRADE_ALLOWED)) 

   { 

      Comment(LANGUAGE?"@>25@LB5 2 =0AB@>9:0E B5@<8=0;0 @07@5H5=85 =0 02B><0B8G5A:CN B>@3>2;N!":"Check the automatic trading permission in the terminal settings!");

      Sleep(2000);

      return;

   }

   

   //---

   

   if(!MQLInfoInteger(MQL_TRADE_ALLOWED)) 

   {

      Comment(LANGUAGE?"2B><0B8G5A:0O B>@3>2;O 70?@5I5=0 2 A2>9AB20E ?@>3@0<<K 4;O ":"Automatic trading is prohibited in the program properties for ",__FILE__); 

      Sleep(2000);

      return;

   }

   

   //---

   

   if(SymbolInfoInteger(_Symbol,SYMBOL_TRADE_MODE)!=SYMBOL_TRADE_MODE_FULL)

   {

      Comment(LANGUAGE?"">@3>2;O ?> 2K1@0==K< 8=AB@C<5=B0< 70?@5I5=0":"Trading on the selected instruments is prohibited");

      Sleep(2000);

      return;

   }

   

   //---

   

   if(!AccountInfoInteger(ACCOUNT_TRADE_EXPERT)) 

   {

      Comment(LANGUAGE?"2B><0B8G5A:0O B>@3>2;O 70?@5I5=0 4;O AG5B0 ":"Automatic trading is prohibited for the account ",AccountInfoInteger(ACCOUNT_LOGIN), 

      LANGUAGE?" =0 AB>@>=5 B>@3>2>3> A5@25@0":"on the side of the trading server");

      Sleep(2000);

      return;

   }

   

   //---

   

   if(!AccountInfoInteger(ACCOUNT_TRADE_ALLOWED))

   {

      Comment(LANGUAGE?"">@3>2;O 70?@5I5=0 4;O AG5B0 ":"Trading is prohibited for the account ",AccountInfoInteger(ACCOUNT_LOGIN));

      Sleep(2000);

      return;

   }

   

   //---

   

   double Bid=SymbolInfoDouble(Symbol(),SYMBOL_BID);

   double Ask=SymbolInfoDouble(Symbol(),SYMBOL_ASK);

   double OOP,OSL,OTP;

   for(int i=0; i<PositionsTotal(); i++)

   {

      if(_Symbol==PositionGetSymbol(i))

      {

         ZeroMemory(request);

         ZeroMemory(result);

         request.position = PositionGetInteger(POSITION_TICKET);

         OOP = PositionGetDouble(POSITION_PRICE_OPEN); 

         OSL = PositionGetDouble(POSITION_SL);

         OTP = PositionGetDouble(POSITION_TP);

         long tip = PositionGetInteger(POSITION_TYPE);

         request.sl=0;request.tp=0;

         if (OSL!=0 || OTP!=0)

         {

            request.action = TRADE_ACTION_SLTP;

            Comment(TimeToString(TimeCurrent())," Modify Sell ",request.position,",  SL ",DoubleToString(OSL,_Digits)," -> ",DoubleToString(request.sl,_Digits),"  TP ",DoubleToString(OTP,_Digits)," -> ",request.tp);

            if(!OrderSend(request,result)) Print("error ",GetLastError());

         }

      }  

   }

   Comment("");

}

//+------------------------------------------------------------------+

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 ---