Opening Second Position Just after the close of Previous Candle which has triggered the first Active order.

 

Hi coders , I am new here in the world of coding but I am learning! However, I am stuck and requesting for an honest help from someone to help me with opening new (second )order on the close of the previous candle which is having the active first position.

NOTE: I mean the code must only open the second position just after the close of the previous candle which is having the active first open order already.

I have tried to use new candle open function that I created but in most cases, it is not opening the second position as I intend it to work...I have attached a screenshot where you see, buy direction has two position and sell direction has only one position and also sometimes order is getting opened on the candle which I don't want!

here is the piece of code

if( ( OrderType()==Buy || OrderType()==Sell ) && IsNewCandle() )
{
   //OrderSend...
}

Improperly formatted code edited by moderator.

I have tried to use OrderOpenTime() function to compare with the candle time that the first position is active on BUT I am stuck on how to make it work, some body please help.

thanks in advance

Files:
 
Your topic has been moved to the section: MQL4 and MetaTrader 4
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
 

In the future, please use the CODE button (Alt-S) when inserting code.

Code button in editor

 
Fernando Carreiro #:

In the future, please use the CODE button (Alt-S) when inserting code.

Noted.