• Overview
  • Reviews
  • Comments (20)
  • What's new

Cross Trend Line to Trade

This Expert Advisor opens or closes orders when the price is crossing the specified trend line (or horizontal line).

For example, you draw a trendline and name it "B1". When the price is crossing the trendline, the EA will open a buy order.

The name "B1" is built-in EA, you cannot use other letters.

Panel

  • Green: change the panel
  • Violet: change the line type(trend or horizontal)
  • Del: delete lines
  • X: close the panel


Built-In Names

The built-in names are used to open and close orders. All built-in names are described as below:

  1. B1, B2, B3, B4, B5 - these 5 names are used to open buy orders. For example, when price is crossing the "B3" line, the EA will open a buy order, and the order's comment is "752-B3", the number 752 is magic number
  2. S1, S2, S3, S4, S5 - these 5 names are used to open sell orders
  3. CALL1, CALL2, CALL3 - close all buy and sell orders. When price is crossing any of these 3 lines, all buy and sell orders will be closed
  4. CBALL1, CBALL2, CBALL3 - close all buy orders. When price is crossing any of these 3 lines, all buy orders will be closed
  5. CSALL1, CSALL2, CSALL3 - close all sell orders
  6. CBWIN1, CBWIN2, CBWIN3 - close buy orders in profit. When price is crossing any of these 3 lines, buy orders with positive profit will be closed
  7. CSWIN1, CSWIN2, CSWIN3 - close sell orders in profit
  8. CBLOSS1, CBLOSS2, CBLOSS3 - close buy orders in loss. When price is crossing any of these 3 lines, buy orders with negative profit will be closed
  9. CSLOSS1, CSLOSS2, CSLOSS3 - close sell orders in loss
  10. CBWINMAX1, CBWINMAX2, CBWINMAX3 - close the buy order with the maximum profit. When price is crossing any of these 3 lines, the buy order with the maximum profit will be closed
  11. CSWINMAX1, CSWINMAX2, CSWINMAX3 - close the sell order with the maximum profit
  12. CBLOSSMAX1, CBLOSSMAX2, CBLOSSMAX3 - close the buy order with the maximum loss. When price is crossing any of these 3 lines, the buy order with the maximum loss will be closed
  13. CSLOSSMAX1, CSLOSSMAX2, CSLOSSMAX3 - close the sell order with the maximum loss
  14. CBFIRST11, CBFIRST2, CBFIRST3 - close the buy order with the first open time. When price is crossing any of these 3 lines, the buy order with the first open time will be closed.
  15. CSFIRST11, CSFIRST2, CSFIRST3 - close the sell order with the first open time.
  16. CBLAST11, CBLAST2, CBLAST3 - close the buy order with the last open time. When the price is crossing any of these 3 lines, the buy order with the last open time will be closed.
  17. CSLAST11, CSLAST2, CSLAST3 - close the sell order with the last open time.
  18. TSB1, TSB2, TSB3 - trail stop loss of buy orders. When the price is above the line, the stop loss of order will move to the line value.
  19. TSS1, TSS2, TSS3 - trail stop loss of sell orders. When the price is below the line, the stop loss of order will move to the line value.


Input Parameters

  • B1_Lots: Lots for "B1" line.
  • B2_Lots: Lots for "B2" line.
  • B3_Lots: Lots for "B3" line.
  • B4_Lots: Lots for "B4" line.
  • B5_Lots: Lots for "B5" line.
  • S1_Lots: Lots for "S1" line.
  • S2_Lots: Lots for "S2" line.
  • S3_Lots: Lots for "S3" line.
  • S4_Lots: Lots for "S4" line.
  • S5_Lots: Lots for "S5" line.
    Note: B1_LOTS, B2_LOTS, etc. are initialized as 0, you should set them as your requirements.
  • MagicNumber: magic number
  • StopLossInPips: Stop Loss in Pips
  • TakeProfitInPips: Take Profit in Pips
  • MaxBuyOrders: the maximum number of buy orders, the maximum of MaxBuyOrders is 5, because there are only 5 lines for opening buy orders. Suppose it is set to 2, you draw 3 lines. Let's say, B1, B4 and B5, If price crossed B4 and B5 first, 2 orders are opened, although price crossed B1 later, EA will not open order for this crossing signal.
  • MaxSellOrders: Same as MaxBuyOrders.
  • TrailStopLevelPipsBuy: the threshold to activate trail stop for buy orders
  • TrailStopLevelPipsSell: the threshold to activate trail stop for sell orders
  • DeleteLineAfterTrade: If true, the line will be deleted immediately after the order is opened.
  • EmailOn: any trade action (open or close orders), EA will send an email
  • AlertOn: If true, any trade action (open or close orders), the EA will popup an alert. Besides Email and Alert, when there is a trade action, the EA will snapshot the chart, and the image is saved in MQL4\Files folder.
No reviews
Version 7.0 - 2017.07.24
Now new version 7.0 updated as below:

1. Add inputs TrailStopLevelPipsBuy and TrailStopLevelPipsSell as threshold to activate trailing stop.
2. Cancel input FullInstruction file, it is not necessary.
3. Cancel input ShowLineDescription, it is not necessary.
4. Add buttons to help to draw lines (trend or horizontal),which makes EA more easy to use:
4.1 Click the green button to change the panel.
4.2 Click the violet button to select line type (trend line or horizontal line)
4.3 Click the button Del to delete lines
4.4 Click the button X to close the panel.
Version 6.5 - 2017.03.30
Updated to the new terminal build.