'How to do I manipulate my code for a maximum of one buy order and one sell order and the same time
#property strict
int ticket;
void OnTick()
{
double AccountBal;
double MAfast = iMA(_Symbol,PERIOD_CURRENT,20,0,MODE_EMA,PRICE_CLOSE,0);
double MAslow = iMA(_Symbol,PERIOD_CURRENT,30,0,MODE_EMA,PRICE_CLOSE,0);
AccountBal = AccountBalance()/10000;
double Force = iForce(_Symbol,PERIOD_CURRENT,13,MODE_SMA,PRICE_CLOSE,0);
double rsi = iRSI(_Symbol,PERIOD_CURRENT,7,PRICE_CLOSE,0);
if((rsi> 70)&&(OrdersTotal()==0)&&(MAfast>MAslow)){
ticket = OrderSend(_Symbol,OP_BUY,AccountBal,Ask,10,Ask-0.007,Ask+0.007,"This iS Buy",33,0,clrBlue);
}
if((rsi <30)&&(OrdersTotal()==0)&&(MAslow>MAfast)){
ticket = OrderSend(_Symbol,OP_SELL,AccountBal,Bid,10,Bid+0.007,Bid-0.007,"This is a Sell",33,0,clrRed);
}
}
The code works and everything is great but when a order is open like a buy order, even if the the conditions are true for sell order it wont place the order until the open one hits take profit or stop loss, the Orders Total function is screwing me over is there anyway I can replace it?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
