• Overview
  • Reviews
  • Comments (16)

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.


Built-In Names

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

  1. BUY: B1, B2, B3, B4, B5 - these 5 names are used to open buy orders. You may draw a trendline and name it with one of these 5 names. Of course, you may draw 5 trendlines. Every line opens only one order with a special comment, the comments are used to identify the order. For example, draw a trendline and name it "B3". When the 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 MagicNumber of EA. If "752-B3" order exists, the EA will not open a new order with the same comment.
  2. SELL: S1, S2, S3, S4, S5 - these 5 names are used to open sell orders. Every line opens only one order.
  3. Close All orders: CALL1, CALL2, CALL3 - these 3 names are used to close all buy and sell orders. You may draw 3 lines named with these 3 names. When price is crossing any of these 3 lines, all buy and sell orders will be closed.
  4. Close Buy Orders: CBALL1, CBALL2, CBALL3 - these 3 names are used to close all buy orders. When the price is crossing any of these 3 lines, all buy orders will be closed.
  5. Close Sell Orders: CSALL1, CSALL2, CSALL3 - these 3 names are used to close all sell orders. When the price is crossing any of these 3 lines, all sell orders will be closed.
  6. Close Buy Orders with Win profit: CBWIN1, CBWIN2, CBWIN3 - these 3 names are used to close buy orders with positive profit. When the price is crossing any of these 3 lines, buy orders with positive profit will be closed.
  7. Close Sell Orders with Win profit: CSWIN1, CSWIN2, CSWIN3 - these 3 names are used to close sell orders with positive profit. When the price is crossing any of these 3 lines, sell orders with positive profit will be closed.
  8. Closs Buy Orders with Loss profit: CBLOSS1, CBLOSS2, CBLOSS3 - these 3 names are used to close buy orders with negative profit. When the price is crossing any of these 3 lines, buy orders with negative profit will be closed.
  9. Close Sell Orders with Loss profit: CSLOSS1, CSLOSS2, CSLOSS3 - these 3 names are used to close sell orders with negative profit. When the price is crossing any of these 3 lines, sell orders with negative profit will be closed.
  10. Close Buy Order with Win-Max: CBWINMAX1, CBWINMAX2, CBWINMAX3 - these 3 names are used to close the buy order with the maximum positive profit. When the price is crossing any of these 3 lines, the buy order with the maximum positive profit will be closed.
  11. Close Sell Order with Win-Max: CSWINMAX1, CSWINMAX2, CSWINMAX3 - these 3 names are used to close the sell order with the maximum positive profit. When the price is crossing any of these 3 lines, the sell order with the maximum positive profit will be closed.
  12. Close Buy Order with LOSS-MAX: CBLOSSMAX1, CBLOSSMAX2, CBLOSSMAX3 - these 3 names are used to close the buy order with the maximum negative profit. When the price is crossing any of these 3 lines, the buy order with the maximum negative profit will be closed.
  13. Close Sell Order with LOSS-Max: CSLOSSMAX1, CSLOSSMAX2, CSLOSSMAX3 - these 3 names are used to close the sell order with the maximum negative profit. When the price is crossing any of these 3 lines, the sell order with the maximum negative profit will be closed.
  14. Close Buy Order with the First open time: CBFIRST11, CBFIRST2, CBFIRST3 - these 3 names are used to close the buy order with the first open time. When the price is crossing any of these 3 lines, the buy order with the first open time will be closed.
  15. Close Sell Order with the First open time: CSFIRST11, CSFIRST2, CSFIRST3 - these 3 names are used to close the sell order with the first open time. When the price is crossing any of these 3 lines, the sell order with the first open time will be closed.
  16. Close Buy Order with the last open time: CBLAST11, CBLAST2, CBLAST3 - these 3 names are used to 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. Close Sell Order with the last open time: CSLAST11, CSLAST2, CSLAST3 - these 3 names are used to close the sell order with the last open time. When the price is crossing any of these 3 lines, the sell order with the last open time will be closed.
  18. Trail Stop For Buy Orders: TSB1, TSB2, TSB3 - these 3 names are used is to 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. Trail Stop For Sell Orders: TSS1, TSS2, TSS3 - these 3 names are used to 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: When price is crossing the line named "B1", the EA will open a buy order with B1_Lots.
  • B2_Lots: When price is crossing the line named "B2", the EA will open a buy order with B2_Lots.
  • B3_Lots: When price is crossing the line named "B3", the EA will open a buy order with B3_Lots.
  • B4_Lots: When price is crossing the line named "B4", the EA will open a buy order with B4_Lots.
  • B5_Lots: When price is crossing the line named "B5", the EA will open a buy order with B5_Lots.
  • S1_Lots: When price is crossing the line named "S1", the EA will open a sell order with S1_Lots.
  • S2_Lots: When price is crossing the line named "S2", the EA will open a sell order with S2_Lots.
  • S3_Lots: When price is crossing the line named "S3", the EA will open a sell order with S3_Lots.
  • S4_Lots: When price is crossing the line named "S4", the EA will open a sell order with S4_Lots.
  • S5_Lots: When price is crossing the line named "S5", the EA will open a sell order with S5_Lots.
    Note: B1_LOTS, B2_LOTS, etc. are initialized as 0, you should set them as your requirements.
  • MagicNumber: This is the magic number of the EA.
  • StopLossInPips: It is in pips instead of points. When an order is opened, the EA will set a stop loss price for it.
  • TakeProfitInPips: It is in pips instead of points. When an order is opened, the EA will set a take profit price for it.
  • MaxBuyOrders: This input limits the number of buy orders, the maximum of MaxBuyOrders is 5, because there are not more than 5 lines for opening buy orders. These lines are B1, B2, B3, B4 and B5. Suppose MaxBuyOrders is set to 2, you draw 3 lines. Let's say, B1, B4 and B5 on a chart. 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.
  • DeleteLineAfterTrade: If it is set to true, the line will be deleted immediately after the order is opened.
  • ShowLineDescription: If it is set to true, the EA will use the line's name to set the description of the line, and show it on a chart.
  • EmailOn: If it is set to true, when there is a trade action (open or close orders), the EA will send an email as per your MetaTrader 4 email configuration. MT4 Email configuration: Tools ---> Options --->Email.
  • AlertOn: If it is set to true, when there is a 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