an impossible problem? - page 3

 
yes the price is specific and the ea will only start from that specific price, yes the spacing is constant, the spacing is correlated with the tp.
 

about pending orders,

a pending order will also not work because the minimum price difference between the "live" price and the pending order price must be 5 pips.. and sometimes when a trade reaches a tp and needs to be replaced by a similar trade a pending order cannot fill it if the price fluctuation is smaller than 5pips .

 

nayef wrote >>

1. buy and sell at the same pre-determind set price (i know there will be a time lag in most cases and other cases the buy or sell might not be fulfilled because of fluctations or other reason but its a risk ill take

OK... do you want to wait until the price reaches your pre determined level before actioning or should the orders action a soon as you load the EA... even if that means the current price is say below a load of sellstops?



nayef:

2. as an example im working on a tp of 50 and a sl of 250 points on both the buyorders and sellorders.

3. if im using a sl of 250 and a tp of 50 and using the predetermined prices of pending orders then ill always have 10 open orders, if my sl is 500 ill have 20 open orders etc.


Agian, this is straight forward, so there is a gap of 50 between each order and 5 buy and 5 sell. As you have done before, set int for SL TP and grid spacing.


Homework time.... write an EA to declare your SL,TP, Grid spacing and start price. Add an additional Bool variable "EXECUTE" set to True. Then in start write an if statement that if EXECUTE is true, it opens 5 orders up and 5 orders down. At the end of the code block set EXECUTE=false; If you can do it in a loop as zzueg showed earlier great if not, sequencially is fine.

Once done, post it and we will review

 

ill wait till price reaches the pre determined level,

if i do write the EA to declare the sl,tpgrid spacing and start price... wount the slippage mean a different start price?

 
nayef:

ill wait till price reaches the pre determined level,

if i do write the EA to declare the sl,tpgrid spacing and start price... wount the slippage mean a different start price?

Slippage occurs when you send a market order not a pending order. Although the pending order may incur slippage when it's triggered. The thing we will tackle after this first stage is the price that triggers EXECUTE. I'm going to go through this slowly 'cos it's about showing principles and building upon those principles. So one step at a time
 
great, im on it now... let the concstruction begin.
 

Viffer wrote >>

And top viffer tip, if it's pending orders, and you post market orders one more time, I think I will scream


#EDIT# - You deleted your post....


AAARRRRRRGGGGHHHHHHHH!!!!


Ok, lets do it in pictures...

http://cdn.forexfactory.com/attachment.php?s=c8d1fa0c22129af6ed1d8f0958dfb5e6&attachmentid=154986&d=1223333711

You are correct in saying "or isit just not possible to do it this way". You will NEVER be able instantly buy something for a price that doesn't exist at the moment. All you can do is commit to buy it if it reaches your price sometime in the future. that commitment is a PENDING ORDER.


And forgive my tone, but WTF are you doing with OrderMagicNumber()? In fact, just forget you even heard about magic numbers for now. We are many levels below that at the moment.



You got an F on your homework but I would like you to have another go at it. I would like for your if statement to open one "buy" market order at the current price and one "buy stop" at 100 pips above the current price. I want us to understand how an EA sends an order, then we will look at criteria to send an order and then how to manage those orders. The ONLY reading you will need for this is

https://book.mql4.com/programm/structure

https://book.mql4.com/operators/if

https://book.mql4.com/trading/orders

 

i cannot belieeeeeeeeeeeeeeeve how much time a day im spending on this but what can i say.. im lovin it.... so far all the attempted EA's ive written are a load of BS! and i cannot beliveeeeeeee how stubborn i bloody am! why wount i get it!!! forget market orders! im gonna write that down 100 times so i really will forget them.. but in all these hours ive learnt sooooo much! so its time to redeem myself and delete allllll the EAs ive made and start from scratch ( you told me this like 10 posts ago :S ) .

ive done some reading on grid systems and found some good stuff. all my system is:

a grid system but with both buy and sell limits && buy and sellstops ... the end... thats it!

so technically speaking i could take a grid EA in existence, try decompile it then make it place orders both ways instead of just sellsstops and buystops... im always jumping the wagon... but its ok.

its a quarter past 12 now so i need to get my 6 hours sleep and im working tomorow. unfortunatly i only get fridays off. that said this time of year work is really quite so ill get to do my homework tomorow. yippeee

Reason: