help me debug my orders!

 

I get a bunch of OrderSend130's and don't know why! Can anyone shed light?

I didn't include the CloseAll() method because it would just distract. I'm getting errors from the opening of the orders and it's only opening half the time it should be.

Thanks all!

int Symbol.magic=90022;
extern double Lots=0.05;
int Slippage=3;
int start()
{
if(Volume[0]>1) return;
CloseAll();
SetNew();
return(0);
}
//+------------------------------------------------------------------+
void SetNew(){
double high=iHigh(NULL,PERIOD_D1, 1);
double low=iLow(NULL,PERIOD_D1,1);


OrderSend
(Symbol(),OP_BUYLIMIT,Lots,high,Slippage,low,0,"Big Ben Making dollars.",Symbol.magic,0,Blue);

OrderSend
(Symbol(),OP_SELLLIMIT,Lots,low,Slippage,high,0,"Big Ben Making dollars.",Symbol.magic,0,Blue);

}

 
LBranjord:

I get a bunch of OrderSend130's and don't know why! Can anyone shed light?

I didn't include the CloseAll() method because it would just distract. I'm getting errors from the opening of the orders and it's only opening half the time it should be.

Thanks all!

int Symbol.magic=90022;
extern double Lots=0.05;
int Slippage=3;
int start()
{
if(Volume[0]>1) return;
CloseAll();
SetNew();
return(0);
}
//+------------------------------------------------------------------+
void SetNew(){
double high=iHigh(NULL,PERIOD_D1, 1);
double low=iLow(NULL,PERIOD_D1,1);


OrderSend
(Symbol(),OP_BUYLIMIT,Lots,high,Slippage,low,0,"Big Ben Making dollars.",Symbol.magic,0,Blue);

OrderSend
(Symbol(),OP_SELLLIMIT,Lots,low,Slippage,high,0,"Big Ben Making dollars.",Symbol.magic,0,Blue);

}


I've added my broker's minimum stoploss in as criteria, I cant test now but I think that is why some of these don't go through, if the daily bar is too small, the stoploss will be too small?
 

If you gonna buy above the ask price you should use OP_BUYSTOP instead and OP_SELLSTOP with sell.

 

Don't use volume for... well anything!

If it's New Bar you are after, check time instead.

//+------------------------------------------------------------------+
//  NEW BAR FUNCTION
//+------------------------------------------------------------------+
   // Identify new bars
   bool Fun_New_Bar()
      {
      static datetime New_Time = 0;
      bool New_Bar = false;
      if (New_Time!= Time[0])
         {
         New_Time = Time[0];
         New_Bar = true;
         }
      return(New_Bar);
      }
V
 
Viffer:

Don't use volume for... well anything!

If it's New Bar you are after, check time instead.

V


Yes! I was looking for something to do this. I have an dead-EA called SNIPPETS and your code is being added to it :)

That's where I put things I will use over and over again. Thanks Vif

 
LBranjord:


Yes! I was looking for something to do this. I have an dead-EA called SNIPPETS and your code is being added to it :)

That's where I put things I will use over and over again. Thanks Vif


so to use that bool function I would do something like the following?

if (Fun_New_Bar==true){

//go check for signals or whatever I planned on doing

}

 
LBranjord:


so to use that bool function I would do something like the following?

if (Fun_New_Bar==true){

//go check for signals or whatever I planned on doing

}

Pretty much, yep.

My EA swaps around from wanting New Bar and then tick data so I set a variable first thing in start()

New_Bar=Fun_New_Bar();

Then when I get to a piece of code that needs a new bar criteria, I add New_Bar t to the if statement

   if (New_Bar)
      {
      // Do new bar stuff
      }

Probably a little faster (for me) than running the function repeatedly as I swap in and out of current and newbar spots.

Glad it's helpful

V

Reason: