Kelly Lot Help Please - page 2

 

Gidday dabbler


Thanks for joining in, do you have any ideas as to how to get this working I know its close.

 
kiwi06:

Here is the EA with the changes.


Better, but
bool IsSkipComment(string OrdComment)
{
   bool IsSkipComment = false;
   for(int i=0; i<SkipComments; i++) if(StringFind(OrdComment, SkipComment[i]) != -1) IsSkipComment = true;

   return(IsSkipComment);
}  
you still have at least one variable with the same name as the function. I bet that isn't the only problem though.
 
dabbler:
Better, but you still have at least one variable with the same name as the function. I bet that isn't the only problem though.
No it isn't . . . variable names get changed by the compiler, function names do not . .
 
kiwi06:

The Lot Size seems to be switching between 00, 10 so I suspect that has something to do with the Array is that correct?


On your OrderSend() functions you must use the
double NormalizeDouble( double value, int digits) 
function. Doubles have far too many digits so that any calculation involving doubles must be normalized to the correct number of digits or it will fail. Sending a lotsize of 0.1000001 for example may not be accepted.
 
dabbler could you provide and example please don't understand exactly where I should place the
NormalizeDouble
 
This is what I have done and its made no difference unfortunately
void CheckForOpen(string symbol) {
   int    res;
//---- sell conditions
   if(sellsig && ttime!=Time[0])  {
      res=OrderSend(symbol,OP_SELL,NormalizeDouble(Kellylot(),Digits),Bid,slippage,NormalizeDouble(Bid+StopLoss*Point,Digits),NormalizeDouble(Bid-TakeProfit*Point,Digits),"Kelly Buy",SpecificMagic,0,Red);
      Print(symbol,OP_SELL,Kellylot(),Ask,slippage,Ask-StopLoss*Point,Ask+TakeProfit*Point,SpecificMagic );
        if (res<0) Alert("Error opening SELL order : ",ErrorDescription(GetLastError()));
      ttime=Time[0];
      return;
   }
//---- buy conditions
   if(buysig && ttime!=Time[0])  {
      res=OrderSend(symbol,OP_BUY,NormalizeDouble(Kellylot(),Digits),Ask,slippage,NormalizeDouble(Ask-StopLoss*Point,Digits),NormalizeDouble(Ask+TakeProfit*Point,Digits),"Keyy Sell",SpecificMagic,0,Blue);
      Print(symbol,OP_BUY,Kellylot(),Ask,slippage,Ask-StopLoss*Point,Ask+TakeProfit*Point,SpecificMagic );
        if (res<0) Alert("Error opening BUY order : ",ErrorDescription(GetLastError()));
      ttime=Time[0];
      return;
   }
}
 
kiwi06:
This is what I have done and its made no difference unfortunately

Don’t despair. It’s getting better even if it is not yet fixed!

The NomalizeDouble() is ok apart from the one on the LOTSIZE. This will be 1 or 2 digits depending on the minimum lotsize increment.

 

Ok so there is too much error data being created and it is overflowing the simulator journal even for one day’s worth of trades. Answer: comment out the buy orders to halve the data. (I just ANDed the buy test with 0 to make the test guaranteed to fail.

Next, the print function is not putting spaces between the parameters making it almost impossible to read so I added a literal space between each parameter.

      Print(symbol," ",OP_SELL," ",lotSize," ",Ask," ",slippage," ",Ask-StopLoss*Point," ",Ask+TakeProfit*Point," ",SpecificMagic );

Then I was getting invalid stops errors so I figured you meant to use stops in pips but have them in points so i increased the values by 10x to shut that up.

Then I was getting a different error on lotsize so I added this code before the order send functions ...

   double lotSize= NormalizeDouble(Kellylot(),2);
   if( lotSize <0.01 ){
      Print("Error in lotsize=" + lotSize);
   }

and sure enough there are loads of lotsize zero being sent.

Over to you. Move the debug print statements to see where the zero lotsize is coming from.



 

Attached is a mock up EA that has the original EA in it just to see was the out puts would be.

its not optimised or very good for that matter.

if you run a demo you will see the Risk by Optimal F starting at 0.00 in moving to -0.19 or something then up to a positive GBPUSD Daily was the pair and for every win it moves up depending on the size of the win and vice versa for the loss.

I have been trying to use the Risk by Optimal F as the lot size for the EA so if there is a - 0.19 that needs to = the minimum lot size for the broker.

I hope that helps out a little

Files:
pivot.mq4  21 kb
 

Ok so bug finding is alot more difficult then first anticipated but from what I can see the zero's are coming from the entire mm script.

but is I move the print around I get a buy order insted of a sell. at 0.01 lots then it reverts back to

2011.12.16 14:58:15 2008.01.15 00:00 Kelly Experiment GBPUSD,Daily: Alert: Error opening SELL order : invalid function parameter value
2011.12.16 14:58:15 2008.01.15 00:00 Kelly Experiment GBPUSD,Daily: GBPUSD 1 0 1.9527 20 1.9562 1.9407 12332151
2011.12.16 14:58:15 2008.01.15 00:00 Kelly Experiment GBPUSD,Daily: OrderSend error 4051
2011.12.16 14:58:15 2008.01.15 00:00 Kelly Experiment GBPUSD,Daily: invalid lots amount for OrderSend function
2011.12.16 14:58:13 2008.01.14 00:00 Kelly Experiment GBPUSD,Daily: Alert: Error opening BUY order : invalid function parameter value
2011.12.16 14:58:13 2008.01.14 00:00 Kelly Experiment GBPUSD,Daily: GBPUSD 1 0 1.9598 20 1.9563 1.9718 12332151
2011.12.16 14:58:13 2008.01.14 00:00 Kelly Experiment GBPUSD,Daily: OrderSend error 4051

   double lotSize= NormalizeDouble(Kellylot(),2);
   if( lotSize <0.01 ){
      Print("Error in lotsize=" + lotSize);
   }
Reason: