OrderSend Problem

 
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
 
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);
}

 
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
 

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

 
phy:

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
 
 
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;

}
 

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.

 
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]);
}