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
A code should not rely on the lotsize being 2. It should be coded to deal with all possibilities.
Don't use Bid when modifying an order. Unless you want to change the price of a pending order, use OrderOpenPrice()
If I were you, I would take William's advise
Personally I would never use
I think that trying to get the jump on the broker closing the trade at TP is a bad idea.
I would open the trade with the TP set at TP2 and then when the price is halfway there, I would do the partial close.
@Keith Watford
Thanks to your advice, throughout the passed week, I was able to successfully fix abit. However, I have a new obstacle that is different topic, would it be possible for me to ask some guidance from you? It is regarding opening only one orders per bar.
I would truly appreciate it if you would reply to this forum, however, I am not so sure whether you will see this forum or not.
So would it be alright for me to open another forum if you do not reply within a certain period of time? I assure you, it is regarding different topics.
If you open a new topic and it concerns MT4, please keep it in this section
https://www.mql5.com/en/forum/mql4
Hi,
If the stochastic main and signal crossed, I want to close my position.
Whats the problem with this?
MAny thanks
extern int number = 12;
void OnTick()
{
double main2=iStochastic(NULL,0,5,3,3,MODE_SMA,0,MODE_MAIN,0);
double signal2=iStochastic(NULL,0,5,3,3,MODE_SMA,0,MODE_SIGNAL,0);
if(main2=signal2)
{
int ticket=OrderClose( number, 1, Bid, 2 );
}
}
Please edit your post and
use the code button (Alt+S) when pasting code.
if(main2=signal2) //This is not boolean!
OrderClose returns a bool not an int. Check GetLastError() if it fails.
bool OrderClose(
int ticket, // ticket
double lots, // volume
double price, // close price
int slippage, // slippage
color arrow_color // color
);
Is number a valid ticket number?
Is 1 a valid lot size for the order?
Is bid a valid close price? We don't know if it is a buy or sell.
Personally I would never use
I think that trying to get the jump on the broker closing the trade at TP is a bad idea.
Requirements and Limitations in Making Trades - Appendixes - MQL4 Tutorial
On some ECN type brokers the value might be zero (broker doesn't know.) Use a minimum of two (2) PIPs.