Download MetaTrader 5

Watch how to download trading robots for free

Interesting script?
So post a link to it -
let others appraise it

You liked the script? Try it in the MetaTrader 5 terminal

Libraries

Hidden StopLoss and TakeProfit System - library for MetaTrader 4

| English Español Português 日本語 Deutsch

Views:
795
Rating:
votes: 1
Published:
2017.09.22 08:51

The attached files represent a class system that can be used to simulate a hidden Stop Loss and Take Profit system, however in addition to this, it also creates a live Stop Loss and Take Profit on the trade just in case the connection between the client and broker server goes down. There are also 4 example EAs. A basic description of how the system works is as follows:

  1. A class object is created with the trade characteristics that are required.
  2. A set of functions that are very similar to the OrderSend, OrderModify and OrderClose functions have been provided in the class for opening the trade.
  3. The class records the hidden Stop Loss and hidden Take Profit.
  4. When a trade is opened, a real Stop Loss and Take Profit is added onto the trade that is bigger than the hidden Stop Loss or Take Profit.
    • Buy: Minimum Stop Loss 1 = hidden Stop Loss - Live Spread.
    • Buy: Minimum Stop Loss 2 = Current Spot - {Freeze Level/Stop Level Adjustment} - Live Spread.
    • Buy: Actual Live Stop Loss is Min (Stop Loss 1, Stop Loss 2).
    • Sell: Minimum Stop Loss 1 = hidden Stop Loss + Live Spread.
    • Sell: Minimum Stop Loss 2 = Current Spot + {Freeze Level/Stop Level Adjustment} + Live Spread.
    • Sell: Actual Live Stop Loss is Max (Stop Loss 1, Stop Loss 2).
  5. The idea was to choose a level for Live Spread that will be large enough to cover any changes in the spread for Stop Loss hunting, but also any changes in the Stop Level and Freeze Level that may occur.
  6. I would suggest recording the spread, Stop Level and Freeze Level over a week and recording the difference between the minimum and maximum of these values. The Live Spread should be set so that it is greater than these differences.

To get the system to work please use the following procedure:

  1. Add GlobalChartFunctions, C_Trade, C_Trade_TrailingStop Loss, C_Trade_SteppedStop Loss, C_Trade_Pending into the include directory.
  2. Add C_Trade_BasicExample_1, C_Trade_TrailingStop Loss_2, C_Trade_SteppedStop Loss_3, C_Trade_Pending_4 into the Experts directory.
  3. If you want to move the files to a different location, you may need to adjust the include files.
  4. Compile the EA's and test them.

This system has only had some basic testing. It has not been tested in a live environment or incorporated into practical trading system yet, so please take great care and beware that bugs may exist.

I consider this a work in progress that I hope to improve upon later, when I have more time available.

S4T_DaysOfTheWeek S4T_DaysOfTheWeek

The indicator marks the days of the week with a colored histogram in the chart sub-window.

Multicurrency hedge example EA (overlay hedge) Multicurrency hedge example EA (overlay hedge)

The example of multicurrency hedging implementation on a single chart in Metatrader 4.

All In One Divergence All In One Divergence

Indicator to trade divergence. One of 30 indicators can be selected.

Simpler Trend Simpler Trend

Get a grasp of the current trend by candle colors.