Metatrader EA Required to place trades (pending orders) on pivot levels if a moving average has already crossed a level. Alert me when it next crosses a level.
Please note, the EA comes alive or I turn it on, it then must look back and work out if MA has crossed up or down a level.
And I do expect you to test this EA works before sending me the file.
Detail:
Place pending order trades at pivot levels above and/or below one or 2 moving average lines. So I want to use either one or 2 Moving averages.
Places pending orders ready to open at Pivot levels if x moving average (x being number I enter so for exmaple 5 MA or a 13 MA)
Option to have 2 MA crossing pivot levels so have one or other or both.
If it (MA) has crossed pivot point level place a pending order above MA at the pivot level if it is going down or if MA is rising and crosses pivot level place a pending buy at the immediate pivot below the MA so that when the price candle touches it it opens. Then it closes the other. (OCO)
I will include the indicator code for pivot levels for you to use.
I need to be able to turn levels on or off and be customisable, i.e allow buy sell at H3, H4, R2, R1, M2 etc in other words I need to be able to individually select which pivots I want to use/be live levels.
My thought is once this is coded for one it will be a case of repeating the code for each pivot. More repetitive than complicated.
Need to enable buy or sell on pivot depending on direction of MA so if MA has crossed and is going down (one or both the MAs) then sell at pivot above MAs
or if MAs are rising then buy at pivot below MA(s)
Also need time constraint avalable so I can specify when the EA should run, i.e run between 09:00 and 1400 hrs GMT
I also need a option buy or sell depending on MA direction, or, buy and sell. I will call this “momentum or both”.
Explain: So if MA is going up and has crossed R1 level then the momentum option will place a buy at R1 (behind MA). If “both” option is selected then another pending order would be placed at the pivot above the MA line as well (so one above and below) at (presumably) PP line.
Once one is hit the option to OCO must be available (so i can choose whether OCO or not)
To to explain this in a real scenario:
Imagine a box. The top of the box is H2 and the bottom is H3. Price MAs are in the middle of the box going up, they crossed H3 going up an hour ago. At 0900 gmt I enable the EA. It calculates MA is rising (one or both MAs are rising up through level) and has entered the box travelling upwards.
If option “momentum” is selected then a pending buy order is placed at the pivot level BELOW the MA (the bottom of the box). This pending order is good until the next pivot level is breached by MA.
If option “Both” is selected then as above but the EA will place a pending order at the bottom of the box on H4 to buy and ALSO at the top of the box (H3) to sell. Both pending orders remain good until one is touched and opened. If I have selected OCO as true then it wll close the other pending order.
I need to tell it how many trades it can do while it is on.
I need to set the TP/SL level as a number or next level.
This is a long explanation but in essence place a buy or sell or both at pivot levels on the pivot levels I have decided I want live.
Once it has done a trade thats it, no more for the time period allowed, I don’t want it opening multiple trades unless I have enabled 2, 3, 4 etc.
So allow x live trades by EA while it is on or unlimited option please.
More real life example:
EA starts at say 08:00 gmt. The MA 13 and and MA 30 have both already crossed DOWN through H3 pivot line. The EA looks back and calculates this and places a pending sell order at the pivot level ABOVE MAs (in this case H4 assuming mid pivots have not been enabled). TP will be the next pivot/cam/mid pivot level. SL is user eneterd.
Pending order is placed and stays in place until the next level is broken by MA.
This will work on a 5 minute chart. I will use visual backtesting so it needs to leave a marker on the screen of where it enetered.
Lot size entered by user
I have a manage trade EA which code is also available. I would like the option to use this incorporated into the EA, so if the manage trade EA was enabled then TP would be infinite. This needs the option to change whether close 1/3 or half or all at first level.
Any more Qs please ask. I know it reads lot but it is quite simple, MA cross level, when EA come on look back and place order at level. To look back might be difficult.
I would expect you to check it works before sending me the EX4 file. I then check as well. I own source at the end of this.
The above description will be the test document. I will test this via backtest visual and in a demo account.