Condition without specific timeframe attatched

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #160799 quote
    RobinJK
    Participant
    Junior

    How do i make a condition to enter a trade without it having a specific timeframe?

    For example in this code when 5 ma crosses over 20 ma it will buy, buy only if the RSI is below 30 in the same time period.

    How do i create a code that recognise that 5 ma has crossed over 20 ma and the first time RSI goes below 30 any time after that, if 5 ma is still over 20 ma it buys.

    Can i somehow loop c1 untill c2 has happend?

    //Enter Long
    indicator1 = Average[20](close)
    indicator2 = Average[5](close)
    c1 = (indicator2 CROSSES OVER indicator1)
    indicator3 = RSI[14](close)
    c2 = (indicator3 < 30)
    
    IF c1 AND c2 THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    
    #160816 quote
    robertogozzi
    Moderator
    Master

    There you go:

    Once c1 = 0
    indicator1 = Average[20](close)
    indicator2 = Average[5](close)
    If OnMarket or (indicator2 CROSSES UNDER indicator1) then
       c1 = 0
    Endif
    If c1 = 0 then
       c1 = (indicator2 CROSSES OVER indicator1)
    Endif
    indicator3 = RSI[14](close)
    c2 = (indicator3 < 30)
     
    IF c1 AND c2 THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    #160867 quote
    RobinJK
    Participant
    Junior

    Thanks! Very helpfull.

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

Condition without specific timeframe attatched


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
RobinJK @robinjk Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by RobinJK
5 years ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 02/09/2021
Status: Active
Attachments: No files
Logo Logo
Loading...