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
Hi Raptor, thanks again.
1. Is that the only problem with the above code??? I think worst case the PendingOrderTicket_1 would not get modified, and would close at its SL.
2. Is it ok how I used the OrderSelect function?
The big problem I think I will have, is that when OrderTicket_1 is over the first Gap_Level1, it will still modify the order ON EVERYTICK that this criterea is met.
3. Is that the case? If so, would the below code fix it?
Thanks again ;)
1. It's just something that jumped out at me that will break your code.
2. Your OrderSelect is wrong ( https://docs.mql4.com/trading/OrderSelect ) if you are going to select using the ticket number you have to use SELECT_BY_TICKET not SELECT_BY_POS
3. I don't think so, what you have done, i think, will just mean that that function just gets called once . . . what happens when you have the next Order that needs modifying ? what happens if you have two orders open at the same time ?
I'm not 100% conversant with what you are doing, I don't have time to look at your code in enough detail to do that . . . but, I have a question.
Can't you look at an Order's OrderOpenPrice(), it's OrderStopLoss() and it's OrderTakeProfit() and determine if it has already been modified to level 1 2 or 3 ?
1. It's just something that jumped out at me that will break your code.
2. Your OrderSelect is wrong ( https://docs.mql4.com/trading/OrderSelect ) if you are going to select using the ticket number you have to use SELECT_BY_TICKET not SELECT_BY_POS
3. I don't think so, what you have done, i think, will just mean that that function just gets called once . . . what happens when you have the next Order that needs modifying ? what happens if you have two orders open at the same time ?
I'm not 100% conversant with what you are doing, I don't have time to look at your code in enough detail to do that . . . but, I have a question.
Can't you look at an Order's OrderOpenPrice(), it's OrderStopLoss() and it's OrderTakeProfit() and determine if it has already been modified to level 1 2 or 3 ?
Thank you Raptor, your insight has been very helpful to me...
I totally understand with time constraints too, your time and tips has been much appreciated.... I wasn't trying ask anyone to write it for me, so I didn't go to great detail... which presents the problem that without much detail it is hard to offer help, so apologies..... In this instance, it was more the code I was concerned about while learning and your tips have been great for me
1. I have been busting to get it together to test, so might fix the power out problem later when I am more experienced.
2. I will change to SELECT_BY_TICKET, rather than POS, thank you muchly.
3. I do want that GAP_Level1 to only be called upon once, so perhaps I am correct there with the way I strung it all together.... To answer your question, I am trying to look at the latest Pending Order's Ticket, to see if it gets over my TradeUp mark. When that happens, I would like it to drag all of my previous orders up (this time selecting by magic number to get them all)... By this stage, I have another Pending Order Open, and when it gets to Gap_Level2, I will have a BuyModify_Level2 block, with the same code.... Plausable??
I am hoping I am write with my logic, I really did sit down with paper like you suggested this time to nut it out... ;)
3. I do want that GAP_Level1 to only be called upon once, so perhaps I am correct there with the way I strung it all together.... To answer your question, I am trying to look at the latest Pending Order's Ticket, to see if it gets over my TradeUp mark. When that happens, I would like it to drag all of my previous orders up (this time selecting by magic number to get them all)... By this stage, I have another Pending Order Open, and when it gets to Gap_Level2, I will have a BuyModify_Level2 block, with the same code.... Plausable??
How (or where in your code) will you set HasBeenExecuted = false ; so that IfGap_Level_1() gets executed for the 2nd set of trades ?
Good question mate.
I was going to bool that variable at the beginning of internal variables underneath the ones I export. I was going to do an GAP_Level_1, GAP_Level_2,GAP_Level_3, GAP_Level_4, GAP_Level_5 etc. So once it hits GAP_Level_1, it can forget about this first gap level.
You point did get me thinking, much appreciated. I do see a problem now.
I realised that when a trade hits a SL, and starts over again, I do want the first trade to look for Gap_Level_1 again and rotate through. And damn yeah that will cause a problem, since I was going to tie PendingOrder_1 with GAP_Level_1, PendingOrderLevel_Level_2 with GAP_Level2.
I guess I can still pull it off, but I wouldn't of thought about this unless you mentioned.....
I can think of three work-arounds... The first suits my brain power a little better haha ;)
1. if I go IF LAST TRADE IS LOSS, then DELETE ALL PENDING ORDERS, and restart them if a trade hits a SL. So that Pending Order 1 goes to Gap Level_1, it will stop Pending_Order5 being the next trade opened which goes to GAP_Level5. After a SL is hit, all of my Open trades will be Closed as they all share the same SL, so closing down my Pending Orders and restarting the logic might be ok.
2. The other option I can think of (thanks to your tip with my other code problem a few weeks ago), is to insert a boolean variable after the first trade is made called NEWTRADE, and then have a block IFNEWTRADE==1, then go to GAP_Level1. This gets me thinking, I guess I could go IFNEWTRADE1 in the Pending Order 1 Block, and IFNEWTRADE2 in the Pending Order 2 Block and so on... then IFNEWTRADE2==1 go to GAP_Level2.
EDIT (after a coffee): 3. I just thought, what if I sorted order by time (now I know one can sort multiple orders lots of ways), and assign a interger variable called ORD_SELECT_NUMBER based on TIME. Then after ORD_SELECT_NUMBER == 1, go to GAP_Level1, then look at the next ORD_SELECT_NUMBER using that ORDER_SELECT_NUMBER ++ command.
I am ok at writing single order EAs based on signals etc, it is just this multiple order stuff that honestly kills me... My EA is actually working as is, and gets good results, it is just crazy to use, as it modifies on EVERYTICK, and just uses my smallest Gap_Level atm obviously since I am since working out how to tie it all together above...
Wow, but thanks again Raptor, as well as CODING KNOWLEDGE I see how important good LOGIC is too, thanks for making me think.
Wow, but thanks again Raptor, as well as CODING KNOWLEDGE I see how important good LOGIC is too, thanks for making me think.
You have that the wrong way round . . . all software, no matter what language it is coded in, C++, Perl, Pascal, Fortran, Assembler, etc is just about solving problems. If the logic behind your solution is flawed then it doesn't matter how good a coder you are . . . the solution comes first, the code comes later.
I understand what you are saying... A builder without building plans, won't get far, even if he is the best builder in the world. The initial plan is almost more important, I hear you.
You have been a great help to me Raptor, and wanted to say thanks again.
I went with lazy option 1 above.
It has been hours and hours of programming, my EA is around 85k (thus only posted a fragment), so I am yet to report back how I went after this dinosaur is complete. I am having quite a bit of luck atm, the orders do select properly. I am studying up as I go, as it is far from the single order EAs that I am used to writing. I jumped into the deepend with this project and learning how to swim. I will post back how I go.
Thanks again Raptor :)
I understand what you are saying... A builder without building plans, won't get far, even if he is the best builder in the world. The initial plan is almost more important, I hear you.
You have been a great help to me Raptor, and wanted to say thanks again.
I went with lazy option 1 above.
It has been hours and hours of programming, my EA is around 85k (thus only posted a fragment), so I am yet to report back how I went after this dinosaur is complete. I am having quite a bit of luck atm, the orders do select properly. I am studying up as I go, as it is far from the single order EAs that I am used to writing. I jumped into the deepend with this project and learning how to swim. I will post back how I go.
Thanks again Raptor :)
Once you see yourself expanding in your code resources, and there are functions that can be made common for any future EA's use, do consider to use library/include, etc.
Bec. once it grows into tyrannosaurus, you codes do get lost in their own Juraissic Park, esp. when you need them again for any future use.
Once you see yourself expanding in your code resources, and there are functions that can be made common for any future EA's use, do consider to use library/include, etc.
Bec. once it grows into tyrannosaurus, you codes do get lost in their own Juraissic Park, esp. when you need them again for any future use.
Haha mate, that gave me a laugh. I do see how that can happen.
To be honest I found a Library Insert called 'OrderSendReliable.mqh'. I am going to finish this EA first, then was going to post back how I went with that Library Insert with that other EAcode post I had going as believe it might fix the hot market thing.
I had a giggle, cause I can now see, how with experience, there would be all sorts of #includes at the top of the EA, haha, and you carry around a 1mb cache of files for each EA.
You know your comment gets me thinking, it just went click. I have just been cutting and pasting code around between my EAs when I get a {section} that I like, and tie them in (eg. that {section} I was having trouble with in that other post I mentioned before). I hadn't even thought to make that as a Library Insert, and just refer to it... I am a long way off that sort of thing... I was just about to start my first library include after this EA with that one to see how they work.... the possibilities are so cool. It is quite addictive this MQL.
Oh yeah all is on track with my code too, it works perfectly for its purpose, I was popping back to give a big thanks :) ..
I really appreciate you guys support, I wish I could describe how much in words ;)
You can have your own sets of "core" library functions, which I strongly recommend you to consider earlier, than later.
I also started with my first EA, same thing, copy, paste, copy paste....
The turning point was when i was doing this EA for my old time military service ex-co, already retired. That changed everything, I started using library for the first time.
I still keep that library till today. If it can offer you ideas, helping you to get on... here is its header, mate:
hope this helps....
You can have your own sets of "core" library functions, which I strongly recommend you to consider earlier, than later.
I also started with my first EA, same thing, copy, paste, copy paste....
The turning point was when i was doing this EA for my old time military service ex-co, already retired. That changed everything, I started using library for the first time.
I still keep that library till today. If it can offer you ideas, helping you to get on... here is its header, mate:
hope this helps....
Hi Diostar, that is really cool mate, thanks for sharing that information, I was yet to read up on libraries. That seems like an awesome way to carry around variables and have them predefined for later. I will have a think about it. I like how you said "earlier rather than later", I like tips like that, thanks mate. It reminds me of like learning to play the guitar, when 20 years later I think I wish I did 'so and so' from the start, it would of made the last 20 years easier, lol. I will seriously look into this more, thank you.
Ah just when I thought I was on fire, I have a drama, that I can't think to solve. I am having trouble with selecting the correct orders in these two joining sections:
I might show two of my examples, and show the effects, my brain just won't go click on this one...
Example 1:
SCROLLS through previous orders exactly like I want, however it modifies them on EVERYTICK
(the original drama with order select Raptor helped me with stopped the Levels from conflicting, so the SL slopping around for that reason before too. I felt this last part easy to sort out, but been on it for days it feels trying to stop it happening every tick..)
Example 2:
This example is not what I want... I tried this option to stop it modify send on every tick... however it does not scroll through the orders, and just modifies one of the correct ticket on every tick (it modifies the first order, I guess last in Index cache of orders).
I have another 50 attempts, trying a little IF EXECUTED 00 section first to pass it to IFGAP if not executed before... however I didn't have much luck inserting a switch before hand..... I might just post this example to show that option....
Example 3:
With a swtich... it still has the same effect as Example 1. It scrolls through orders correctly but still modifies on every ticck...
I can see that the switch keeps getting issues a false again, so just runs through again... however other attempts would not let it pass through at all... should I stick with this option and try declaring IfGap_SELLLevel_00AlreadyExe = true elsewhere, if so where?
So yeah I really tried guys before bothering you all again.... for hours and hours... I am lost again...
Any help or pointers would be appreciated ;)