Scalping on MT4 !!

 

It has been a while since I have been to any forum; the truth is that I have lost interest and decided to focus on my own development.

The reason I came back is to share a peace of information, which could be on an interest to some traders; I don’t think such information has been shared before , certainly my friends didn’t know about it, so if it was shared before then at least I brought the issue back to life.

My professor taught me that we should never use the absolute term in speech or writing as things changes over time and what’s wrong now may becomes right later on and vise versa, so apply that to my post in case MetaTrader decided to improve their platform.

Now to the main subject:

In my humble opinion using a program such an “Expert Advisor “ in MetaTarder “MT4” as a SCALPER may cause the trader a great damage not because the code is not correct or not fast enough but rather due to the fact that MT4 is not suitable for scalping.

I am sure many of you knows that in the back of their mind, who didn’t create or own an code that makes a fortune on backtest tick data and lose big time when used on the market ? Now lets go to the reason why this happens.

Instead of writing what lead me to this conclusion, I will ask you to make one of those two simple tests to verify my claims.

The purpose of the test is to illustrate that the price can move several ticks before MT4 codes respond to such movements.

Steps :

Write a simple code, the code can be an expert advisor EA, indicator or script it wont mater they all will fail.

In the main body where the start function you can either display the Bid, Ask as comments using the simple commands:

Comment("Bid= ", Bid);

Comment("\nAsk = ", Ask);

Or you can write a test code to count from (1 to 5) on the same line using the simple commands:

Comment("\1"); Comment("\2"); Comment("\3"); Comment("\4"); Comment("\5");

You can save the code as an expert , indicator or script it wont matter.

Now open 1 min chart on an active pair like GBPUSD and display both the bid and ask lines on the chart , or you can watch the price changes on the top right corner of the chart.

Attach your code to the chart.

Now watch the Bid and Ask lines changes on the chart and see if your code been updated or run ?

What you will notice is that the price moves several ticks, sometimes only the Bid move other times only the Ask or they may move combined but what’s important is that the price moves several ticks can reach to 5 ticks before the code runs or update the comments with the new data. This apply to use a script , EA or indicator.

Which means the broker doesn’t need to know your stoploss , all what he need to know is when you send the order to his server to close the scalping trade, he knows that it takes few ticks for the MT4 to respond and that’s enough for any broker to take advantage of your trade.

So

if(IsConnected() && IsTradeAllowed() && !IsStopped() && !IsTradeContextBusy()){ …..}

May not do much if the MT4 is still sleeping

I have even tried with Global variables , spread changes …etc the results are the same , MT4 will take several ticks before the code runs, and when I brought the subject with my respected broker his answer was no program on MT4 works on tick data !! So my question what’s the use of tick data backtest if the MT4 doesn’t respond to tick data ?

If I am wrong about my findings I hope someone will be able to give the right approach to program a code that responds to a tick data and give me a better answers than my broker

Best of luck in life and trades,

Fadi / MiniMe

 

No I did not know about the tick lapse by metatrader, certainly metatrader cannot be instant but 4-6 ticks is a quite a long time.

I wonder if in Metatrader 5 the same issue is present, I'll try to test it to confirm the difference in behaviour.

I also have not posted in ages but I am restarting the process with MT5 and hopefully they have not built in more way to make our life difficult.

Sunwest

 

very fast trades..

only possible when u run a scipt with "no requotes malfunction"

some brokers prevent it with dealing desk so needd a broker which is reliable

Files:
scalp.rar  154 kb
 
wirefax:
Explain to a newbie, what is scalping?*

Scalping is when a trader try to "steal" few pips mostly in an active market during the news.

its very stressful, not to mention that human is considered slow compared to market movement during the news.

That's the most common type of of scalping , some traders use the slow slow Asian session for scalping other use different method , the general concept is the same , taking few pips and close the trade ASAP

Using a written code for scalping should remove the stress and speed up the process.

Not only that , programmers try to improve their code to work as fast as possible to save time on few milliseconds , an example would be

//----

Total=0;BuyStopNo=0;SellStopNo=0; BuyNo=0; SellNo=0;

for (int i = OrdersTotal() - 1; i >= 0; i--)

{

OrderSelect(i, SELECT_BY_POS, MODE_TRADES);

if ( OrderMagicNumber() != iMagic && OrderSymbol() != Sym ) continue;

cmd=OrderType();

if ( cmd == OP_BUY ) { Total++;BuyNo++; }

else if ( cmd == OP_SELL ) { Total++;SellNo++; }

else if ( cmd == OP_SELLSTOP ) { Total++;SellStopNo++; }

else if ( cmd == OP_BUYSTOP ) { Total++;BuyStopNo++; }

}

Notice the use of "cmd" and Sym, using cmd will avoid calling the function OrderType() , 4 times in the worst case and instead its called only once in each loop , and that would save time.

The question is it worth it saving time on MT4 for scalping?

a code written in MT4 is supposed to run each time a new price is received which means a new "tick", script written in MT4 should be always ready for new tick to execute.

Brokers generously provides free tick data to download so as you can build your code and test it as if it was running on a live active market ... is that true ?

ignoring the fact that we can not test the spread changes historically , many traders/programmers build over the years codes that backtest nicely but fails on real market, there are many reasons for that.

