Enter at the 4th hour and stop loss with time limit

 

Hi,


I am thinking of the following logic:


Take the first H4 bar from opening bell, measure the range


if range > threshold then enter immediately,

else do nothing.


What is the code for getting the open and close for the first H4 bar of the day? ( Assume London open is the opening of the day.)

------------------

Next, I want to develop a stop loss that is based on time.

If we are in a trade and it has not moved X amt of pips within 60 minutes, then modify order to exit at 4 hours from enter. ( assume GMT time)


-----------------


Please point me to the appropiate resources.



Thanks in advance.

 

one way to do it is to use https://docs.mql4.com/series/iBarShift to get the shift (index) of the bar you are looking for (at the specified time). Make sure you set the time per your brokerage timezone. After you have obtained the shift you can use iOpen() and iClose() to get the open and close values of your H4 bar...

thank you

Automated (automatedfx@gmail.com)

--

my recent grid trading:

http://fx-grid2.forexmosaic.com/ - 8621 pips in 7 weeks

http://fx-grid3.forexmosaic.com/ - 2068 pips in 3 weeks

Reason: