Here is one of the files that doesn't work with the EURUSD Am having trouble trying to enter both files here at one time using the SRC. I am new to this way or the right way.
I think I have got it right.
Here is one of the files that doesn't work with the EURUSD Am having trouble trying to enter both files here at one time using the SRC. I am new to this way or the right way.
This is for the scalpOSC EA.
if ((adx>adxx) && (ma>maa) && (sto<20 && rsi<30)) //Signal Buy { if(OrderSelect(0,SELECT_BY_POS,MODE_TRADES))
Here you are signalling a buy but may not have any orders on. Hence you fail the first test and hit the error message. Add an
if( OrdersTotal()>0 )
test before the OrderSelect() to rid yourself of the first error message.
For the second problem, I notice the default
extern int StopLoss =0; // SL for an opened order extern int TakeProfit =0; // ?? for an opened order
will fail in the OrderSend() because the StopLoss and TakeProfit levels are too close to the market value (equal to it).
For the second problem, I notice the default
extern int StopLoss =0; // SL for an opened order extern int TakeProfit =0; // ?? for an opened order
will fail in the OrderSend() because the StopLoss and TakeProfit levels are too close to the market value (equal to it).
the result from int openbuy/opensell is a no. not true or false so, u have to check
in my opinion the error is gonna be 130
search for 4/5 digit broker / ECN broker & of course error 130
Thanks for the help. I use MBTrading an ECN Broker. I am doing Ok with the code but still having the most trouble with the Orders part of the code.
Looks like I need to look at more examples on this.
there is no problem at all to send an order with SL & TP 0 with some brokers (called ECM) you must send with ST & TP 0
Thanks for the help. I use MBTrading an ECN Broker. Is there really an ECM Broker? Maybe I need to talk to MBTrading but then
again they do nothing or do not support the code themselves. You are on your own. I need to get this Order code mess straighted out.
I am able to write halfway decent EA'S because of my experience Trading. Just need to get this down clear. I know you will always get
some errors now and then.
Here is one of the files that doesn't work with the EURUSD Am having trouble trying to enter both files here at one time using the SRC. I am new to this way or the right way.
int openbuy=OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, Ask-StopLoss*Point, Ask-StopLoss*Point); //Opening Buy
to:
int openbuy=OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, 0, 0); //Opening Buy
if (openbuy > 0 ) { // Succeeded, got back a ticket number
if ( !(OrderModify(openBuy, OrderOpen(), Slippage, Ask+StopLoss*Point, Ask-StopLoss*Point, 0, CLR_NONE)) ) {
// Process orderModify Errors(use GetLastError())
}
} else {
// Process OrderSend errors, no ticket was received back (use GetLastError())
}
This works with all brokers that I know of - While it used to be limited to ECN brokers, there is a growing number of all types who require you to establish an order with no stop loss or take profit and then add the TP and SL to the already existing order (and make sure the values added and subtracted from Ask are large enough to not run afoul of 'stoplevel').
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use