Weekly HL and Monthly HL
Forums › ProRealTime English forum › ProOrder support › Weekly HL and Monthly HL
- This topic has 9 replies, 3 voices, and was last updated 1 year ago by MauroPro.
-
-
10/21/2023 at 10:06 PM #22276010/21/2023 at 11:20 PM #222762
// calculate daily high/low
dailyHigh = dHigh(1)
dailyLow = dLow(1)
// calculate weekly high/low
if dayOfWeek < dayOfWeek[1] then
weeklyHigh = Highest[BarIndex – lastWeekBarIndex](dailyHigh)
weeklyLow = Lowest[BarIndex – lastWeekBarIndex](dailyLow)
lastWeekBarIndex = BarIndex
endif
// calculate monthly high/low
if month <> month[1] then
monthlyHigh = Highest[BarIndex – lastMonthBarIndex](dailyHigh)
monthlyLow = Lowest[BarIndex – lastMonthBarIndex](dailyLow)
lastMonthBarIndex = BarIndex
endif
1 user thanked author for this post.
10/21/2023 at 11:27 PM #22276310/22/2023 at 7:48 AM #22276710/22/2023 at 9:08 AM #22277010/22/2023 at 9:15 AM #222771Weekly HL and Monthly HL12345678910111213141516171819202122232425// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivated// calculate daily high/lowdailyHigh = dHigh(1)dailyLow = dLow(1)// calculate weekly high/lowif dayOfWeek < dayOfWeek[1] thenweeklyHigh = Highest[BarIndex - lastWeekBarIndex](dailyHigh)weeklyLow = Lowest[BarIndex - lastWeekBarIndex](dailyLow)lastWeekBarIndex = BarIndexendif// calculate monthly high/lowif month <> month[1] thenmonthlyHigh = Highest[BarIndex - lastMonthBarIndex](dailyHigh)monthlyLow = Lowest[BarIndex - lastMonthBarIndex](dailyLow)lastMonthBarIndex = BarIndexendif// Conditions to enter long positionsc1 = (close CROSSES UNDER monthlyLow)IF c1 THENBUY 1 SHARES AT MARKETENDIFI do not get any positions with this code…
10/22/2023 at 9:19 AM #222774//Nasdaq CFD H1
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
// calculate daily high/lowdailyHigh = dHigh(1)
dailyLow = dLow(1)
// calculate weekly high/lowif dayOfWeek < dayOfWeek[1] then
weeklyHigh = Highest[BarIndex – lastWeekBarIndex](dailyHigh)
weeklyLow = Lowest[BarIndex – lastWeekBarIndex](dailyLow)
lastWeekBarIndex = BarIndex
endif
// calculate monthly high/low
if month <> month[1] then
monthlyHigh = Highest[BarIndex – lastMonthBarIndex](dailyHigh)
monthlyLow = Lowest[BarIndex – lastMonthBarIndex](dailyLow)
lastMonthBarIndex = BarIndex
endif
// Conditions to enter long positions
c1 = (close CROSSES UNDER monthlyLow)IF c1 THEN
BUY 1 SHARES AT MARKET
set stop pLoss 100
set target pProfit 200
ENDIF1 user thanked author for this post.
10/22/2023 at 12:58 PM #222780You con use graphOnPrice to see the max-min levels on the chart.
This is just a quick experiment: buy when the price crosses below the weekly maximum (Nasdaq 1 hour).
//Nasdaq TF: H1 [spread = 1]
defParam cumulateOrders = false
defParam preLoadBars = 10000
//——————————
positionSize = 1
//———————————————————————–
// calculate daily high/low
dailyHigh = dHigh(1)
dailyLow = dLow(1)
// calculate weekly high/low
if dayOfWeek < dayOfWeek[1] then
weeklyHigh = Highest[BarIndex – lastWeekBarIndex](dailyHigh)
weeklyLow = Lowest[BarIndex – lastWeekBarIndex](dailyLow)
lastWeekBarIndex = BarIndex
endif
// calculate monthly high/low
if month <> month[1] then
monthlyHigh = Highest[BarIndex – lastMonthBarIndex](dailyHigh)
monthlyLow = Lowest[BarIndex – lastMonthBarIndex](dailyLow)
lastMonthBarIndex = BarIndex
endif
//—————————————————————————-
c1L = close crosses under weeklyHigh
if not onMarket and c1L then
buy positionSize contracts at market
set stop pLoss 80
set target pProfit 280
endif
//—————————————-
pointToReachLong = 150*pointSize
pointToKeepLong = 10*pointSize
If not onMarket then
newSL = 0
endif
If longOnMarket then
If newSL = 0 and high – tradePrice(1) > pointToReachLong then
newSL = tradePrice(1) + pointToKeepLong
endif
If newSL > 0 and close-newSL > pointToReachLong then
newSL = newSL + pointToKeepLong
endif
endif
If newSL > 0 then
sell at newSL STOP
endif
//——————————————————–
graphOnPrice weeklyHigh coloured (189,252,201)
graphOnPrice weeklyLow coloured (255,215,0)
graphOnPrice monthlyHigh coloured (0,205,0)
graphOnPrice monthlyLow coloured (255,0,0)
// https://cloford.com/resources/colours/500col.htm1 user thanked author for this post.
10/22/2023 at 5:52 PM #22278810/22/2023 at 10:51 PM #222799It’s difficult for me to control bcause you use the future that is a bit different from the cfd.
However, from the chart you should understand which data is correct (also consider that pivot are calculated in different ways).
1 user thanked author for this post.
-
AuthorPosts