MQL4 Learning - page 54

 

No. You need to put it inside your start function, you've got it outside. Put it inside the curly braces, first line is fine.

Lux

 

one mor question

thank you so much, one more question, will it still work if i wanted to trade between 22pm at night and 2am in the morning?

//+------------------------------------------------------------------+

//| expert start function |

//+------------------------------------------------------------------+

int start() {

if (TimeHour(TimeCurrent())=2)return(0);

int Order = SIGNAL_NONE;

int Total, Ticket;

double StopLossLevel, TakeProfitLevel;

 

NO!

This another case. Use:

if(TimeHour(TimeCurrent())=2)return(0);

 

thank you

thank you , it works well.

 

reversing the position

there is a method to instantly (with the mouse on the chart) reverse the position fromm sell to buy and viceversa ?

https://www.mql5.com/en/forum

thanks

 
tito:
there is a method to instantly (with the mouse on the chart) reverse the position fromm sell to buy and viceversa ?

https://www.mql5.com/en/forum

thanks

I think I have notice a script that do that but already forgot where it is

 

thanks, a good starting point

 

Why won't this script sell?

I'm playing with a simple script to buy and sell at the same time. It will place the buy but then ignores the sell command. The sell command is copied and pasted from a script that successfully sells so I know it's correct, but for some reason the two commands don't work together...

//+------------------------------------------------------------------+

//| Enter 0.05.mq4 |

//+------------------------------------------------------------------+

int start()

{

OrderSend(Symbol(), OP_BUY, 0.05, Ask, 3, 0, 0, "", 0, 0, CLR_NONE);

OrderSend(Symbol(), OP_SELL, 0.05, Bid, 3, 0, 0, "", 0, 0, CLR_NONE);

return(0);

}

Any suggestions?

 
ZTrader:
I'm playing with a simple script to buy and sell at the same time. It will place the buy but then ignores the sell command. The sell command is copied and pasted from a script that successfully sells so I know it's correct, but for some reason the two commands don't work together...
//+------------------------------------------------------------------+

//| Enter 0.05.mq4 |

//+------------------------------------------------------------------+

int start()

{

OrderSend(Symbol(), OP_BUY, 0.05, Ask, 3, 0, 0, "", 0, 0, CLR_NONE);

OrderSend(Symbol(), OP_SELL, 0.05, Bid, 3, 0, 0, "", 0, 0, CLR_NONE);

return(0);

}

[/CODE]

Any suggestions?

[CODE]int start()

{

OrderSend(Symbol(), OP_BUY, 0.05, Ask, 3, 0, 0, "", 0, 0, CLR_NONE);

Sleep(2000);

RefreshRates();

OrderSend(Symbol(), OP_SELL, 0.05, Bid, 3, 0, 0, "", 0, 0, CLR_NONE);

return(0);

}
 

Problem with testing the difference of two numbers

Hi, I need someone kind enough to tell me what is wrong with my way of comparing two numbers (line1 and line2) in the following code:

***

int Almost_Cross (double line1 , double line2)

{

if (line1 < 30.0 && line2 <30.0 && MathAbs(line1 - line2)<5.0)

{

return (1);

}

else

{

if (line1 < 30.0 && line2 < 30) Print("filtered buy order: "," ",line1," ",line2," ",MathAbs(line1-line2));

return (0);

}

if (line1 > 70.0 && line2 >70.0 && MathAbs(line2 - line1)<5.0)

{

return (2);

}

else

{

if (line1 > 70.0 && line2 >70.0) Print("filtered sell order: "," ",line2," ",line1," ",MathAbs(line2-line1));

return (0);

}

}

***

When I actually call the function in start() with the following code:

###

int is_almost_crossed = Almost_Cross(rsioma,marsioma);

if(fxs != EMPTY_VALUE && is_almost_crossed == 0)

{

Print("SELL order filtered : ",rsioma," ",marsioma," ",MathAbs(rsioma-marsioma));

}

###

For some unknown reason, I get 0 for Almost_Cross even if both rsioma and marsioma are larger than 70 and their difference is smaller than 5, as illustrated by the following line taken from the log:

22:22:40 2008.11.19 17:42 fxlive_caller GBPJPY,M5: SELL order filtered : 89.3971 84.8517 4.5454

Can anybody identify the problem? I would be exxxxtremely grateful to you.

Reason: