Weekly HL and Monthly HL

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #222760 quote
    Inertia
    Participant
    Master

    Hello Roberto and all,

    May I have the following snippet of code at your best convenience please:

    1. Low Month Previous
    2. High Month Previous
    3. Low Week Previous
    4. High Week Preivous

    Thank you.

    Damien

    #222762 quote
    MauroPro
    Participant
    Veteran

    // 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

    Inertia thanked this post
    #222763 quote
    phoentzs
    Participant
    Master

    Doesn’t the weekly high also work like this?

    timeframe(1week, updateonclose)
    myhigh = high

    Inertia thanked this post
    #222767 quote
    MauroPro
    Participant
    Veteran

    Yes. They are two ways of writing the same thing, without and with the multitimeframe.

    Inertia thanked this post
    #222770 quote
    Inertia
    Participant
    Master

    Thank yo MauroPro. Top.

    How would you wright the buying condition to, let’s say buy 1 contract on the low of the month/week?

    If monthlyLow then

    buy 1 contract?

    Thank you very much.

    Damien

    #222771 quote
    Inertia
    Participant
    Master
    // Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    // 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
    // Conditions to enter long positions
    c1 = (close  CROSSES UNDER monthlyLow)
    
    IF c1 THEN
    BUY 1 SHARES AT MARKET
    ENDIF
    

    I do not get any positions with this code…

    #222774 quote
    MauroPro
    Participant
    Veteran

    //Nasdaq CFD H1

    // Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    // 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
    // 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
    ENDIF

    Inertia thanked this post
    #222780 quote
    MauroPro
    Participant
    Veteran

    You 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.htm

    Inertia thanked this post
    #222788 quote
    Inertia
    Participant
    Master

    Thank you very much MauroPro.

    Works nearly perfectly. Just a little discrepancy highlighted in yellow (between your indicator and the PRT PP). Who’s right ? ;-))

    #222799 quote
    MauroPro
    Participant
    Veteran

    It’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).

    Inertia thanked this post
Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.

Weekly HL and Monthly HL


ProOrder support

New Reply
Author
author-avatar
Inertia @inertia Participant
Summary

This topic contains 9 replies,
has 3 voices, and was last updated by MauroPro
2 years, 3 months ago.

Topic Details
Forum: ProOrder support
Language: English
Started: 10/21/2023
Status: Active
Attachments: 2 files
Logo Logo
Loading...