# How to code an [Invisible Stop Loss] Why it's necessary to confuse broker monitoring

Some will monitor your EA. They place you on a monitoring list after confirming that your EA is profitable. Then they monitor the EA’s trading strategy, predictability and stop-levels. If your EA is predictable, they’ll look for ways to manipulate price. for this reason, I inform coders to only utilize take-profit levels, but not use stop-loss levels.

Instead, of using a stop-loss, code in when to close the market order whenever price declines in its opposite direction by a specified amount of points. [This effectively is a hidden stop loss].

Example: If price > 20 points below your buy market order, select the order and close it. (This creates an invisible stop-loss and perplexes the broker, making it difficult for them to predict the nature of your EA).

At the end of the day, a forex-broker earns money in 3 ways: 1. Commissions, 2. Spread fee and 3. Every-loss trade. Therefore, they profit when you lose, and would prefer to not pay you if you win.
How much money do they make per day?
If a broker has 5 million active traders on its server losing trades in addition to applying aforesaid fees, the math of this equation approximates to: (1=Day of trading + (5 million * \$0.50 spread) + (\$1 commission * 5 million) + (\$50 trades loss * 5 million) = \$257,500,000. PER DAY! (Not including the profits generated by the losses of financial institutions). Therefore, they can easily afford to pay your profitable EA.

[Now for Beginner Coders who’d ask me:]

Ok, “30-Dimensions”, How do you code an invisible stop-loss? Ans. Like this:

(The beauty of coding mql4, is there are multiple routes to achieve one goal.) For example purposes: The code below is structured to close the order after 20 pips negative to entry price. If the the current market price reaches 20 pips opposite of your sell, the order will be closed. (Though this code will compile in mql4, it’s only for example purposes. If you wish to use it for your EA, you should definitely swap out the “If” statement with one that suits your trade conditions.)

``````int     market_order_sell_type  = OP_SELL;

int  sell_market_total       = OrdersTotal();
if(  sell_market_total <1){
bool refresh_the_rates       = RefreshRates();

Print("RefreshRates return=:"," ", refresh_the_rates);
int  market_order_sell_send  = OrderSend(_Symbol,market_order_sell_type,lot_size_volume,Bid,set_slippage,0,0,NULL,magic_mumber,0,clrNONE);
}
int     get_magic_number     = OrderMagicNumber();
double  get_order_open_price = OrderOpenPrice();
int     get_order_ticket     = OrderTicket();

Print("OrderSelect           return=:     "," ",   select_market_order
," ", "OrderMagicNumber      return=:     "," ",   get_magic_number
," ", "OrderOpenPrice        return=:     "," ",   get_order_open_price
," ", "OrderTicket           return=:     "," ",   get_order_ticket);

if(select_market_order    == true &&          get_magic_number == 222333){
double  set_invisible_stoploss =                   get_order_open_price + 200*_Point;
Comment("Invisible stop=:                 "," ",   set_invisible_stoploss
," ",   "OrderOpenPrice=:                 "," ",   get_order_open_price
}
int       get_order_error    = GetLastError();Print(get_order_error);
}``````

Hidden stop loss, why this makes absolutely no sense!

A stop loss is part of your risk management plan.
Under normal circumstances a stop loss order is a pending order. It will wait on the sidelines at the preset price value on your broker’s sever. The only way price will move is for buyers or sellers to enter the market with market orders and clear out all pending orders at the current bid or ask.
Having your stop loss hidden from your broker means you risk numerous things. If you data connection fails you will have a problem. You also risk slippage from your desired stop loss level since your algorithm will only send a stop after your level has been recognised.

So since a stop loss is part of your risk management plan playing around with silly techniques to hide your stop is playing with fire.

It is illegal for brokers to run stop-losses in the UK. Stop-running here is a theoretical risk: failing to set a stop-loss is a very real risk of wipe-out.

1 Like

If you think your broker will manipulate their entire platform just to get your money, maybe you should choose another broker.

2 Likes
1 Like

I really needed that laugh!!! omg! wow

They can’t it all depends on how your EA is coded my friend. Risk-Management is king and an invisible stop loss has been working fine for me, so I don’t know where all of this negative energy stems from but mainly I’m beginning to notice that it’s always those who are upset that they aren’t profitable. Those who are making a living from trading seem to deliver different feedback. It’s very weird to me…

My apologies then. I know now, but you replied to the post so it’s logical for the originator to assume you were replying to them personally. All the best.

1 Like

No problems. Onwards and upwards.

1 Like

I think we can notice that even if we want a reply to be tagged to a specific post, it is often not marked as such so it just looks like a general response to either the whole thread or to the original post, both equally understandable, or indeed any random post in between the start and today. I think it’s just a minor defect in the software.

1 Like

*** People Person who loves People.**
*** Loves to teach and Learn.**
*** Loves networking with others and teaching others.**

Right, obviously.

Under normal circumstances a stop loss order is a pending order. My guy, a Stop Loss order isn’t a “Pending Order”. Like what are you talking about even? Refer here: Stop Loss is a “Stop Order” Mql4 documentation

From the Mql4 book itself:

StopLoss is a stop order; it is a price set by trader, at which a market order will be closed if the symbol price moves in a direction that produces losses for the order”. If you’re gonna refute someone’s code/trading suggestions based on Mql4/5 language, then at least know what you’re talking about?

A Stop Loss is a “Stop Order” as well as a Take Profit is a Stop Order. They aren’t pending orders.

A stop loss hinges upon your broker’s “stop level” requirement in which you’re able to access using the MarketInfo() function via the parameter constant “MODE_STOPLEVEL”: See Here: MarketInfo() Identifiers and constants Mql4

Are you even a Coder?/Programmer?

I forgot to include: Except people who like to be trolls, and imply that you’re stupid. I mean it’s fair to say that I didn’t attack anyone who didn’t attack me first? The only thing I did was post a code to help/assist people only to log in and see that I’m being called stupid? Like is that cool?

You guessed right.
I’m not a programmer.
But following your link to see the information about stop loss being equivalent to a stop order and ultimately executing as a market order, I also noticed that MT4 seems to ultimately treat every order as a market orders.

Anyway
My whole argument is if you want to use a stop loss, due to various risks it is best to send attached stop loss order with your entry. That way the risk of excessive loss due to unforeseen circumstances is minimized.

@30-Dimensions
Just a note, I’m not having a go at you personally with your idea and your post. I recognize we all have different opinions. But my comments are aimed towards those who may read this thread in the future and give them a balanced perspective with understanding for my point of view.

“My whole argument is if you want to use a stop loss, due to various risks it is best to send attached stop loss order with your entry. That way the risk of excessive loss due to unforeseen circumstances is minimized”.

Let me see if I’m following your discourse correctly. In essence, it seems like you’re basically arguing: “Don’t ever not use a Stop Loss. Always use a Stop Loss”?

If that is your stance, then not only do I agree with you, but also you’re not disputing my code nor my application of it after all because my code actually utilizes a “Stop Loss” with the exception that it’s “Unseen” or “Hidden” from plain sight unlike a common application of a stop loss. Therefore, any coherent risks are still mitigated, and no additional risks apply to any one given trade in comparison.

“Ultimately executing as a market order, I also noticed that MT4 seems to ultimately treat every order as a market orders”.

Whenever you place an order in mt4, and the corresponding “Ask” or “Bid” quotes are reached, only then will it convert the order into a Market Order if one hasn’t initially set it as that type. Afterwards, when the actual TP/SL distance of your order is reached and said order is within the confines of the proper amount of slippage required to close it, the Mt4 server will terminate the order/close the order by two means: 1. By using the “OrderClose()” function if the order was submitted by an AI trading algo/coded program: SEE MQL4 OrderClose() Function Also SEE: MQL4 CLOSING AND DELETING ORDERS Or 2: by manual means: SEE: CLOSING A POSITION IN MT4 TERMINAL

May this be clear to anyone who reads it.

1 Like