Loading…

Entry Price Improver

Waiting for a small pullback before entering at market is a reasonable way to shave a few points off the fill, but an unbounded wait has an unbounded downside: if price never pulls back, the signal is silently missed altogether, which is a strictly worse outcome than the small amount of slippage the wait was trying to avoid in the first place. This header bounds the wait explicitly: arm it with the signal price, a pullback distance in pips, and a maximum wait in seconds, and it reports either "pullback reached, enter now" or "timeout reached, enter now anyway" - it never reports neither and leaves the signal hanging forever. The header is split into a pure decision function and a separate action function, the same split this catalogue's other trade-management headers use. EpiEvaluate() reads the current state, a caller-supplied price and a caller-supplied time and returns a decision code without sending anything - which means it can be driven with synthetic price/time values for testing, exactly as the demo does, without needing to wait on live ticks or risk a real order. EpiFireMarketEntry() is the separate, thin wrapper around OrderSend that actually enters, called only once EpiEvaluate has returned one of the two FIRE codes. Notes and limitations - The wait is time-bounded (seconds via TimeCurrent()), not bar-bounded. A bar-count cap can be built on top by comparing Bars/iBars() at Arm() time against the current count instead of calling EpiEvaluate with a TimeCurrent()-derived nowTime - the pure decision function does not care which clock the caller uses, since both the armed timestamp and the "now" value are supplied by the caller, not read internally. - EpiFireMarketEntry() sends a real OrderSend - this is the one acting function in the header. Only call it from the branch that already checked EpiEvaluate's return value. - Only one wait can be tracked per SEntryImproverState instance; track an array of states if more than one signal can be pending improvement at once. - No retry logic around EpiFireMarketEntry() itself - if the send fails (requote, off quotes, trade context busy), the caller's own error handling decides what happens next. This header only decided WHEN to attempt the entry, not how to recover if the attempt fails.

Script · MT4 · v1.0 · Free

About Entry Price Improver

Entry Price Improver is an expert advisor (trading robot) for MetaTrader 4. It has 2 settings, such as Pullback pips and Max wait seconds. MQL source code included.

Files in the download: EntryPriceImprover.mqh, EntryPriceImprover.txt, EntryPriceImproverDemo.mq4.

Trading robots can lose money. Check every setting and test on a demo account before using real funds.

Settings

SettingDefaultWhat it does
Pullback pips3.0Pullback required before firing early, in pips
Max wait seconds60Hard timeout - fires at market regardless past this

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Experts.
  3. Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
  4. Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
  6. Test it first on a demo account or in the Strategy Tester.

Download the PDF guide

Tags: Buy/Sell Arrows · MT4 Script · MQL4 Source Code

MQL4 & MQL5 scripts · PolyMaria