Referencing past candles

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

    Hi, in my system I need it to buy/short when a moving average crosses the price and when the RSI has been over 60/under 40 in the last 3 candles. Please help i don’t know how to do this. 🙂

    defparam preloadbars = 15
    defparam CUMULATEORDERS = false
    indicator2 = call "example5 : RSI"[14]
    brsi = (indicator2 < 45)
    
    indicator3 = call "example5 : RSI"[14]
    srsi = (indicator3 > 65)
    
    indicator1 = Average[9](close)
    
    once haclose=close
    once haopen=open
    
    if barindex>1 then
    haclose=(open+close+low+high)/4
    haopen=(haopen[1]+haclose[1])/2
    endif
    
    //buy condition
    cBuy = (haclose CROSSES OVER indicator1 and brsi)
    
    //sell condition
    cSell = (haclose CROSSES UNDER indicator1 and srsi)
    
    If cbuy then
    buy 5000 CASH at market
    endif
    
    If csell then
    sell at market
    endif
    
    if csell then
    sellshort 5000 CASH at market
    endif
    
    if cbuy then
    exitshort at market
    endif
    #10264 quote
    mr.brymas
    Participant
    Average

    Check this thread: http://www.prorealcode.com/topic/rsi-sab-strategy/

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

Referencing past candles


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
jbyrne @jbyrne Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by mr.brymas
9 years, 7 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 07/05/2016
Status: Active
Attachments: No files
Logo Logo
Loading...