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
Height of previous bar
Hi,
Can you please give the code for previous bar.
This can be used in the EA to limit placing the orders when the previous bar is more than certain height.
Regards,
SIDDESH
Plz correct my code (basic EMA, STOC etc.)
hi.. im new here n new to mql4 coding.. i've construct few codes based on specific condition.. hope u guys can help me to correct if theres any mistake..
okay.. lets begin
1) EMA CROSS
BUY if:
- EMA 5 > EMA 18
- both of the line is upward
- different between current n previous price for EMA5 >= 10pips
currently im using this:
double EMA5 = iMA(NULL, 0, 5, 0, MODE_EMA, PRICE_CLOSE, 0);
double EMA5_prev = iMA(NULL, 0, 5, 0, MODE_EMA, PRICE_CLOSE, 1);
double EMA18 = iMA(NULL, 0, 18, 0, MODE_EMA, PRICE_CLOSE, 0);
double EMA18_prev = iMA(NULL, 0, 18, 0, MODE_EMA, PRICE_CLOSE, 1);
if (EMA5 > EMA18) {
if ( EMA5 - EMA5_prev >= 10 && EMA18 > EMA_prev) {
Order = BUY;
}
}
[/CODE]
2) RSI
double RSI = iRSI(NULL, 0, 18, PRICE_CLOSE, Current + 0);
double RSI_prev = iRSI(NULL, 0, 18, PRICE_CLOSE, Current + 1);
if (RSI > 50 && RSI > RSI_prev) {
Order = BUY;
}
[/CODE]
3) STOCH
Buy when the Oscillator (either %K or %D) falls below a specific level (e.g., 20) and then rises above that level. Sell when the Oscillator rises above a specific level (e.g., 80) and then falls below that level
[code]
double STOCH_K = iStochastic(NULL, 0, 5, 3, 3, MODE_SMA, 0, MODE_MAIN, 0);
double STOCH_D = iStochastic(NULL, 0, 5, 3, 3, MODE_SMA, 0, MODE_SIGNAL, 0);
if (STOCH_K < 20 || STOCH_D < 20) {
Order = BUY;
}
* i think i've skipped the red one.. dont know how to do that part..
Buy when the %K line rises above the %D line and sell when the %K line falls below the %D line
[code]
double STOCH_K = iStochastic(NULL, 0, 5, 3, 3, MODE_SMA, 0, MODE_MAIN, 0);
double STOCH_D = iStochastic(NULL, 0, 5, 3, 3, MODE_SMA, 0, MODE_SIGNAL, 0);
if (STOCH_K > STOCH_D) {
Order BUY;
} else
if {STOCH_K < STOCH_D) {
Order SELL;
}
4) In Stoc coding, MODE_MAIN indicates for what? MODE_SIGNAL indicates for what?
5) how to put auto close and auto on timer for EA?
eg: set open at 8am and close at 5pm
6) how to put disable EA on other chart when a post is opened?
such as use an EA on 2 pairs (GU and EJ) when a post on GU is opened then disable EA on EJ..
sorry if this question is quite basic.. hope u guys can teach me.. thx
A Tricky Stoploss - can you help with this?
I have put together a trend riding EA. When profit hits a certain level, I want to move the stoploss for PART of the open lots, to that profit level. I would let the rest of the lots be (or move the stoploss for the rest up to break even).
I am not using a Take Profit.
How do I code this?
Thanks,
Big Be
... When profit hits a certain level, I want to move the stoploss for PART of the open lots, to that profit level. ..
How do I code this?
Thanks,
Big BeYou cannot do that unless you have multiple positions : there may be only one SP/TP by position. But you can close a part of a position : just put the number of lots you want to close in the OrderClose(..) function.
What you also can do (it depends of your broker) is to place a pending stop (hedge) for the part you want : then later you have to do a "CloseBy" command or function.
#import question
hi all
i ned to cal this API function in MT4
int GetMouseMovePoints(
UINT cbSize // size of the MOUSEMOVEPOINT struct
LPMOUSEMOVEPOINT lppt, // pointer to current mouse move point
LPMOUSEMOVEPOINT lpptBuf, // buffer to store the points
int nBufPoints, // how many points the buffer can store
DWORD resolution // resolution of the points
);
please tell me the #import clausule
thanks
hi all
i ned to cal this API function in MT4
int GetMouseMovePoints(
UINT cbSize // size of the MOUSEMOVEPOINT struct
LPMOUSEMOVEPOINT lppt, // pointer to current mouse move point
LPMOUSEMOVEPOINT lpptBuf, // buffer to store the points
int nBufPoints, // how many points the buffer can store
DWORD resolution // resolution of the points
);
please tell me the #import clausule
thanksMoved your question to this thread.
One trade per bar?
I know this has been covered before, but can someone show me some code to allow only 1 trade per bar?
Thanks.
Michel,
Thanks.
I was afraid of that.
Now I have to learn "fun with Magic Numbers".
Big Be
Question!!!
How do I code this?
If previous 6 trades were a loss, I tried this, and it won't work!!!
int MTL;
extern MaxTradeLoss=6;
int start()
{
for(int b=0;b<MaxTradeLoss;b++)
{
if(OrderSelect(b,SELECT_BY_POS,MODE_HISTORY)==true)
{
if(OrderSymbol()==Symbol() && OrderProfit()<0)
{
MTL++;
}
}
}
MTL=0;
return(0);
}
How do I code this?
If previous 6 trades were a loss, I tried this, and it won't work!!!
int MTL;
extern MaxTradeLoss=6;
int start()
{
for(int b=0;b<MaxTradeLoss;b++)
{
if(OrderSelect(b,SELECT_BY_POS,MODE_HISTORY)==true)
{
if(OrderSymbol()==Symbol() && OrderProfit()<0)
{
MTL++;
}
}
}
MTL=0;
return(0);
}
your statement MTL=0; pretty much sets MTL to zero regardless what it counted in the "for" loop. That line should be before the "for" loop and not after.