
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
This is printing in the Journal during my for loop, where by, in the case of a pending Buy Stop Order, if the 60 EMA is > than the OrderStopLoss, it will close the pending order, open a new one with new SL (which is behind the 60EMA), adjust the take profit to entertain the 1:2 reward, and change the lots relative to the stop in points and my risk profile (say 2%).
So when this is all being done, the "Current Lots" which is "LotSize" custom variable within OrderSend works, it is sending off a lot size that is not correct for the server to receive? "0.18215"? Could this be an issue, despite the orders actually being sent through anyway - this question is more in connection to "could this be the reason why I cannot call "OrderType==OP_BUY"?
You should fix that, validate the lot size in the same way that you already have . . . you could even code a separate function to do it based on the code you already have . . . for example:
Instead of using LotSize in your OrderSend() you would use ValidateLots(LotSize)
I doubt that this is causing your issue though . . .
Argh! So frustrating lol - stuck on this for too long now :(
I cannot see why this is an issue and I cannot select an "OP_BUY"... I know I've probably exhausted this topic, but any last stabs in the dark would be really appreciated - thanks for helping me as well!!
Hmm - yeah I just played about with it. It appears that the order just gets sent through as the server only allows 0.00 (2 decimal places) anyway. So the remaining digits are almost irrelevant.
Argh! So frustrating lol - stuck on this for too long now :(
I cannot see why this is an issue and I cannot select an "OP_BUY"... I know I've probably exhausted this topic, but any last stabs in the dark would be really appreciated - thanks for helping me as well!!
I think you need to show all your code . . .
I see some issues here:
-http://pastebin.com/eaY1wKbN
Sorry about the syntax - little harder to see everything, but they dont have MQL4? So put it under C++
All the code won't fit on here? I've put it up on pastebin though?
-http://pastebin.com/eaY1wKbN
Sorry about the syntax - little harder to see everything, but they dont have MQL4? So put it under C++
No problem . . .
When you do this . . .
. . . what Order is already selected ? was it the pending order ? your OrderSelect() will fail if your OrderTicket() fails unless you already have an Order selected. Do you really need this code at all ? later on you have a loop where you select the orders and check their symbol and Magic Number and type . . .
This need fixing too . . .
. . . ad some braces . . .
Ok - I wacked more prints in to get a bit of clarity on whats being done and what point. I have pasted it below.
The line where it says "Order Select for closing:-..." that is what is being selected at the point "Close OP_BUY Half Lots @ 1:1 Function" you've asked above. It appears that the ticket number is different at this point of selection? I had deleted the "...&& OrderType()==OP_BUY" part out of it, as it seems to print the rest when this part is not in the "if" statement... Does this give a little more clarity?
"First Buy Order Placed:-" is the first OrderSend function going through at the start
"Checking Buy Order:-" Is the one within the for loop to delete and re-open the pending order if the MA is > the OrderStopLoss().
"NEW BUY ORDER:-" is the new order being placed inside that for loop.
"Order Select for closing:-..." - as mentioned above already, this is the part that's being selected to close half of the lots.
Sorry if that was confusing, as I have just added these parts in - you won't see this within that pastebin link above... just simple print functions :)
Ok - I wacked more prints in to get a bit of clarity on whats being done and what point. I have pasted it below.
The line where it says "Order Select for closing:-..." that is what is being selected at the point "Close OP_BUY Half Lots @ 1:1 Function" you've asked above. It appears that the ticket number is different at this point of selection? I had deleted the "...&& OrderType()==OP_BUY" part out of it, as it seems to print the rest when this part is not in the "if" statement... Does this give a little more clarity?
"First Buy Order Placed:-" is the first OrderSend function going through at the start
"Checking Buy Order:-" Is the one within the for loop to delete and re-open the pending order if the MA is > the OrderStopLoss().
"NEW BUY ORDER:-" is the new order being placed inside that for loop.
"Order Select for closing:-..." - as mentioned above already, this is the part that's being selected to close half of the lots.
Sorry if that was confusing, as I have just added these parts in - you won't see this within that pastebin link above... just simple print functions :)
Try the attached . . . it's my best guess at what you are trying to do . . .
Ah awesome - thank you. Its a large step in the right direction. I think because it's within a for loop, it wants to close out half and half and half @ the price... Instead of just doing it once? Not only that, but it seems to not close half off as soon as price >= to the exit price I want, instead it goes beyond it, and then when price swings back lower into the exit price I want, it closes then - strange... Appreciate your patience in helping me! Very grateful for your time!!
UPDATE: Also, I have just figured out, that if I change the expert properties (extern int) before running strategy tester, then the close half does not work at all - things that effect the close half is "MA_PadAmount" this is how many points I want to add as a pad to the stop loss that trails in pips, and "OrderPrice_PadAmount" which allows me to specify how many pips I can put as a pad on the entry price of the orders...
Ah awesome - thank you. Its a large step in the right direction. I think because it's within a for loop, it wants to close out half and half and half @ the price... Instead of just doing it once? Not only that, but it seems to not close half off as soon as price >= to the exit price I want, instead it goes beyond it, and then when price swings back lower into the exit price I want, it closes then - strange... Appreciate your patience in helping me! Very grateful for your time!!
Not entirely sure how to write that, but is that roughly on the right lines?