Job finished
Specification
Hallo,
MAXIMUM BUDGET $50. it needs to be completed within 5 hours of taking the job.
---->>>>>AT PRESENT:
- My first order, opens to a certain set of criteria. the below is a filter for opening the rest of the grid trading.
- Currently my EA places BUY orders spaced according to the set pips. ie. 20 pips. so everytime price moves 20 pips away from the last order, it will place another buy order. This is the code for it: Last(0,"op")-step >= Ask
- MaxOpenPositions > Positions() -> I limit the number of positions that are allowed to open
- ClosedBar() + CurrBar() - EA will not open a new position if one is already opened in the current bar
- step>=minstepgrid*point() - The EA is not allowed to place orders if it is not equal or bigger than 20 pips ( when using geometric griding according to % and not pips)
- (!EnableATRgridFilter || (atd7[1] < MAXATRforgrid*point()) - the EA will not place an order if the Average True Range is above a certain level.
---->>>>>PROMBLEM:
Summary: see attached screenshot: EA does not use lowest price to place next buy, it uses last buy orders price to place next buy.
See second screenshot, the pink question mark is where the EA must grid upwards. spaced 20 pips from on another.
Firstly:
I have a button on my EA, that allows me to place an order manually with the same magic number. But if my manual order is higher than the last placed buy order, then the EA will use my last placed buy order which i placed manually - 20 pips to place the next buy order. It is therefore not using the lowest BUY order placed. Ie. say i grid every 10 pips. If first position opens at price $0 and the first grid step will be at $10 and the second grid step at $20. If Price moved to $10 and opened first grid and then retracted to $5 and I manually enter a buy there, the EA will open the next grid at $15 and not at $10 plus 10 pips.
Secondly: With this code: (!EnableATRgridFilter || (atd7[1] < MAXATRforgrid*point()) the ea will skip grids on the way down untill the ATR settels back to the correct levels. BUT, it will not place orders on the way up. I want it to grid upwards also.So say price is $0 and ATR is to big, and price moves to $20 and the ATR settles there- it will open a grid currently... But as price retracts to $10 i want it to place a buy order at $10. So that the spacing of orders will if price moves correctly be $0 $10 $20 $30. Also if price moves Say from $0 to $20 and ATR settles there, then the EA may open the grid at $20, say price then falls to $22 and i manually place a grid order at $22, price then retracts on its way bakc to $0, the ea can place an order at $10 cause. as the rule below says the ea is not allowed to grid if orders are smaller than 20 pips from one another. so it will not use $22 minus 10 pips and place one at $12.
MOST IMPORTANT: THE EA is not allowed to place grids within 20PIPS (or whatever i set it too) within one another.
Here is the current code:
if(EnableGRID && Last(0,"op")-step >= Ask && 0 < Positions(0) && MaxOpenPositions > Positions() && ClosedBar() && CurrBar() && step>=minstepgrid*point() && (!EnableATRgridFilter || (atd7[1] < MAXATRforgrid*point()) ) )
{
double lot=Lot(0);
MarketOrder(Symbol(), POSITION_TYPE_BUY, lot, 0, 0, 0, Magic, Slippage*PipValue);
}