Hi all,
After a lot of reading, I think I'm ready to post my first message. Which contains a probably easy question but I can't seem to be able to solve it, and after several hours of searching I decided to shoot it out here :)
Anyhow, I'm trying to make an EA that stores yesterdays range , goes long when the price breaks through YesterdayHigh, goes short when price goes through YesterdayLow. This on small timeframe with SL & TP. But I can't seem to determine the PreviousDay's info correct. I'd thought this would work.
But the problem I get this way, is that the orders only get executed at 00.00(hh:mm), but I would like them to open and given ticks on the 1M Chart. Here's my Newbar Function:
So, what's going wrong? And does anyone has an alternative solution? I'd be really thankful! Hope you folks be easy on me!
Use Print() function to check your variables values.
This code is not necessary:
double iLow(),iHigh();
In place of this :
double TakeProfitBuy= YesterdayHigh + (TakeProfitPips/10000);
Use :
double Point = SymbolInfoDouble(_Symbol, SYMBOL_POINT); double TakeProfitBuy= YesterdayHigh + (TakeProfitPips * Point);
You have also to take into account Ask & Bid, Buy is open at Ask price and Sell is open at Bid price.
Please give us complete code, that compile, otherwise it's difficult to do any test. You can attach a file to your post.
Thanks for your quick reply, appreciate it!
Ha you're right guess I was a bit sleepy ^^
I added the rest of the code! Do you note some points you think are very inefficient? Or other things you don't like? Ps. I don't understand how to work with classes at the moment, you think that's crucial?
Edit 12;36GMT+1: Updated version
Thanks for your quick reply, appreciate it!
Ha you're right guess I was a bit sleepy ^^
I added the rest of the code! Do you note some points you think are very inefficient? Or other things you don't like? Ps. I don't understand how to work with classes at the moment, you think that's crucial?
Edit 12;36GMT+1: Updated version
It's not necessary to use class, it's an option.
If you want me to read your code, you have to attach a mql5 file and not a compiled one (ex5). I am not a robot ;-)
Woops sorry thanks for your patience
Ok, your EA open a trade on new bar and close it on next bar, then open on new bar then close, etc...
So it seems that it's you exit strategy who is bad. What are you trying to do ?
EDIT: Oh, I see an error finally :
double iHigh(string strSymbol,ENUM_TIMEFRAMES tf,int nShift) { double timeseries[1]; if(CopyLow(strSymbol,tf,nShift,1,timeseries)==1) return(timeseries[0]); else return(-1.0); }
must use CopyHigh. I am not very awake either :-D
I'd like to open a Long Position as soon as the previous days high is broken. If the price breaks through the top I'd like to have a 10Pips TP and 5Pips SL as exit.
I'd like to open a Short Position as soon as the previous days low is broken. If the price breaks through the bottom I'd like to have a 10Pips TP and 5Pips SL as exit.
Spread still excluded by both of them btw, want to add it later as soon as it functions as I like it to.
Edit: Ah Cool thank you, lol must be careful when being lazy copying things next time! You see other things you don't like? Since I just started programming recently and don't really know if I'm writing some stuff that could be written way better?
Edit2: There are still some things not working out well, like trades that stay open for 3 months. You can spot anything else?
Edit3:It's probably better to send the SL an TP with the initial order since that's compared per tick and if I let the EA look at the SL and TP per bar it's much more inaccurate since a new bar has to appear before the EA takes SL and TP, right?
I'd like to open a Long Position as soon as the previous days high is broken. If the price breaks through the top I'd like to have a 10Pips TP and 5Pips SL as exit.
I'd like to open a Short Position as soon as the previous days low is broken. If the price breaks through the bottom I'd like to have a 10Pips TP and 5Pips SL as exit.
Spread still excluded by both of them btw, want to add it later as soon as it functions as I like it to.
Edit: Ah Cool thank you, lol must be careful when being lazy copying things next time! You see other things you don't like? Since I just started programming recently and don't really know if I'm writing some stuff that could be written way better?
Edit2: There are still some things not working out well, like trades that stay open for 3 months. You can spot anything else?
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi all,
After a lot of reading, I think I'm ready to post my first message. Which contains a probably easy question but I can't seem to be able to solve it, and after several hours of searching I decided to shoot it out here :)
Anyhow, I'm trying to make an EA that stores yesterdays range , goes long when the price breaks through YesterdayHigh, goes short when price goes through YesterdayLow. This on small timeframe with SL & TP. But I can't seem to determine the PreviousDay's info correct. I'd thought this would work.
//Related Input Parameters & Stuff input int TakeProfitPips=10,StopLossPips=5; input ENUM_TIMEFRAMES MYPeriod=PERIOD_M1; double iLow(),iHigh(); static int Signal=0; MqlDateTime timee
But the problem I get this way, is that the orders only get executed at 00.00(hh:mm), but I would like them to open and given ticks on the 1M Chart. Here's my Newbar Function:
So, what's going wrong? And does anyone has an alternative solution? I'd be really thankful! Hope you folks be easy on me!