MQL4 - automated forex trading   /  

Forum

OrderSend Problem

Back to topics list To post a new topic, please log in or register

avatar
6
tomas1234 2008.02.16 00:05 
Hi,

I took this example:

ticket=OrderSend(Symbol(),OP_BUY,1,Ask,3,Ask-25*Point,Ask+25*Point,"My order #2",16384,0,Green);
if (ticket<0)
{
Alert ("OrderSend failed with error #", GetLastError());
return (0);
}

However I am getting an error #4055, what does it mean? I have demo account with Meta Trader. Can't I use and test this command with demo account?

Thank you very much, I searched all over google, but couldn't find any good information about it

Tom
article

Registration Is Closed!

Everybody could apply for participation in the Automated Trading Championship 2007 within 3 months. 2011 people have been registered. 731 Expert Advisors have already been checked and are ready to start the contest.


avatar
2462
phy 2008.02.16 00:27 
ERR_CUSTOM_INDICATOR_ERROR 4055 Custom indicator error.

Try this:


int error = GetLastError();
if(err != 0) Alert("There was an error BEFORE the OrderSend, error # = ", error);
ticket=OrderSend(Symbol(),OP_BUY,1,Ask,3,Ask-25*Point,Ask+25*Point,"My order #2",16384,0,Green);
if (ticket<0)
{
Alert ("OrderSend failed with error #", GetLastError());
return (0);
}


avatar
6
tomas1234 2008.02.16 00:42 
hi, thanks for your respond. I tried to run this code:

int error = GetLastError();
if(error != 0) Alert("There was an error BEFORE the OrderSend, error # = ", error);
ticket=OrderSend(Symbol(),OP_BUY,1,Ask,3,Ask-25*Point,Ask+25*Point,"My order #2",16384,0,Green);
if (ticket<0)
{
Alert ("OrderSend failed with error #", GetLastError());
return (0);
}

but before OrderSend I didn't get any error alert, I got "OrderSend failed with error #4055"

Is it allowed to do OrderSend function on Demo Account ?

thank you
Tom


avatar
2462
phy 2008.02.16 00:55 

Some dealers do not permit automated trading.

Who are you using?

What do you get for IsTradeAllowed() ?

Is this an Indicator or Expert? You can't trade in an indicator


avatar
6
tomas1234 2008.02.16 01:09 
phy wrote:

Some dealers do not permit automated trading.

Who are you using?

What do you get for IsTradeAllowed() ?

Is this an Indicator or Expert? You can't trade in an indicator

isTradeAllowed() - I am getting 0 value.

This is an indicator ichimoku.mq4, so I can't make an orders inside the indicator?

I am a programmer, so programming is not an issue for me, it's just where can I do orders? where can I use OrderSend function?

Thank you very much


avatar
2462
phy 2008.02.16 07:47 

avatar
6
tomas1234 2008.02.17 19:49 
This code is in expert advisor, (EA). My idea is to draw a line where red and blue lines crosses each other. This code works, the problem is that after drawing one line it draws others, where it should stop. After drawing one line it should wait for another cross of blue and red lines and then draw next one. If I explained bad, please let me know, my english is terrible:) Didn't think i will have problems of coding soo much. Thank you!

void start()
{
datetime TMY;
string mydate;

double blue=iIchimoku(NULL, 0, 9, 26, 52, MODE_KIJUNSEN, 0);
double blue_last=iIchimoku(NULL, 0, 9, 26, 52, MODE_KIJUNSEN, 1);

double red=iIchimoku(NULL, 0, 9, 26, 52, MODE_TENKANSEN, 0);
double red_last=iIchimoku(NULL, 0, 9, 26, 52, MODE_TENKANSEN, 1);

TMY = iTime(Symbol(),PERIOD_H1,0);
mydate =TimeToStr(TMY,TIME_DATE|TIME_SECONDS);

if (((red<blue) && (red_last<blue_last) && (blue-red)>=0.0004) ){
ObjectCreate("OH"+Open[0], OBJ_VLINE, 0, TMY, Open[0]);
}

if (((red>blue) && (red_last>blue_last) && (red-blue)>=0.0004) ){
ObjectCreate("OH"+Open[0], OBJ_ARROW, 0, TMY, Open[0]);
}

red_last = red;
blue_last = blue;

}

avatar
2462
phy 2008.02.17 20:31 

if (((red<blue) && (blue-red)>=0.0003) || (red==blue)){
ObjectCreate("OH"+Open[0], OBJ_VLINE, 0, TMY, Open[0]);
}

Restated:

if( red <= (blue+0.0003) ) draw a line

There is no logic here to detect cross, only "red is less than blue so draw another line"

try

if( (red <= (blue+0.0003)) && (red_last > (blue_last+0.0003)) ) draw a line

That should get you closer to what you want.


avatar
6
tomas1234 2008.02.17 23:04 
I want to ask why it doesn't catch all crosses and touches?

if ( (red-blue>-0.000000000000000001) && (red-blue<0.000000000000000001) && (red_last > blue_last) ){
state = 2; //touch from bottom
ObjectCreate("OH"+Open[0], OBJ_VLINE, 0, TMY, Open[0]);
}

if ( (blue-red>-0.000000000000000001) && (red-blue<0.000000000000000001) && (red_last > blue_last) ){
state = 4; //touch from top
ObjectCreate("OH"+Open[0], OBJ_VLINE, 0, TMY, Open[0]);
}

if ( (red-blue>0.000000000000000001) && (red_last < blue_last) ){
state = 1; //cross from bottom
ObjectCreate("OH"+Open[0], OBJ_VLINE, 0, TMY, Open[0]);
}

if ( (blue-red>0.000000000000000001) && (red_last > blue_last) ){
state = 3; //cross from top
ObjectCreate("OH"+Open[0], OBJ_VLINE, 0, TMY, Open[0]);
}





Back to topics list  

To add comments, please log in or register