Help! Pivot Reversal

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

    Hello,

     

    I’ve been using Nicolas code below for my own manual trading, would love to be able to backtest it but can’t figure out how to code it at as an automated system, 100 % in the market and changing long / short when the indicator changes direction. Could anyone help a fellow out?

     

    //PRC_Pivot Reversal Strategy | indicator
    //14.02.2019
    //Nicolas @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    
    // --- settings
    leftp = 4
    rightp = 2
    // --- end of settings
    
    period=max(leftp,rightp)
    hh = highest[period](high)
    ll = lowest[period](low)
    
    if hh<>hh[1] then
    hhbar=barindex
    hhprice=high
    endif
    if ll<>ll[1] then
    llbar=barindex
    llprice=low
    endif
    
    if barindex-hhbar=rightp then
    drawtext("•",hhbar,hhprice) coloured(168,168,168)
    top=hhprice
    endif
    if barindex-llbar=rightp then
    drawtext("•",llbar,llprice) coloured(168,168,168)
    bottom=llprice
    endif
    
    atr=averagetruerange[14]
    if high crosses over top and lastsig<=0 then
    drawarrowup(barindex,low-atr/2) coloured(30,144,255)
    lastsig=1
    endif
    if low crosses under bottom and lastsig>=0 then
    drawarrowdown(barindex,high+atr/2) coloured(255,48,48)
    lastsig=-1
    endif
    
    RETURN
    
    #117295 quote
    Nicolas
    Keymaster
    Master

    You can try this below code (not tested). The strategy will open/close orders when a new pivot is detected, it is always on market.

    //PRC_Pivot Reversal Strategy | indicator
    //14.02.2019
    //Nicolas @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    
    // --- settings
    leftp = 4
    rightp = 2
    // --- end of settings
    
    period=max(leftp,rightp)
    hh = highest[period](high)
    ll = lowest[period](low)
    
    if hh<>hh[1] then
    hhbar=barindex
    hhprice=high
    endif
    if ll<>ll[1] then
    llbar=barindex
    llprice=low
    endif
    
    if barindex-hhbar=rightp then
    //drawtext("•",hhbar,hhprice) coloured(168,168,168)
    top=hhprice
    endif
    if barindex-llbar=rightp then
    //drawtext("•",llbar,llprice) coloured(168,168,168)
    bottom=llprice
    endif
    
    //atr=averagetruerange[14]
    if high crosses over top and lastsig<=0 then
    //drawarrowup(barindex,low-atr/2) coloured(30,144,255)
    lastsig=1
    buy at market 
    endif
    if low crosses under bottom and lastsig>=0 then
    //drawarrowdown(barindex,high+atr/2) coloured(255,48,48)
    lastsig=-1
    sellshort at market 
    endif
    
    
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

Help! Pivot Reversal


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
MonopolyTm @monopolytm Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by Nicolas
6 years, 1 month ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 01/18/2020
Status: Active
Attachments: No files
Logo Logo
Loading...