The open orders manually opened can be read?

To add comments, please log in or register
Brian Lillard
9173
Brian Lillard  

Hello

what im trying to do is simply make a traders assistant ea

when its reading open orders its supposed to print the order it found but its not showing anything but a 0 or "" (blank)

Could somebody fix my code?


#property copyright "Copyright 2013, TradersAssistant -by Brian Lillard."
#property link "http://iseedeadpresidents.fml.netne.net/"
#include <stderror.mqh>
#define NA 0 
#define BUY 1
#define SELL 2
extern string Settings = "== Trader Assistant Settings ==";
extern     bool Hedge?                  =False;
extern     bool Buy?                    =False;
extern      int HowManyBuys?            =1;
extern     bool CloseAllBuys?           =False;
extern     bool Sell?                   =False;
extern      int HowManySells?           =1;
extern     bool CloseAllSells?          =False;
extern     bool CloseAll?               =False;
extern      int MagicNumber             =3210;
extern   string Order_Comment           =""; //MyTrader'sAssistantEA
extern     bool UseTakeProfit           =True;
extern      int TakeProfit              =100;
extern     bool UseStopLoss             =True;
extern      int StopLoss                =35;
extern     bool UseTrailingStop         =True;
extern      int TrailStartPips          =0;      
extern      int TrailStopPips           =-35;
extern   double LotSize                 =0.05;
extern   double MaxSpreadPips           =4.0;
extern   double SlippagePips            =1.9;
extern      int ServerRetries           =4;
extern   string BarTimer = "== Bar Timer Settings ==";
extern   string FontName="Arial";
extern    color FontColor=Black;
extern      int FontSize=10;
extern      int Corner=3;
extern      int XDistance=25;
extern      int YDistance=35;
         string s_base=":...:...:...:...:"; 
            int lenbase; 
         double SymSprd,SymPt,SymPip,TStrPt,TStpPt,newTS,s1[],newTP,newSL;
         double StopLossPips,TakeProfitPips;
            int Err,TryCount;
           bool CloseAll=false;
static datetime Bar1Time;
//+------------------------------------------------------------------+
int init()
//+------------------------------------------------------------------+
   {
   lenbase=StringLen(s_base);
   if(CloseAll?){CloseOrders(BUY,HowManyBuys?); CloseOrders(SELL,HowManySells?);}
   return(0);
   }
//+------------------------------------------------------------------+
int deinit()
//+------------------------------------------------------------------+
   {
   if(ObjectFind("BarTimer")!=-1){ObjectDelete("BarTimer");}
   return(0);
   }
//+------------------------------------------------------------------+
int start()
//+------------------------------------------------------------------+
   {
   int ordersopen=0;
   if(Digits==3){SymPt=0.010;SymPip=100;SymSprd=(Ask-Bid)*SymPip;TStpPt=TrailStopPips*SymPt;TStrPt=TrailStartPips*SymPt;}
   if(Digits==5){SymPt=0.00010;SymPip=10000;SymSprd=(Ask-Bid)*SymPip;TStpPt=TrailStopPips*SymPt;TStrPt=TrailStartPips*SymPt;}
   if(Bar1Time!=Time[1])
      {
      for(int a=OrdersTotal(); a>=0; a--)
         {
         if(OrderSelect(a,SELECT_BY_POS,MODE_TRADES))
            {
            Print("Order "+OrderType()+", OrderMagicOrder "+OrderMagicNumber()+", Comment "+OrderComment()+"~");
            if(OrderSymbol()==Symbol()&&OrderMagicNumber()==MagicNumber&&OrderComment()==Order_Comment)
               {
               ordersopen++;
               //--
               if(OrderType()==OP_BUY&&!Hedge?){CloseOrders(SELL,HowManySells?);}//close hedge?
                  if(OrderType()==OP_BUY&&CloseAllBuys?){CloseOrders(BUY,HowManyBuys?);}
               if(OrderType()==OP_SELL&&!Hedge?){CloseOrders(BUY,HowManyBuys?);}//close hedge?
                  if(OrderType()==OP_SELL&&CloseAllSells?){CloseOrders(SELL,HowManySells?);}
               //--
               if(UseTakeProfit&&UseStopLoss && OrderTakeProfit()!=TakeProfit && OrderStopLoss()!=StopLoss)
                  {OrderModify(OrderTicket(),OrderOpenPrice(),StopLoss,TakeProfit,0,CLR_NONE);}
               else
                  {
                  if(UseTakeProfit&&OrderTakeProfit()!=TakeProfit)
                     {OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),TakeProfit,0,CLR_NONE);}
                  if(UseStopLoss&&OrderStopLoss()!=StopLoss)
                     {OrderModify(OrderTicket(),OrderOpenPrice(),StopLoss,OrderTakeProfit(),0,CLR_NONE);}
                  }
               }
            }
         }
      if(ordersopen>0){TrailingStop();}
      else
         {
         if(Buy?){OpenOrders(BUY,HowManyBuys?);}
         if(Sell?){OpenOrders(SELL,HowManySells?);}
         }      
      Bar1Time=Time[1];
      }
   return(0);
   }
Simon Gniadkowski
17274
Simon Gniadkowski  
Subgenius:

Hello

what im trying to do is simply make a traders assistant ea

when its reading open orders its supposed to print the order it found but its not showing anything but a 0 or "" (blank)

Could somebody fix my code?


Perhaps it found an OP_BUY with no Magic Number and no comment ?

Please copy and paste the output from the log file here . . .

Brian Lillard
9173
Brian Lillard  
RaptorUK:

Perhaps it found an OP_BUY with no Magic Number and no comment ?

Please copy and paste the output from the log file here . . .


2013.10.02 04:59:48 TradersAssistant USDCHF,M15: Order 0, OrderMagicOrder 0, Comment ~

open order is buy 0.10 usdchf noSL noTP


now i had added

Print("Open Orders: "+ordersopen);

and its not showing any orders of the symbol

Simon Gniadkowski
17274
Simon Gniadkowski  
Subgenius:

2013.10.02 04:59:48 TradersAssistant USDCHF,M15: Order 0, OrderMagicOrder 0, Comment ~

open order is buy 0.10 usdchf noSL noTP

OK, that output is correct . . . OP_BUY is 0, no Magic Number is 0 and no comment is ""

Subgenius:

now i had added

Print("Open Orders: "+ordersopen);

and its not showing any orders of the symbol

Added where in the code ? you have to add it at the right place . . . ordersopen isn't a static . . .



Brian Lillard
9173
Brian Lillard  
RaptorUK:

OK, that output is correct . . . OP_BUY is 0, no Magic Number is 0 and no comment is ""

Added where in the code ? you have to add it at the right place . . . ordersopen isn't a static . . .




after order pooling


see

attached
Files:
Simon Gniadkowski
17274
Simon Gniadkowski  
Subgenius:


after order pooling


see

attached

Perhaps the MagicNumber doesn't match, print the Magic Number that the order has when you have selected it . . .

By the way, you really need to read this: What are Function return values ? How do I use them ?

and this: Loops and Closing or Deleting Orders

To add comments, please log in or register