Weekly HL and Monthly HL

Forums ProRealTime English forum ProOrder support Weekly HL and Monthly HL

Viewing 10 posts - 1 through 10 (of 10 total)
  • #222760

    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

    // 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.
    #222763

    Doesn’t the weekly high also work like this?

    timeframe(1week, updateonclose)
    myhigh = high

    1 user thanked author for this post.
    #222767

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

    1 user thanked author for this post.
    #222770

    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

    I do not get any positions with this code…

    #222774

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

    1 user thanked author for this post.
    #222780

    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

     

    1 user thanked author for this post.
    #222788

    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

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

    1 user thanked author for this post.
Viewing 10 posts - 1 through 10 (of 10 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login