Watch how to download trading robots for free
Find us on Twitter!
Join our fan page
Interesting script?
So post a link to it -
let others appraise it
You liked the script? Try it in the MetaTrader 5 terminal
Views:
2449
Rating:
(12)
Published:
2018.07.13 16:07
Need a robot or indicator based on this code? Order it on Freelance Go to Freelance

An Expert Advisor for closing all positions, in case of the total losses on those positions exceeded the Stop Loss level fixed in inputs, or where it is necessary to close all positions beyond the time interval fixed in the settings. In a manner, this EA works as a global stop loss function for all open positions simultaneously. The fact itself of stopping the losses and commanding to close positions is placed by the EA in a log file as relevant comments.

//+----------------------------------------------+
//|  Options to calculate the losses             |
//+----------------------------------------------+
enum LossMode
  {
   ENUM_PERCENT,     //losses in percents
   ENUM_CARRENCY     //losses in deposit currency units
  };
//+----------------------------------------------+
//| Input parameters of the EA indicator         |
//+----------------------------------------------+
input LossMode LMode=ENUM_PERCENT;  //method of detecting losses
input double StopLoss=20.0;         //stop loss level

The EA provides an option of closing positions only beyond the time interval defined in its input variables:

input bool TimeTrade=true; //Permission to trade by time intervals
input HOURS StartH=ENUM_HOUR_0; //Trading start (Hours)
input MINUTS StartM=ENUM_MINUT_0; //Trading start (Minutes)
input HOURS EndH=ENUM_HOUR_23; //Trading end (Hours)
input MINUTS EndM=ENUM_MINUT_59; //Trading end (Minutes)

Two variables (hours and minutes) are provided for the operation start time, and two similar variables for the end time.

Default settings enable the Expert Advisor to trade the whole trading session from 0:00, while all positions are closed at 23:59.

If the start time is later than the specified end time, the Expert Advisor will close positions the next day, at the specified time.

Translated from Russian by MetaQuotes Ltd.
Original code: https://www.mql5.com/ru/code/21341

Choppiness_IndexH Choppiness_IndexH

Indicator Choppiness Index Histogram

Choppiness_Index Choppiness_Index

Indicator Choppiness Index

Exp_GTakeProfit_Tm Exp_GTakeProfit_Tm

An Expert Advisor for closing all positions, in case of the total profits on those positions exceeded the Take Profit level fixed in inputs, or where it is necessary to close all positions beyond the time interval fixed in the settings.

Exp_GStop_Tm Exp_GStop_Tm

An Expert Advisor for closing all positions, in case of the total profits on those positions exceeded the Take Profit level fixed in inputs or the total losses on those positions exceeded the Stop Loss level fixed in inputs, or where it is necessary to close all positions beyond the time interval fixed in the settings.