can't get my EA to run - page 2

 

If you are on a 5 digit broker you need to adjust accordingly, there are plenty of code examples posted here to help you.

Have a look here: http://crum.be/45digit

 
ray2955:

Now i'm get Error 130 " invalid stops ".

I put print statements and checked the stoploss:

Stoploss= 20 pips

I check and 20 *Point = .00002 not .00020

So the stoploss is not large enough.

EA's must adjust for 5 digit brokers, TP, SL, AND slippage. On ECN brokers you must open first and THEN set stops.
//++++ These are adjusted for 5 digit brokers.
int     pips2points;    // slippage  3 pips    3=points    30=points
double  pips2dbl;       // Stoploss 15 pips    0.0015      0.00150
int     Digits.pips;    // DoubleToStr(dbl/pips2dbl, Digits.pips)
int     init(){
    if (Digits == 5 || Digits == 3){    // Adjust for five (5) digit brokers.
                pips2dbl    = Point*10; pips2points = 10;   Digits.pips = 1;
    } else {    pips2dbl    = Point;    pips2points =  1;   Digits.pips = 0; }
    // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl
 

Thanks again, I having problem with New Bar Det. I see there are different versions

which one works best.

 
ray2955:

Thanks again, I having problem with New Bar Det. I see there are different versions

which one works best.

Probably the one that you can understand the easiest and that works for you in your coding scenario . . . you can learn a lot by trying to understand other peoples code, I know I have. :-)
 

Hi, how do this logic work?


void Function_New_Bar()
{
double New_Time;
int f_New_Time,NewBar;
bool f_New_Bar = false;


if (New_Time!=Time[0]) New _Time not = Time[0] ok this is the logic truth
{
New_Time = Time[0]; how can this be true
f_New_Bar = true; and how does this det the chainge in New_Time

Alert(Time[0]);
}

if (f_New_Bar==false)

{
Alert("Waiting for new bar");

}else{
Alert("New bar just Exist.");
NewBar1++;
}
return(0);
}

 
ray2955:

Hi, how do this logic work?




Please use this to post code . . . it makes it easier to read.

 
Hi,im trying to have only one trade per bar,often the 20pip profit is hit 
on the same bar and will keep trading the same bar and get stopped out often.
So I'm trying to check for the new bar that i can use inhibit trades. 

Also I'm trying to understand the logic of the new bar script
and i'm having problems working it.

here is my program and thanks.
Files:
raysbars_2.mq4  10 kb
 

Select your code, copy (Ctrl + C), click the SRC button, paste . . .

void Function_New_Bar()
{
double New_Time;
int f_New_Time,NewBar;
bool f_New_Bar = false;


if (New_Time!=Time[0]) New _Time not = Time[0] ok this is the logic truth
{
New_Time = Time[0]; how can this be true 
f_New_Bar = true; and how does this det the chainge in New_Time

Alert(Time[0]);
}

if (f_New_Bar==false)

{
Alert("Waiting for new bar");

}else{
Alert("New bar just Exist."); 
NewBar1++;
}
return(0);
}
 
  1. ray2955:

    Thanks again, I having problem with New Bar Det. I see there are different versions

    which one works best.

    All that use time work the same.


  2. I don't like the function type because it can only be called ONCE per tick. The function fails if you call it more than once.

    int start(){    static datetime Time0;
      if (Time0 == Time[0]) return(0); Time0 = Time[0];
      // A new bar.
    or
    int start(){    static datetime Time0;
      bool newBar = Time0 != Time[0];
      ...
      if (newBar){  Time0 = Time[0]; ...
    

  3. Raptor
    double New_Time;
    int f_New_Time,NewBar;
    bool f_New_Bar = false;
    if (New_Time!=Time[0]) New _Time not = Time[0] ok this is the logic truth
    New_Time MUST be static or global
 
WHRoeder:

  1. Raptor New_Time MUST be static or global
It's not my code it's ray2955:'s . . I just pasted it via SRC to demonstrate what I was asking to be done ;-)
Reason: