Download MetaTrader 5

Im a beginner, can someone link me to a code base similar to what im trying to perform

To add comments, please log in or register
Trade with MetaTarder 5. Download it right now!
jazzpur
55
jazzpur 2015.08.14 00:19 

greetings everyone,

im looking to craft and test my first EA, unfortunately i only have 1 year of c++ training from highschool and that was 15 years ago.

ive sucessfully managed to code a few strategies with thinkscript on TOS but the interface is much more simple...now im moving to mt4

 

 this is very simple, but mql4 is very new to me, so if you could just link me to something similar  i can dissect, or give me pointers.... 

so here goes:

 i want something that upon:

condition A=> opens a long position, exits via stoploss or takeprofit OR exits via Condition B

condition B=> opens a short position, exits via stoploss or takeprofit OR exits via Conditon A

 

so that upon condition A i open long and ride to condition B, then it closes my long and opens a short,

just plays a rollercoaster but only opens one position in each direction, 1 lot up, OUT, 1 lot down, OUT. 

if i hit a stoploss or takeprofit, i want to be out of the money completely, no reverse entry, just safety net 

this function is automatically programmed into thinkorswims program language, so i never had to code this

 

i have a feeling this is very simple, but i need an example to run by to establish a better fondation to build upon

 

 

thank you guys for the help

Nick 

Trinh Dat
37217
Trinh Dat 2015.08.14 00:45  
Simple ea here
https://www.mql5.com/en/code/13625
jazzpur
55
jazzpur 2015.08.14 04:37  
Trinh Dat:
Simple ea here
https://www.mql5.com/en/code/13625

thank you for the link, i was able to find a document online that broke down the logic of this same EA

 https://sites.google.com/site/marketformula/mql-code/mql4-how-to-create-a-simple-mt4-expert-advisor-that-trades-once-per-bar

 

more complex than i thought but  i believe can work with this with some time...

 

i was curious however why this EA did not work with strategy backtesting for EURUSD and JPYUSD, even when the RSI conditions were clearly being met... no orders were completed

 

it did however work  for AUDJPY, why is that??

thanks 

MQL4 - How To Create a Simple Forex MT4 Expert Advisor Template Using the RSI That Trades Once Per Bar - Market Formula = Forex Trader + Metatrader
  • sites.google.com
This is a two-part MQL4 code tutorial discussing how to create a simple Metatrader expert advisor using the RSI that trades only once per bar. At the end of part 2, a fully functioning RSI EA template may be downloaded. Additionally, the code will reference a different time frame chart for the RSI. So if you're interested in learning how to...
jazzpur
55
jazzpur 2015.08.14 20:38  

ok ive tested this EA today live on demo account,


not only does it not function on the EURUSD backtest, it does not trade or function realtime live for EURUSD...

live trading is checked, smiley face is happy, autotrade is green, conditions are being met......still not trading


however, this RSIea does work realtime for AUDJPY


what is wrong here if it works perfect for one currency pair and not another?

Marco vd Heijden
Moderator
4708
Marco vd Heijden 2015.08.14 21:03  

JPY has different Digits.

what values did you use for TP ans SL and what is the error reported ?

jazzpur
55
jazzpur 2015.08.14 21:40  

i have TP AND SL 0.0 for simplicity

 

no errors are reported unless i dont know where to find them. 

when i drop the EA onto the EURUSD chart, it says intialized and loaded successfully in the experts tab on the bottom

 

still, nothing is traded...ive tried M1, M5, M15 for hours..

Marco vd Heijden
Moderator
4708
Marco vd Heijden 2015.08.14 21:55  

if its order does not succeed look in the journal tab.

ive seen that stoploss is still being calculated even if 0 so you try with a higher value because if it is zero the server can reject the order because it is too close to price.

also you can drop in Alert() function to see if it triggers.

jazzpur
55
jazzpur 2015.08.14 22:17  
Marco vd Heijden:

if its order does not succeed look in the journal tab.

ive seen that stoploss is still being calculated even if 0 so you try with a higher value because if it is zero the server can reject the order because it is too close to price.

also you can drop in Alert() function to see if it triggers.

oh ok, i didnt even check journal tab my apologies

 not enough money!

2015.08.14 15:35:24.677 '2418260': order buy 4.91 EURUSD opening at 1.11091 sl: 0.00000 tp: 0.00000 failed [Not enough money]


is the default of the demo account 1:1 leverage??


perhaps i should modify EA to remove  LOT() function and just set lot size throughout

Marco vd Heijden
Moderator
4708
Marco vd Heijden 2015.08.14 22:52  
that almost 5 lot why would you take on these sized positions.
jazzpur
55
jazzpur 2015.08.19 15:55  
Marco vd Heijden:
that almost 5 lot why would you take on these sized positions.

that was the whole problem... i wasnt choosing those lots, it was written in one of the program functions to optimize the lot size

 

so i discovered that was a glitch in that EA and removed that function, and manually set my lot size to 0.1 

To add comments, please log in or register