Scripts: The scripts for opening short positions

 

The scripts for opening short positions:

These scripts are designed to sell with fixed values of Stop Loss and Take Profit in points from the current price. There are four variants of scripts which can be divided into two groups:

  1. Scripts for brokers which have nonzero spread and admit the ability to set Stop Loss and Take Profit simultaneously performing a deal;
  2. Scripts for brokers which may have zero spread, otherwise, it is not recommended to set Stop Loss and Take Profit simultaneously opening a position. At first, these scripts open positions without orders, and then modify them changing Stop Loss and Take Profit.

Author: Nikolay Kositsin

 

The OpenBuyPosition script is buggy when SYMBOL_TRADE_STOPS_LEVEL=0 in the following code :

bool StopCorrect(string symbol,int &Stop)
  {
//----
   int Extrem_Stop=int(SymbolInfoInteger(symbol,SYMBOL_TRADE_STOPS_LEVEL));
   if(!Extrem_Stop) return(false);   MUST BE    if(Extrem_Stop<0) return(false);
   if(Stop<Extrem_Stop) Stop=Extrem_Stop;
//----
   return(true);
  }
Extrem_Stop is an int, not a bool.