entry requirment relative to previous candle high or low

 

Hello everyone, I am putting together a strategy and I want to use previous candle highs or lows as a final filter for entry

For example if conditions A, B and C are satisfied at bar close, enter only if the price is above (for long trades) or moves above the last (specified number of candles), where you set the number of candles to be considered as a variable

In this example I am not sure how to specify that the price must be greater than all of the last (specified number of candles) highs for entry

Would some one please show me how to write this line or specify a value relative to a number of candles

thanks in advance

davep

 
pullend:

Hello everyone, I am putting together a strategy ........

Would some one please show me how to write this line or specify a value relative to a number of candles

thanks in advance

davep


If you were putting together a strategy then also you have to do some coding at it

That is the start for programming

If we show you how to write then it is like speaking .....

We 're helping with coding this is asking to code NO SLAVES

 

Untested ...

int lookback = 5;

if( Bid > High[ iHighest(NULL,0,MODE_HIGH,lookBack,0) ] ){
}
 
dabbler:

Untested ...


Bid is same as candel 0 (last price)
 
deVries:


If you were putting together a strategy then also you have to do some coding at it

That is the start for programming

If we show you how to write then it is like speaking .....

We 're helping with coding this is asking to code NO SLAVES


Thanks deVries, but I think you misunderstood me.

The reason for my question is that I am trying to code it myself and was not sure how to make the reference to previous number of bars.

The single line that dabbler provided is exactly what I needed.

It is the use of "Lookback" that has confused me previously and the answer to what I was missing here.

Certainly not looking for someone to do the work for me, just help understand the bits I am missing which as I understand it is the whole point of the forum

thanks davep

 
dabbler:

Untested ...



Briliiant, thanks dabbler, I have had trouble understanding the concept of "Lookback" previously

That single line is exactly what I needed to show me how to make the reference I needed and finish my code

thanks davep

 
pullend:

Thanks deVries, but I think you misunderstood me.

The reason for my question is that I am trying to code it myself and was not sure how to make the reference to previous number of bars.

The single line that dabbler provided is exactly what I needed.

It is the use of "Lookback" that has confused me previously and the answer to what I was missing here.

Certainly not looking for someone to do the work for me, just help understand the bits I am missing which as I understand it is the whole point of the forum

thanks davep




That doesn't matter i wanna see someone is trieing and if it won't succeed showing where it fails then you have thought about the problem

But can you now calculate a high everytradingday from "08:30" to "17:00" ??

 
deVries:
But can you now calculate a high everytradingday from "08:30" to "17:00" ??
#define HR0830 30,600 // 8*3600+30*60
#define HR1700 61,200
datetime LTD        = iTime(NULL, PERIOD_D1, 1), // Last trading day, not yesterday.
         LTD0830    = LTD + HR0830,
         LTD1700    = LTD + HR1700;
int      iLTD0830   = iBarShift(NULL, PERIOD_M30, LTD0830), // M30 or smaller
         iLTD1700   = iBarShift(NULL, PERIOD_M30, LTD1700),
         nLTD       = iLTD0830 - iLTD1700 - 1,
         iLTDHigh   = iHighest(NULL, PERIOD_M30, MODE_HIGH, nLTD-1, iLTD1700+1); // Not including
double   HHLTD      = iHigh(NULL, PERIOD_M30, iLTDHigh);
  1. "from '08:30' to '17:00' means it doesn't include 1700 on.
  2. Note, on GMT+0 brokers, Sunday is 2200-2400. There is no 0830-1700.
Reason: