Play videoPlease edit your post.
For large amounts of code, attach it.
- avoid that the EA opens a new Buy order even if the price still above the MASo test for it
bool isWaiting; int init(){ isWaiting = false; } int start(){ bool wasWaiting = isWaiting; isWaiting = false; // Assume not OK to open : // Test // Ok to open isWaiting = Bid < ma; // Time to open? if(!isWaiting && wasWaiting){ // Open Buy!
- Your loop keeps going after you've found the highest position order and will set both values (needs a break).
- Don't use int's when you mean bool's
cashmaker:
Hello,
I´m trying to add a routine to an EA to avoid open consecutive orders of the same type.
The idea here is, if price is above such a MA it BUY, but when that initial order is closed I need to avoid that the EA opens a new Buy order even if the price still above the MA, because the next order must be a SELL order when the price is below the MA.
I need something to identify the kind (Buy/sell) of the last closed order.
I tried with the follow piece of code, but it isn´t generating a signal .
Can I have some suggestions? Thanks.
...Can you please edit your post and use the SRC button when you post code.
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
Hello,
I´m trying to add a routine to an EA to avoid open consecutive orders of the same type.
The idea here is, if price is above such a MA it BUY, but when that initial order is closed I need to avoid that the EA opens a new Buy order even if the price still above the MA, because the next order must be a SELL order when the price is below the MA.
I need something to identify the kind (Buy/sell) of the last closed order.
I tried with the follow piece of code, but it isn´t generating a signal .
Can I have some suggestions? Thanks.
-----------------------------------------------------
int Last_Buy, Last_Sell;
if (modo_scalper==1)
{
for(int z=OrdersHistoryTotal()-1;z>=0;z--)
{
if(OrderSelect(z,SELECT_BY_POS,MODE_HISTORY)==true && OrderSymbol()==Symbol() && OrderMagicNumber()==magico)
{
if(OrderType()==OP_BUY)
{
Last_Buy=1;
}
if (OrderType()==OP_SELL)
{
Last_Sell=1;
}
}
}
}