ONE of the reasons is what I have mentioned in my previous post , which is MT4 is not fit for scalping , the platform is slow and I doubt MT5 will be any different . IMHO its an intentional deficiency and I though I should alert traders/programmer for this issue.

 

Hi MiniME,

Nice to see you again.

Not only what you mension gives problems in scalping but there are other more scarry elements that make if difficult with some brokers to scalp.

The following text was an inside mail that was leaked to about a complaint that I made on some of the executions on my trading platform.

After I red it I sure felt: to say the least.

1.) All ECN systems are "asynchronous" and require a certain amount of buffering, or "space/time" to avoid order collisions we refer to as "ships colliding in the night", where the cancel or handling of an SL/TP can result in a reject and fill at the same time an instant close is issued, resulting in double orders or an "out trade". The normal handling of this "space" in the process is conducted per Metaquotes on the Freeze / SL constant which the EA author can interrogate at any time to know the standard distance the server is configured for.

2) Historically brokers have handled this with "static" Freeze zones of between 3 and 6 Pips, plus "Invisible delays", meaning once the market was within that distance of the target side, the trade becomes committed to a "Point of no return" where the fill is considered "imminent", unless the market should turn back. The brokerage delays the order until the cancel SL/TP is completed, then fills the trader with slip from that delay, (possibly skimming the slip as well). More and more, ECN brokers have been adopting the infamous "magic dealer" plugin which radically whips the freeze and sl zones dynamically, (unfairly), without updating the related Freeze / SL constants, each time the market goes into volatility. This, we consider to be a violation of No Dealer STP commitment ATC refuses to impose on our system, most often used to "Skim" slippage to the broker, as well as avoiding the "ships colliding in the night".

3.) The nature of ECN trading exposes a dynamic spread. ECN trading existed well before the days of dealer buffered, fixed spread, retail operations. In recent years, FXCM developed a "Hit-and-miss" round robin process of requesting committed quotes with every order, then issuing to the best confirmed, but then receiving back "too late to fill", moving to next best bank, etc., etc. This creates a delay of fill for orders near the current market and for some banks can vacuum off available liquidity at that level. The delay means that a trader may "FEEL" or program his EA, to escape an SL by a couple of Pips, if time has gone by. Unfortunately, the traders SL / TP is a "Commitment", whereby the act to "revoke" that commitment just as it's likely to fill, can be compared to the broker using a dealer to make it look like volume is gone, when it is not. The broker prepares to convert the SL/TP to market based on "Timeliness" with their banks. When the spirit of a commitment to order becomes "plastic" then the trader is behaving the same way a broker would, engaged in "stop hunting", e.g. "I'm going to put a stop "here" to make you THINK that's my target, but then I'll close by market and "stick the broker" with the sl/tp fill after the fact". In essence, this is like a "Cheat" where we commit to an order, but then unfairly revoke it at the last minute. Market orders ARE a commitment to fill, (at whatever the price might end up AFTER delay to successfully cancel the SL/TP FIRST!!!! ) ATC also does not pull that stunt on traders. We simply tell you, 1 pip on all order setups, 2 pips on the sl/tp against a market close.

Can 2 pips be considered extreme? Not in forex. We've seen Freeze/SL zones as high as 12 Pips and time-in-market requirements as high as 15 minutes. We see two pip spread expansions dynamically in these networks all the time. Even if these come by way of the broker changing the mark-up on he spread at the last minute, he's entitled under law, to set his price for the apples he's selling on the street, so long as the bid and ask both changed the same amount. It is the nature of an unregulated system which falls under a certain amount of voluntary regulation per each country, such as the US now requiring 50:1, QUITE unfairly, in my opinion, literally risking to put the US back a full decade in our pursuits to catch up to European success in Forex.

I'm sorry this restriction is an imposition for some, however I will not impose invisible delays or pull a hidden dealer stunt on our traders, before honestly telling them, if you're going to play fake on SL/TP targets, widen your targets by two Pips and you'll have no problem.

Friendly regards...iGoR

 

What is a TICK?

Thanks iGoR for the information .

According to MT4 the start()" function runs on each new tick , this is not totally true as I pointed out, so I tried to find what cause a change in a tick ?

According to MT4 a tick "is an event characterized by a new price for a symbol at some moment." ... this is also not totally true.

I found an old topic about this issue on MT4 code base by phy , this is the link to the topic

What is a TICK? - MQL4 forum

and some of phy findings

phy 2008.07.03 18:27 To restate:

My basic finding is if there is a change in MarketInfo() for the pair, a "tick" is received.

.

There may be exceptions, like "no changes found" but a tick was received, but it is very rare.

Ticks received with no price change are not rare, and signal some other change in MarketInfo for the pair.

.

Volume is equal to the number of ticks received, i.e. the number of times the start() function was called, it is not specifically trades or Bid/Ask changes. Change in MarketInfo()triggers a tick, and tick count = volume.

I have found that a "tick" is received with no Bid/Ask change on the tested pair when there is a change in the MarketInfo TICKVALUE, and also change in MARGINREQUIRED. So, a change in another currency pair can cause a tick to occur on the Pair Under Test. Ticks come with changes to MarketInfo() values.

So... New definition for MT4 tick is:

A tick is a notification from the Dealer about a change in current dealing prices or trading conditions/parameters.

.

that raises the question, why some of these changes would be used to drive chart bars and chart "volume"...