AbzParticipant
Veteran
hello
when using Dhigh(10) does this return the highest value 10 days ago or the highets value within 10 days? im looking for a variable that looks for the highest within a ceratin periode of time.
It will return the highest value 10 days ago.
For the highest value within the 10 latest days:
Newhigh=0
FOR i = 0 TO 10 DO
IF DHigh(i)>Newhigh THEN
Newhigh = DHigh(i)
ENDIF
NEXT
AbzParticipant
Veteran
if i want to check for highest candle 14 days back on a 5 min chart is this correct to tuse?
//-------------------------------------------------------------------------
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
DEFPARAM FLATBEFORE = 080000
DEFPARAM FLATAFTER = 220000
Newhigh=0
FOR i = 0 TO 4032 DO
IF DHigh(i)>Newhigh THEN
Newhigh = DHigh(i)
ENDIF
NEXT
c13 = Time < 170000
// Conditions to enter Long positions
c1 = close > Newhigh
IF not onmarket AND c13 AND c1 THEN
sellshort 2 SHARES AT MARKET
SET STOP pLOSS 25
SET TARGET pPROFIT 25
ENDIF
You don’t need to use 4032 periods lookback, since the daily OHLC can be retrieve from any timeframe with Dhigh, Dlow, etc..
The solution H_kan gave you is a good one, you just need to replace “10” by “15” to make the loop 15 days back. H_kan could confirm too 🙂
Yes. It works like Nicolas says. DHigh always picks the highest daily value undependently of which timeframe you use. If you use 4032 in your code it will look 4032 days back!