SendOrder sl and tp advise - page 2

 
Now I have to work on IsTradeAllow to make some sort of time range for trading

So the user can set it for a particular time range they want to trade this EA,
Off to search the code base and reading documents again LOL

Happy coding and thanks for the help to everyone
 

Agent86: ...I have a lot of ideas for this and hope to make something useful for people....

I don't wanna dis-courage you or anything but your code didn't work for me. I got lots of error 130. I recommend you forget about making codes for the Masses while you're still green. Focus on creating a Universal Template for yourself first. Don't look toward Library files unless you're comfortable with your current programming style. Instead, make the Template the Library file and add a few good functions to it. Then make the trade logic an include file with it's own magic# etc in that include file. Ever wonder why new versions of software and programs keep coming up every other day? Sure there are cosmetic and monetary reasons but my guess is the biggest reason is because the programmer needs to optimize the code.

One example of a good template can be found here. It takes time so take it easy.

 
Agent86:
Now I have to work on IsTradeAllow to make some sort of time range for trading

So the user can set it for a particular time range they want to trade this EA,
I think you misunderstand the function of IsTradeAllowed "Returns TRUE if the expert is allowed to trade and a thread for trading is not occupied, otherwise returns FALSE." it's not something you can set . .
 
ubzen:

Agent86: ...I have a lot of ideas for this and hope to make something useful for people....

I don't wanna dis-courage you or anything but your code didn't work for me. I got lots of error 130. I recommend you forget about making codes for the Masses while you're still green. Focus on creating a Universal Template for yourself first. Don't look toward Library files unless you're comfortable with your current programming style. Instead, make the Template the Library file and add a few good functions to it. Then make the trade logic an include file with it's own magic# etc in that include file. Ever wonder why new versions of software and programs keep coming up every other day? Sure there are cosmetic and monetary reasons but my guess is the biggest reason is because the programmer needs to optimize the code.

One example of a good template can be found here. It takes time so take it easy.

I'm not getting any 130 error, I'm getting good print statements for this ? Not sure why your 130's perhaps if your on an ECN as others have suggested you need to open a position first before setting sl and tp, I can't really say but I'm not having any errors

I'll research a bit further, and also this is being used on a 5 digit broker so you may have to change the extern lot = .1 to something else also ?
 
RaptorUK:
I think you misunderstand the function of IsTradeAllowed "Returns TRUE if the expert is allowed to trade and a thread for trading is not occupied, otherwise returns FALSE." it's not something you can set . .

I'll reread this some more and likely have to create some code to create a time range for trading such as: trade only during time range = 3am - 6am

or perhaps 6am - 1pm etc.
Hopefully it won't give me too much trouble

 
WHRoeder:

Close but not quite. Mql4 charts are bid charts so the values you get from ABCD are Bid values. These need to be adjusted depending on the direction of the trade.

I think I get it, I'll have to review your code post some more


I am using all Bid prices except for the OrderSend parts And so I may need to adjust these sl and tp by simply +/- the spread right ?
Is there where most of the problem might come in ?

I have no problem referring to a Bid price in my code as that is how it's coded and when I watch the charts I would place a trade based on what I see so this would be ok for this code.

I have to review your code some I don't really understand it but only partially.

Thanks