After the GBP flash crash earlier this month i've been looking at strategies to limit currency pairs when markets are extended and have revisited UseZeljko in Steves shellcode EA..
As my coding is quite limited i'm hoping someone could let me know if i would need to add
type ==OP_BUYSTOP && type == OP_BUYLIMIT if i want to check to see if pending orders are currently open in other pairs as I noticed the Current call is:
Code: Select all
if (UseZeljko && !BalancedPair(OP_BUY))
return; Code: Select all
if (UseZeljko && (!BalancedPair(OP_BUY)||!BalancedPair(OP_BUYSTOP))) return;Do I need to add to check for open Limit Orders?
Code: Select all
if (type == OP_BUY || type == OP_BUYSTOP || type == OP_BUYLIMIT)Code: Select all
bool BalancedPair(int type)
{
string BuyCcy1, SellCcy1, BuyCcy2, SellCcy2;
if (type == OP_BUY || type == OP_BUYSTOP)
{
BuyCcy1 = StringSubstrOld(Symbol(), 0, 3);
SellCcy1 = StringSubstrOld(Symbol(), 3, 3);
}//if (type == OP_BUY || type == OP_BUYSTOP)
else
{
BuyCcy1 = StringSubstrOld(Symbol(), 3, 3);
SellCcy1 = StringSubstrOld(Symbol(), 0, 3);
}//else
for (int cc = OrdersTotal() - 1; cc >= 0; cc--)
{
if (!OrderSelect(cc, SELECT_BY_POS)) continue;
if (OrderSymbol() == Symbol()) continue;
if (OrderMagicNumber() != MagicNumber) continue;
if (OrderType() == OP_BUY || OrderType() == OP_BUYSTOP)
{
BuyCcy2 = StringSubstrOld(OrderSymbol(), 0, 3);
SellCcy2 = StringSubstrOld(OrderSymbol(), 3, 3);
}//if (OrderType() == OP_BUY || OrderType() == OP_BUYSTOP)
else
{
BuyCcy2 = StringSubstrOld(OrderSymbol(), 3, 3);
SellCcy2 = StringSubstrOld(OrderSymbol(), 0, 3);
}//else
if (BuyCcy1 == BuyCcy2 || SellCcy1 == SellCcy2) return(false);
}//for (int cc = OrdersTotal() - 1; cc >= 0; cc--)
//Got this far, so it is ok to send the trade
return(true);
}//End bool BalancedPair(int type)