I have two indicators RSI(13) and RSI(42). if RSI(13)-RSI(42)>=10 is BUY...etc. How to code a EA do it. thanks a lots
- How to draw 2 RSI(13) and RSI(42) at one Chart?
- How to get 2 values on 1 indicator by EA?
- How to stop or limit commands in EA?
akira.nguyen:
I have two indicators RSI(13) and RSI(42). if RSI(13)-RSI(42)>=10 is BUY...etc. How to code a EA do it. thanks a lots
I have two indicators RSI(13) and RSI(42). if RSI(13)-RSI(42)>=10 is BUY...etc. How to code a EA do it. thanks a lots
How to code? Start here https://www.mql5.com/en/articles/1514
When you have digested this article, the following framework may be useful to you.
It is based on the principle of breaking up your code into numerous small functions.
When each function is proven to work, you forget about it and concentrate on the logic of your EA.
ALL of the functions mentioned in the framework have been discussed in this forum and are available for free.
But YOU have to do the legwork to track them down. Best wishes, Helmut
int start() { if( IsTradeAllowed() != true ){ return(0); } // first set the global variables your functions need to know, for example... RSI13 = iRSI(NULL,0,13,PRICE_CLOSE,0); RSI42 = iRSI(NULL,0,42,PRICE_CLOSE,0); count_positions(); // returns the number of open positions (you may have to search for "Open Positions" etc.) if( numPos > 0){ CheckForClose(); // tests your conditions for exiting and calls closing functions SetTrailingStops(); // tests if stops should be adjusted for any open positions } else // prevents adding more positions (optional) { if( LastSignal != Time[0] && stoptrading == false ) // reset extern "stoptrading" to true to keep the EA running without taking new positions { if( get_signal() == true ) // tests your entry conditions and sets Buy and/or Sell signals { SetStops();// sets stop-loss (sl) and take-profit (tp) levels Call_MM(sl);// sets Lots based on capital and risk tolerance if (Lots > 0) { if( Buy == true ) OpenLong(Lots); if( Sell == true ) OpenShort(Lots); } LastSignal = Time[0]; } } } return(0); }
engcomp:
How true indeed.
We should have remembered Mathew 7:6 "neither cast ye your pearls before swine".
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