Help to write some codes

 

Hi,

I wanna to write a code that start to scan chart in 8 GMT, when price move for example 15 pips in each direction, puts a pending order in opposite direction, i wrote some code but it didnt work properely, WHY?


if(OrdersTotal()<Max_Order){
if (h>=8 &&h<9 ){
if (Bid-Open[BAR]>PIPdistance*Point){
OrderSend(Symbol(),OP_SELLSTOP,LotsOptimized(),OrderPrice_Sell,Slippage,0,0,"Sell",Magic,0,Red);
}
if( Open[BAR]-Ask>PIPdistance*Point){
OrderSend(Symbol(),OP_BUYSTOP,LotsOptimized(),OrderPrice_Buy,Slippage,0,0,"Buy",Magic,0,Green);
}
}
}
 
1350:

Hi,

I wanna to write a code that start to scan chart in 8 GMT, when price move for example 15 pips in each direction, puts a pending order in opposite direction, i wrote some code but it didnt work properely, WHY?


if(OrdersTotal()<Max_Order){
if (h>=8 &&h<9 ){
if (Bid-Open[BAR]>PIPdistance*Point){
OrderSend(Symbol(),OP_SELLSTOP,LotsOptimized(),OrderPrice_Sell,Slippage,0,0,"Sell",Magic,0,Red);
}
if( Open[BAR]-Ask>PIPdistance*Point){
OrderSend(Symbol(),OP_BUYSTOP,LotsOptimized(),OrderPrice_Buy,Slippage,0,0,"Buy",Magic,0,Green);
}
}
}

Okay, first things first:

- How are you setting the contents of the "h" variable?

- When you say that its not working properly, can you be more specific?

 
cloudbreaker:

Okay, first things first:

- How are you setting the contents of the "h" variable?

- When you say that its not working properly, can you be more specific?

Dear cloudbreaker,

Thanks for your prompt reply, i set the h with below codes:

extern int Broker_Hour_Differ=2;
extern int Broker_Minute_Differ=0;

then in start section i wrote:

datetime GMT_Time=(TimeCurrent()-(Broker_Hour_Differ*3600)-(Broker_Minute_Differ*60));
int h=TimeHour(GMT_Time);

-about your second question:

this EA puts the positions so far from the real point for example when there are all condition to putting order at 02:01 it put order at 2:20

there is othere problem that i cant set the expiration time for pending orders,when i set expiration time, while i dont connect to internet the EA,delete expired position but when i connect it didnt put any order.

Regards

 
1350:

Dear cloudbreaker,

Thanks for your prompt reply, i set the h with below codes:

extern int Broker_Hour_Differ=2;
extern int Broker_Minute_Differ=0;

then in start section i wrote:

datetime GMT_Time=(TimeCurrent()-(Broker_Hour_Differ*3600)-(Broker_Minute_Differ*60));
int h=TimeHour(GMT_Time);

-about your second question:

this EA puts the positions so far from the real point for example when there are all condition to putting order at 02:01 it put order at 2:20

there is othere problem that i cant set the expiration time for pending orders,when i set expiration time, while i dont connect to internet the EA,delete expired position but when i connect it didnt put any order.

Regards

Okay, will have a look at code later. Meanwhile - could it be that there just aren't any incoming ticks to trigger it?

 
cloudbreaker:

Okay, will have a look at code later. Meanwhile - could it be that there just aren't any incoming ticks to trigger it?

ok Thanks,i'm awaiting for your answer.

 
I'm awaiting yet
 
1350:
I'm awaiting yet

Been busy. Your time calculation looks ok. I did ask you earlier if perhaps the reason that your code is not triggered when you expect it to be, may be that there are no incoming ticks? (The start() function is only triggered each time there is a tick incoming). Could that be what is causing your delay?

Why not check this out via the Experts tab by simply adding the following line to the start() function after you calculate h.

Print("h=",h);

Let me know how you get on.

 
cloudbreaker:

Been busy. Your time calculation looks ok. I did ask you earlier if perhaps the reason that your code is not triggered when you expect it to be, may be that there are no incoming ticks? (The start() function is only triggered each time there is a tick incoming). Could that be what is causing your delay?

Why not check this out via the Experts tab by simply adding the following line to the start() function after you calculate h.

Print("h=",h);

Let me know how you get on.

Thanks, I think you are right, there isnt incoming ticks in backtest, i checked "h", it works properely & return the GMT time for example 5, but expiration time dont work yet.

Regards

 
1350:

Thanks, I think you are right, there isnt incoming ticks in backtest, i checked "h", it works properely & return the GMT time for example 5, but expiration time dont work yet.

Regards

Dear Sir

why expiration time dont work?

 
1350:

Dear Sir

why expiration time dont work?

You'll need to tell us how you set OrderPrice_Buy and OrderPrice_Sell then.

You've GOT to have had some idea I was going to ask for that...

 

Dear All, I am very newbie here. Can you teach me how to program this logic? I love to learn MQL programming :). Your help would be much appreciated.

Can anyone tell me how to program this? Conditions are, if MA(any) close (marked in red dot) just above the center of candle body (marked as light gray vertical line) In other words, if the Red Dot is placed between 50% to 63% on a Bearish Candle, then show the RED DOT & LIGHT GRAY LINE, otherwise don't show or don't mark.

Any help pls?

Be Awesome,

Raj