| New signals service! | |
|
|||||||
| Register in Forex TSD! | |
|
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time). Click here to register and get more information |
|
![]() |
|
|
LinkBack (1) | Thread Tools | Display Modes |
|
|||
|
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 Attachment 53944 currently im using this: Code:
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;
}
}
<-- BUY CODE -->
2) RSI Code:
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;
}
<-- 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;
}
<--- BUY CODE --->
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;
}
<--- BUY & SELL CODE --->
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 |
|
|||
|
Quote:
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. |
|
|||
|
Quote:
The code for the previous bar is below: //to buy double indicatorpast = icustom(....................,1); double indicatornow = icustom(....................,0); if (close[1]<indicatorpast && close[0]>indicatornow) OpenBUY(); if (close[1]>indicatorpast && close[0]<indicatornow) OpenSELL(); but with this satatement, the expert opens positions not only when the price cross the indicator, it opens position above the indicator too. I want that the expert open position ONLY when it cross the indicator, so i tried that: //to buy double indicatorpast = icustom(....................,1); double indicatornow = icustom(....................,0); if (close[1]<indicatorpast && close[0]==indicatornow) OpenBUY(); if (close[1]>indicatorpast && close[0]==indicatornow) OpenSELL(); But this statement it is not performing. Do you know what is happen? Because i think there arent errors in the statement. The question is why is not opening at the exact point of cross when close[0]==Indicatornow? If the function would be with ==, we will prevent the open of orders above the point of crooss between the indicator and the close of the present bar but is not funtioning with this type of relationship between the variables. Last edited by la totona; 02-14-2008 at 10:42 AM. |
|
|||
|
#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 |
|
||||
|
Quote:
__________________
|
|
||||
|
Quote:
Last edited by azmel; 02-12-2008 at 09:18 AM. |
![]() |
| Bookmarks |
| Tags |
| candle time, CHinGsMAroonCLK, coders guru, expert advisor, forex, how to code, I_XO_A_H, mechanical trading, trading |
| Thread Tools | |
| Display Modes | |
|
|
LinkBacks (?)
LinkBack to this Thread: http://www.forex-tsd.com/metatrader-programming/554-how-code.html
|
||||
| Posted By | For | Type | Date | |
| Need an experienced programmer? - Page 2 | Post #0 | Refback | 09-24-2008 07:24 AM | |
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to code this? | iscuba11 | Metatrader 4 mql 4 - Development course | 1 | 08-03-2007 05:22 PM |