Download MetaTrader 5
To add comments, please log in or register
Having troubles understanding the code? Perhaps, you can find an article on that topic!
Tim
128
Tim 2014.11.11 18:10 

I'm struggling to work out why the strategy tester will not allow my EA to place a trade greater than £50/pip. It runs on an IG DEMO account strategy tester fine upt to £49/pip but the moment the EA calls for a pip rate of greater than £50/pip it comes back with an invalid trade volume.

I will include the place trade section of my EA in the next post, nothing special about it and this is what causes an error 131 to be returned. The moment the lot size is restricted to £50/pip or less the trade is placed absolutely fine.

 Does anybody have any ideas why this might happen??? 

Tim
128
Tim 2014.11.11 18:11  
tim
void PlacePendingTrade()
{
   if(TradeTarget>TradeStopLevel)OpType=OP_BUYSTOP;
   else OpType=OP_SELLSTOP;

   if(CalcCandle>=TradeStartTime && CalcCandle<GoodTillCancelled && OrderTradeType!=0 && DayTradeActive=="No" && RunningTicketCounter<MaxTrades) 
      {  
         ticket =  OrderSend(Symbol(),OpType,lots,NormalizeDouble(TradeBidPrice,Digits),30*pips,0,0,"Trade Placed By the EA Script.",1234,0,Magenta); 
         if(ticket>0)
            {
               OrderSelect(ticket,SELECT_BY_TICKET);
               TicketBidPrice=OrderOpenPrice();
               if(!OrderModify(ticket,NormalizeDouble(TicketBidPrice,Digits),NormalizeDouble(TradeStopLevel,Digits),NormalizeDouble(TradeTarget,Digits),(DayOpenTime+GoodTillCancelled),Magenta)) 
                  {
                     err = GetLastError();
                     Print("Encountered an error during modification of the placed order, the pending trade has no tp or sl!"+err+" "+ErrorDescription(err)  );
                  }
                  else PendingOrder=1;
                  Print("Order placed and modified successfully pending order set to 1");              
            }
      else
         {
            err = GetLastError();
            Print("Encountered an error during order placement!"+err+" "+ErrorDescription(err)  );
            if(err==ERR_TRADE_NOT_ALLOWED)MessageBox("You can not place a trade because \"Allow Live Trading\" is not checked in your options. Please check the \"Allow Live Trading\" Box!","Check Your Settings!");
         };  
      };
};
dchambers
:

I'm struggling to work out why the strategy tester will not allow my EA to place a trade greater than £50/pip. It runs on an IG DEMO account strategy tester fine upt to £49/pip but the moment the EA calls for a pip rate of greater than £50/pip it comes back with an invalid trade volume.

I will include the place trade section of my EA in the next post, nothing special about it and this is what causes an error 131 to be returned. The moment the lot size is restricted to £50/pip or less the trade is placed absolutely fine.

 Does anybody have any ideas why this might happen??? 


Keith Watford
Moderator
8016
Keith Watford 2014.11.11 21:55  

Have you checked MarketInfo  MODE_MAXLOT ?

PS if you want people to help you, please do not post such wide sections of code in future. It makes the post difficult to read. 

Tim
128
Tim 2014.11.12 07:40  

Thankyou GumRai, appreciate the advice. As it turns out I arrived at the same result late last night MODE_MAXLOT, annoying for me since I knew of MODE_MINLOT!!!

 So as it turns out the IG DEMO account allows lot sizes of 0.1 to 50 hence my issue. The IG LIVE account allows lotsizes of 1 to 500, BUT for some reason I can't get the strategy Tester to work on the LIVE account, when I go to the History Center it won't download any 1minute data from Metacorp :o(

 I've tried tasking the HST from the DEMO account history folder and pasting into the LIVE history folder but that doesn't see to fix the issue either.

 Any ideas? 

/
To add comments, please log in or register