use OrderType to determine the last closed order...then you can use it as a criteria like :
for(cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_HISTORY);
if(OrderType()<=OP_SELL && // check for opened position
OrderSymbol()==Symbol()) // check for symbol
{
if(OrderType()==OP_BUY) // long position is opened
{
only_shorts=true;
only_Longs=false;
}
if(OrderType==OP_SELL)
{
only_shorts=false;
only_longs=true;
}
if(only_shorts)open_short();
if(only_longs)open_long();
then make 2 custom functions called :
void open_short()
{
ticket=OrderSend(....);
only_shorts=false;
}
void open_long()
{
ticket=OrderSend(....);
only_longs=false;
}
if im wrong i am sure a better coder will correct me and help you...cheers :)

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Greetings all,
I need a code that will only allow my expert to go long if the last trade was short and only go short if the last trade was long.
Thanks...........