Past swing high swing low

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #206119 quote
    Johan
    Participant
    Average

    Whats the easiest way to check past swing high or swing low? I need to check if swing low or high i rising or lowering to strengthen my systems knowledge of the trend. If the past 2 or 3 swing lows is rising i don’t want to trade short and vice versa if the past 2 or 3 swing high is lower to each other i don’t want to trade long…

    Have anybody done something similar before and want to share that code?

    #206130 quote
    robertogozzi
    Moderator
    Master

    A swing is when there are two opposite candlesticks, with the leftmost one making a new high/low within the last N periods:

    ONCE Periods = 20
    ONCE hi1     = 0
    ONCE hi2     = 0
    ONCE hi3     = 0
    ONCE lo1     = 0
    ONCE lo2     = 0
    ONCE lo3     = 0
    Bullish = close > open
    Bearish = close < open
    NewHigh = (high = highest[Periods](high))
    NewLow  = (low  = lowest[Periods](low))
    HIswing = Bullish[1] AND Bearish AND NewHigh[1]
    LOswing = Bearish[1] AND Bullish AND NewLow[1]
    IF HIswing THEN
       hi3 = hi2
       hi2 = hi1
       hi1 = high[1]
    ENDIF
    IF LOswing THEN
       lo3 = lo2
       lo2 = lo1
       lo1 = low[1]
    ENDIF

    hi3 is the oldest swing high, hi2 is the previous one and hi1 is the current one. The same if the LOWs. You can compare them as suits you best.

    You may also filter SWINGs with other indicators or price action, to get rid of as many false signals as possible.

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

Past swing high swing low


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Johan @johan_holmberg Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by robertogozzi
3 years, 2 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 12/21/2022
Status: Active
Attachments: No files
Logo Logo
Loading...