This EA is a semi-automated aide to manual trading.
I thought straight away of the 'Waiting to Buy/Sell' ea's that I have waiting for a price to cross a pivot on my 10.2 charts, and how this might be a useful addition to the armoury. The problem with this sort of ea lies in coding so that it knows when to stop.
I have tackled this one a little differently. Drag the attached script onto a chart and it will draw three lines:
- - yellow, dashed line.
- green and red dotted lines.
Yellow is my default for NeutralLineColour. If you drag the attached ea onto the chart, it will do nothing. If you delete the yellow line, the ea will never do anything - it must have the line on the chart, set to the correct colour first.
If you want a buy stop trade, select the yellow line and change its colour so it matches BuyLineColour - green by default. For a sell stop trade, change the colour to SellLineColour - default is red.
The ea and script have a set of inputs common to both:
- BuyLineColour=Green;
SellLineColour=Red;
NeutralLineColour=Yellow;
PendingLineName="Pending trade line";
TakeProfitLineName="Pending Take profit line";
StopLossLineName="Pending Stop loss line";
Assuming all is well, the ea will send a pending trade at the price indicated by the pending trade line, with sl/tp set to the values of the red and green dotted lines. Once the trade is sent, the line changes back to its neutral colour to prevent further trading.
From here, the ea monitors the trade. When it finds the trade has closed, it examines your trade history:
- - if the trade closed at a loss, the ea resends the pending trade. If you happen to be watching, you will see the colour change briefly to its pending trade colour.
- if the trade closed at a profit or at breakeven, the ea will delete all the pending lines and can do no more.
Much of the rest is well-trodden territory by now. I have removed the swap and balance filters. There are the usual management features.