![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Simple hedge code needed
Programmers, Coders,
I want to insert a simple hedge function into an existing EA, so that when the open position is in a loss of (x) pips (MaxLoss) it triggers a hedge entry of (x) multiple lots. It needs a Hedge TP/SL with the option to exit on the next underlying entry. If anyone could provide me with a snippet of code or template I could insert it would be greatly appreciated.
Trader1
Are you still around RickD?
Just came across this thread. Eventhough it's been a while since anyone posted here, I wanted to say thanks for the very useful code. The simplicity is wonderful.
In case you are still around, I have a good one for you. I am working with the timeline and trying to comeup with an average time difference between a recurring event. Then, I am trying to get the last event and add the average to that last occurrence. The thought being that there may be some value to knowing the possible average position of the next event.
You could say that the event is something like an macross up, or even a zigzag high.
Again thanks for the beautiful code.
ADD PARABOLIC SAR to EA as a filter
I want to ADD A PARABOLIC SAR to EA as a filter. (currently 99% win rate but one losing order kills the account)
trading functions
Hey I was wondering if there any quick drop-in functions that i can include in my ea's for trading functions, ill add a few for you guys that i created, i was hoping to have something similar for the following:
open buy trade
close buy trade (specific trade)
open sell trade
close sell trade (specific trade)
close all buys
close all sells
add trailing stop to buy
add trailing stop to sell
count open buys
count open sells
any other functions that control trading..
the simpler to initialize these functions the better imo
here is my donation to this project
this is for creating labels and lines on the chart
void LineMaker(string name,color LineColor,double price, string Description){
ObjectCreate(name, OBJ_HLINE, 0,TimeCurrent(),price);
ObjectSet(name, OBJPROP_STYLE, STYLE_SOLID);
ObjectSet(name, OBJPROP_COLOR, LineColor);
ObjectSet(name, OBJPROP_BACK, true);
ObjectSetText(name,Description,8,"Arial",LineColor);
return(0);
}
void LabelMaker(string lblname,int x,int y,string window,string txt,int size,string font,color txtcolor){
ObjectCreate(lblname, OBJ_LABEL, WindowFind(window), 0, 0);
ObjectSet(lblname, OBJPROP_CORNER, 0);
ObjectSet(lblname, OBJPROP_XDISTANCE, x);
ObjectSet(lblname, OBJPROP_YDISTANCE, y);
ObjectSetText(lblname,txt,size,font, txtcolor);
return(0);
}
as you can see i try to make it so its just a 1 line piece of code so that its easier to manage
my idea is to make programming easier and less code with just including the functions into the ea which would allow for easier manipulation.
thanks in advance
Please Help with Code
Hi
can someone pls help with my code it do not know programming tried this but can not get it to work
what I want is that when I have either 9 open buy or 9 open sell positions and my account profit is > 0 it must close all open positions
extern int TradeNo = 5;
extern int Slippage = 3;
extern double Profit = 10;
int start() {
int BuyCnt = 0;
int SellCnt = 0;
int cnt = OrdersTotal();
if (AccountProfit () > Profit);
and
( TradeNo !=>BuyCnt )
if (AccountProfit () > Profit);
and
( TradeNo !=> SellCnt)
{
void CloseOrders ;
for (int i=cnt-1; i>=0; i--) {
if (!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue;
//if (OrderSymbol() != Symbol()) continue;
//if (OrderMagicNumber() != Magic) continue;
if (OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), Slippage);
if (OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), Slippage);
}
}
return (0);
}
can someone please help me get this to work
many thanks
alfgrob
Help in MQL4 programming I will pay for that!
Please, can you make me an Expert Advisor:
My strategy is based on the logic that:
1. Most candles (more than 90%) have tails.
2. The first tail is formed before the body is formed.
3. If the price is moving upward from the Open price, most probably - on a 5m candle - it is going to be the first tail. Roughly it can be 3-5 pips. So a Sell opens at 3 pips up the open price with a StopLoss of 5 pips. If the candle is moving in the same direction, forming its body, the trade will close at 8th pip from the Open price.
3. If the price is moving downward from the Open price, most probably - on a 5m candle - it is going to be the first tail. Roughly it can be 3-5 pips. So a Buy opens at 3 pips down the open price with a StopLoss of 5 pips. If the candle is moving in the same direction, forming its body, the trade will close at 8th pip from the Open price.
4. Position will close - either at StopLoss of 5pips, or 10 pips Profit, or on a TrailingStop of 5pips, or at the end of 5th minute whatever price - profit or loss.
5. Then again a new trade.
6. The EA should do 288 trades a day on each pair, even with less profit or a little loss is also ok.
7. I will use the EA on 4 pairs in each account, selected on the candle pattern of Tails.
Please let me know if it's clear.