diff --git a/Experts/Nkanven/CandleCount.ex5 b/Experts/Nkanven/CandleCount.ex5 new file mode 100644 index 0000000..cfd1692 Binary files /dev/null and b/Experts/Nkanven/CandleCount.ex5 differ diff --git a/Experts/Nkanven/GeminiHedge.ex5 b/Experts/Nkanven/GeminiHedge.ex5 index 0dc87d4..70055d7 100644 Binary files a/Experts/Nkanven/GeminiHedge.ex5 and b/Experts/Nkanven/GeminiHedge.ex5 differ diff --git a/Experts/Nkanven/GeminiHedge.mq5 b/Experts/Nkanven/GeminiHedge.mq5 index f0933cf..52284de 100644 --- a/Experts/Nkanven/GeminiHedge.mq5 +++ b/Experts/Nkanven/GeminiHedge.mq5 @@ -11,8 +11,9 @@ #include //Trading hours checks #include //Trading conditions checks #include //Trading conditions checks +#include //DCA manager #include //Lot size calculator -#include //Lot size calculator +#include //Trade entries manager //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ @@ -45,18 +46,28 @@ void OnTick() if(InpActivateDCAHedging) { - string instruments[] = {InpInstrument1, InpInstrument2}; + Print("DCA Hedging is activated"); + ArrayResize(instruments,2); + instruments[0] = InpInstrument1; + instruments[1] = InpInstrument2; } else { - string instruments[] = {InpInstrument1}; + Print("DCA Hedging is not activated"); + ArrayResize(instruments,1); + instruments[0] = InpInstrument1; } +Print("Instrument size", ArraySize(instruments)); for(int i=0; i 0) - { - //return position exists - } + if(gTotalBuyPositions > 0) + { + //Get last opened position id + int lastTicketId = gTotalBuyPositions; + + bool hasOrderAbove = false, hasOrderBelow = false; + + if(PositionGetTicket(lastTicketId) == 0) + { + int Error=GetLastError(); + Print("ERROR - Unable to select the order - ",Error," - ",Error); + return NO_DEALS; + } + + if(PositionGetSymbol(lastTicketId)==gSymbol && PositionGetInteger(POSITION_MAGIC)==InpMagicNumber) + { + //Compute above and below orders price + + Print("Last ticket id ", lastTicketId, " last ticket price ", PositionGetDouble(POSITION_PRICE_OPEN)); + gUpOpenPrice = PositionGetDouble(POSITION_PRICE_OPEN) + (InpBuyCallBack * point); + gDownOpenPrice = PositionGetDouble(POSITION_PRICE_OPEN) - (InpBuyCallBack * point); + + //Check orders around the last opened position + for(int i=0; i