Ok fair enough. Well I think you've made your point.
I don't understand why it is people enjoy spending time just reinforcing what I already know = I am doing something wrong. I have come on here for tips or clues at least...
Anyway, thanks for telling me one tip = it's not the FREEZE_LEVEL...
Now I'm struggling to work out what you are trying to do here, especially as I do not see where the variable pips is declared and assigned a value. But I guess that it is Point for a 4 digit broker or Point*10 for a 5 digit broker.
if (StopLevel > BuyStopPrice + Point ) BuyStopPrice = StopLevel;
and I think "Have I misunderstood?
If StopLevel is 5 pips below current price and the calculated BuyStopPrice is 50 pips below current price, you will change BuyStopPrice to 5 pips below?
If StopLevel is 5 pips below current price and the calculated BuyStopPrice is 2 pips below current price, you will not change BuyStopPrice even though it may be too close?
Thank you kindly for your post. You're absolutely right. I think I get so annoyed sometimes, I don't take a step back and think logically. I apologize too, but I had actually changed the code to what I am trying to do now. I realized (as you've pointed out) that it was a mess!
What I am going to do now is print out everything again, and I'll post it up including the specific code that goes along with it. I will also clean up all the crap i've written in the code too. As you've pointed out, it's ridiculous!
Will post shortly
(p.s. just so I know, is my code easier to see now?)
You think? I'm looking for people to correct me because they know... Just give me some food for thought at least... Not always asking for just the answer. Your doing neither but having a laugh at my lack of knowledge.
Remember when you were learning programming? Bet you never asked any stupid questions did you...
Anyway, I've figured out WHY I am getting Error 130. It has NOTHING to do with what you're talking about. It was more to do with the logic else-where and the "Stored_BuyPrice". It's a static double and it essentially remembers the previous trades buy price and under a rare situation it will try to place a trade at that price when the price of the market is AT THAT price and the stop is ABOVE (for buy) the entry price.
Right, I've 100% figured out what the issue was. I am stuck with this "simple" part. Would be hugely appreciative if anyone can give an input?
//+------------------------------------------------------------------+//| Expert tick function |//+------------------------------------------------------------------+voidOnTick()
{
if( IsNewCandle() ) // Checks to see if there is a new H1 candle (bool)
{
if( CheckHistory()== true ) // If this returns True I want it to wait until the next H1 candle!
...
Basically, if CheckHistory() returns as True, rather than it progress any further, I want it to wait for a brand new H1 candle? What's a simple way of doing this as I feel like I am getting carried away writing overly complex code for it?
To elaborate further: If CheckHistory returns true and the iTime is within the 1 hour period from the "IsNewCandle()" then I DO NOT want it to progress any further until there IsNewCandle()...
DomGilberto: Right, I've 100% figured out what the issue was. I am stuck with this "simple" part. Would be hugely appreciative if anyone can give an input?
Basically, if CheckHistory() returns as True, rather than it progress any further, I want it to wait for a brand new H1 candle? What's a simple way of doing this as I feel like I am getting carried away writing overly complex code for it?
To elaborate further: If CheckHistory returns true and the iTime is within the 1 hour period from the "IsNewCandle()" then I DO NOT want it to progress any further until there IsNewCandle()...
Any help would be hugely appreciative!
if( CheckHistory()== true ) // If this returns True I want it to wait until the next H1 candle!
If you don't want the EA to do anything at all just
if( CheckHistory()== true ) // If this returns True I want it to wait until the next H1 candle!return;
DomGilberto:
(p.s. just so I know, is my code easier to see now?)
Your code is easier to read now that it fits the width of my screen.
Thanks Gumrai for your response. Glad it is easier to read now.
The issue is:
//+------------------------------------------------------------------+//| Expert tick function |//+------------------------------------------------------------------+voidOnTick()
{
if( IsNewCandle() ) // Checks to see if there is a new H1 candle (bool)
{
if( CheckHistory()== true ) // If this returns True I want it to wait until the next H1 candle!return;
...
//+------------------------------------------------------------------+ //| Ensuring its a new candle function |//+------------------------------------------------------------------+ bool IsNewCandle()
{
if(Bar1Time == iTime(NULL, low, IsNewBar_Shift)) //"Time" used to be "Bars" with no brackets return(false);
Bar1Time = iTime(NULL, low, IsNewBar_Shift); //"Time" used to be "Bars" with no brackets return(true);
}
As you can see here, it will just go back to IsNewCandle() and just confirm that we are still on the same Bar1Time as before and not actually wait. Basically, if "CheckHistory() == True" then on that specific bar "0" I want NO CODE to run what-so-ever and instead WAIT for "IsNewCandle()" to produce a NEW BAR. On top of this, i then want CheckHistory()==True to be avoided else this code will never progress:
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
You are not the only one here.
You are not the only one here too.
I think it has something to do with price being too close to the pending order (or within the FREEZE_LEVEL) entry price.OMG. It has nothing to do with FREEZE_LEVEL, instead, it is because of other reasons. I guess more homework needs to be taken care of now.
By the way, you still don't cover the basics of how Point works and how you can manipulate it. Do that and you will see what is going on right now.
I don't understand why it is people enjoy spending time just reinforcing what I already know = I am doing something wrong. I have come on here for tips or clues at least...
Anyway, thanks for telling me one tip = it's not the FREEZE_LEVEL...
I've updated the code in my first post.
A = 1.24000
B = 1.24000
Point = 0.00001
( A > B + Point ) is the same as ( 1.24000 > 1.24001) ...
DomGilberto, I sometimes have to wonder if you have difficulty following your own code, especially when you have left it alone for a few days.
If this is the case, imagine how difficult it is for others to follow your code.
I will tell you the process that I went through while looking at your code.
Problem is with Error 130, so I zoom in on OrderSend
Now I see that you use a variable called StopLevel, so where is that assigned a value?
I find it 50 lines back,
Now I'm struggling to work out what you are trying to do here, especially as I do not see where the variable pips is declared and assigned a value. But I guess that it is Point for a 4 digit broker or Point*10 for a 5 digit broker.
Incidently isn't that the same as
So I have worked out that StopLevel is the maximum that the stop loss can be set at for a Buy order.
it's not used in any code in the 50 lines as far as I can see, so why is it 50 lines back?
So we will move it closer to where it is being referenced
Then I look at the next line of code
and I think "Have I misunderstood?
If StopLevel is 5 pips below current price and the calculated BuyStopPrice is 50 pips below current price, you will change BuyStopPrice to 5 pips below?
If StopLevel is 5 pips below current price and the calculated BuyStopPrice is 2 pips below current price, you will not change BuyStopPrice even though it may be too close?
By now, I have a headache and leave it be.
What I am going to do now is print out everything again, and I'll post it up including the specific code that goes along with it. I will also clean up all the crap i've written in the code too. As you've pointed out, it's ridiculous!
Will post shortly
(p.s. just so I know, is my code easier to see now?)
A = 1.24000
B = 1.24000
Point = 0.00001
( A > B + Point ) is the same as ( 1.24000 > 1.24001) ...
You think? I'm looking for people to correct me because they know... Just give me some food for thought at least... Not always asking for just the answer. Your doing neither but having a laugh at my lack of knowledge.
Remember when you were learning programming? Bet you never asked any stupid questions did you...
Anyway, I've figured out WHY I am getting Error 130. It has NOTHING to do with what you're talking about. It was more to do with the logic else-where and the "Stored_BuyPrice". It's a static double and it essentially remembers the previous trades buy price and under a rare situation it will try to place a trade at that price when the price of the market is AT THAT price and the stop is ABOVE (for buy) the entry price.
I will post up once I have figured it out.
Basically, if CheckHistory() returns as True, rather than it progress any further, I want it to wait for a brand new H1 candle? What's a simple way of doing this as I feel like I am getting carried away writing overly complex code for it?
To elaborate further: If CheckHistory returns true and the iTime is within the 1 hour period from the "IsNewCandle()" then I DO NOT want it to progress any further until there IsNewCandle()...
Any help would be hugely appreciative!
Right, I've 100% figured out what the issue was. I am stuck with this "simple" part. Would be hugely appreciative if anyone can give an input?
Basically, if CheckHistory() returns as True, rather than it progress any further, I want it to wait for a brand new H1 candle? What's a simple way of doing this as I feel like I am getting carried away writing overly complex code for it?
To elaborate further: If CheckHistory returns true and the iTime is within the 1 hour period from the "IsNewCandle()" then I DO NOT want it to progress any further until there IsNewCandle()...
Any help would be hugely appreciative!
If you don't want the EA to do anything at all just
(p.s. just so I know, is my code easier to see now?)
Your code is easier to read now that it fits the width of my screen.
The issue is:
As you can see here, it will just go back to IsNewCandle() and just confirm that we are still on the same Bar1Time as before and not actually wait. Basically, if "CheckHistory() == True" then on that specific bar "0" I want NO CODE to run what-so-ever and instead WAIT for "IsNewCandle()" to produce a NEW BAR. On top of this, i then want CheckHistory()==True to be avoided else this code will never progress:
I cannot get this logic down at all... driving me up the wall....