made a 2 EMA cross EA, need advice - page 2

 
prupru:

Sorry, but I didn't understand that part.

Can you explain this code ?

 int tic = OrderSend(Symbol(),Cmd,Lot,PR,Slippage,SL,TP,"",0,0,clr);
 if(tic < 0) Print("Open order error: ",GetLastError());

. . . in particular variable tic

 

this what happened when I used

        static datetime Time0;
        if (Time0 == Time[0]) return;
        Time0 = Time[0];

the trade took place not at the opening price of the candle but inside the candle

when I use bars everything is fine

why does this happen?

 
deVries:

I don't think this is right

how do you get 100 pips takeprofit and 150 pips Stoploss ???


the price movements on this market are really insane

http://bitcoincharts.com/charts/mtgoxUSD#rg60zig6-hourztgSzm1g10zm2g25

so there is no point in using pips on this market when in one day price moves from 500 to 800 USD or from 1100 to 800 USD

 
RaptorUK:

Can you explain this code ?

. . . in particular variable tic


I think tic is the order number returned by the OrderSend function, and -1 in case of an error.

Yey! I am right)) here is wat MT4 help say (I have checked just now):

Returns number of the ticket assigned to the order by the trade server or -1 if it fails. To get additional error information, one has to call the GetLastError() function.

So, what's wrong with it?

 
prupru:


I think tic is the order number returned by the OrderSend function, and -1 in case of an error.

Yey! I am right)) here is wat MT4 help say (I have checked just now):

Returns number of the ticket assigned to the order by the trade server or -1 if it fails. To get additional error information, one has to call the GetLastError() function.

So, what's wrong with it?

Nothing, you said you didn't understand . . .

prupru:

Sorry, but I didn't understand that part.

. . . maybe you do now ?

I guess you didn't write this code . . .

 
deVries:

update see " so stop loss and take profit are not in pips but in percents of a bid or ask. "

still do you get a valid price that way ... if your symbol has 5 digits the outcome will be often 2 digits more

ok, I can understand that)

so I need to normalise the digits of Ask*Takeprofit/100, so it has the same digits as Ask, I'm working on that, thank you!

 
RaptorUK:

Nothing, you said you didn't understand . . .

. . . maybe you do now ?

I guess you didn't write this code . . .


You are right, I didn't write the code all from my head, I just put together pieces that I could find over the internet in different examples.

And yes, I do understand now what you was talking about, but initially I thought that

"It's good to see somone checking trading function return values without being prompted to do so . . ."

was sarcastic and pointing to some mistake of mine.

Well, never mind and thanks for your help once again.

 
prupru:

this what happened when I used

the trade took place not at the opening price of the candle but inside the candle

when I use bars everything is fine

why does this happen?


the opening price of a candle is a bid price

the opening price of your buy trade is an ask price

 
deVries:


the opening price of a candle is a bid price

the opening price of your buy trade is an ask price


but that should be the same both when I use Time and Bars to determine when to open the order, why is this different?
 
prupru:

but that should be the same both when I use Time and Bars to determine when to open the order, why is this different?


not if you test with current spread this is very crazy moving so spread can become very huge

so how did you do the test ??

fixed spread or current spread ??

Reason: