Max e Min for Entry Price

 

Hello, I'm trying to fix my entry price between the maximum (or minimum) of the candles registered between 4 am and 6 am. I tried anything but the platform does not do anything.

I tried to write these lines:

datetime today1=D'09.01.2019 04:00:00';

datetime today2=D'09.01.2019 06:00:00';

datetime start_day = (today1);
datetime end_day = (today2);
int     fromBar = iBarShift(Symbol(), 5, start_day);
int     atBar = iBarShift(Symbol(), 5, end_day);
int     length = fromBar - atBar + 1;
int      HHbar = iHighest(Symbol(),5, MODE_HIGH, length, atBar);
int      LLbar = iLowest(Symbol(),5, MODE_LOW,  length, atBar);
double   HH = High[HHbar]; // iHigh(NULL,0, HHbar)
double   LL = Low[LLbar]; //  iLow(NULL,0, LLbar)

double OrdBuy=HH;

double OrdSell=LL

No error comes out of me but it does not work.


Can someone give me the solution so I can get it updated day by day?

 


Forum on trading, automated trading systems and testing trading strategies

When you post code please use the CODE button (Alt-S)!

Use the CODE button

 
int      HHbar = iHighest(Symbol(),5, MODE_HIGH, length, atBar);
int      LLbar = iLowest(Symbol(),5, MODE_LOW,  length, atBar);
double   HH = High[HHbar]; // iHigh(NULL,0, HHbar)
double   LL = Low[LLbar]; //  iLow(NULL,0, LLbar)

You are getting the shift for the M5 TF then using that shift for the current chart TF

 
Keith Watford:

You are getting the shift for the M5 TF then using that shift for the current chart TF

Hello Keith,


do you mean that?



datetime today1=D'09.01.2019 04:00:00';

datetime today2=D'09.01.2019 06:00:00';

datetime start_day = (today1);

datetime end_day = (today2);

int     fromBar = iBarShift(Symbol(), 5, start_day);

int     atBar = iBarShift(Symbol(), 5, end_day);

int     length = fromBar - atBar + 1;

int      HHbar = iHighest(Symbol(),PERIOD_CURRENT, MODE_HIGH, length, atBar);

int      LLbar = iLowest(Symbol(),PERIOD_CURRENT, MODE_LOW,  length, atBar);

double   HH = High[HHbar]; // iHigh(NULL,0, HHbar)

double   LL = Low[LLbar]; //  iLow(NULL,0, LLbar)


double OrdBuy=HH;


double OrdSell=LL;


but how can I automate the search for the maximum (and the minimum) every day from 4 to 6 in the morning?

 

Keith Watford:

When you post code please use the CODE button (Alt-S)!



You are still mixing TF

 
Keith Watford:

You are still mixing TF

datetime today1=D'09.01.2019 04:00:00';

datetime today2=D'09.01.2019 06:00:00';

datetime start_day = (today1);

datetime end_day = (today2);

int     fromBar = iBarShift(Symbol(), 5, start_day);

int     atBar = iBarShift(Symbol(), 5, end_day);

int     length = fromBar - atBar + 1;

int      HHbar = iHighest(Symbol(),PERIOD_CURRENT, MODE_HIGH, length, atBar);

int      LLbar = iLowest(Symbol(),PERIOD_CURRENT, MODE_LOW,  length, atBar);

double   HH = High[HHbar]; // iHigh(NULL,0, HHbar)

double   LL = Low[LLbar]; //  iLow(NULL,0, LLbar)



double OrdBuy=HH;



double OrdSell=LL;
 
Keith Watford:

You are still mixing TF

I understood, sorry.

Reason: