Hi all,
I'm using the below code to prevent any new Order from being sent if there is already an Order sent to server within the same candle. This code works fine......
<SNIP>
i've been trying to get the solution for this for some time now but without any success. really appreciate your assistance as i don't know where i've made the mistake..
You have been asked before . . . .
Please edit your post . . . . or your code will be deletedPlease use this to post code . . . it makes it easier to read.
Hi all,
similarly i substituted the lastorderbartime to lastclosebartime hoping that i could use the same code to prevent a new order from being sent after a previous order was closed withing the candle. unfortunatelly it doesnt work.
i've been trying to get the solution for this for some time now but without any success. really appreciate your assistance as i don't know where i've made the mistake..
You need to set the value of lastclosebartime to be the time when the Order was closed, if you close the Order manually in code then you can set . . .
lastclosebartime = TimeCurrent();
if it is closed by TP or SL you will need to detect this happening, select the correct order and use it's OrderCloseTime(), once you have the time you will need to adjust the time to a Bar time or your comparison to Time[0] will always fail . . .
No need to detect when the order closed. Only need to detect when the order was last open.
Each time you find the order still open (i.e. OrderSelect loop,) remember the time lastOpenOrderTime = TimeCurrent(). Then don't open unless Time[0] > lastOpenOrderTime
RaptorUK......
Sorry....it was my mistake.....for not using the SRC to include the code... i thought if it is just an excerpt from the full code i can write it in the comments space..... alright i'll keep in mind to use the SRC for including any code in future.
Using the command (A)...im able to prevent a new order from being sent after closing of an order which originated in the same candle. i'm using the EA in a 1Hr chart. and this works well. The closing condition is due to SL or TP
//Command (A) static datetime lastorderbartime = 0; //other trade entry criteria up till here. if(Time[0]!= lastorderbartime) { OrderSend(..................); lastorderbartime = Time[0]; } // followed by OrderSelect and other closing criteria... //Command (B) static datetime lastclosebartime = 0; // other trade entry criteria up till here. if(Time[0]!= lastclosebartime) { OrderSend(..............); lastclosebartime = Time[0]; // followed by OrderSelect and other closing criteria....
What i want to achieve for a different situation is.....
write a similar command (B) to prevent a new order from being sent after the closing of an order which originated from previous candles. As long as there is a closing in current candle , no new trade shall be allowed until the following candle starts. The condition for closing a trade is due to meeting some set criteria and not SL or TP
thank you...
What i want to achieve for a different situation is.....
write a similar command (B) to prevent a new order from being sent after the closing of an order which originated from previous candles. As long as there is a closing in current candle , no new trade shall be allowed until the following candle starts. The condition for closing a trade is due to meeting some set criteria and not SL or TP
guys....thank you for the options....i'll try it.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi all,
I'm using the below code to prevent any new Order from being sent if there is already an Order sent to server within the same candle. This code works fine......
<SNIP>
similarly i substituted the lastorderbartime to lastclosebartime hoping that i could use the same code to prevent a new order from being sent after a previous order was closed withing the candle. unfortunatelly it doesnt work.
<SNIP>
i've been trying to get the solution for this for some time now but without any success. really appreciate your assistance as i don't know where i've made the mistake..
thank you...