Buy order after two conditions from 2 time frames

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #176523 quote
    assafn
    Participant
    Average

    Hello,

    I’m having trouble writing a code with conditions from 2 TF.

    1. Weekly rsi[9] crosses under 30

    and then wait for:

    2. Daily rsi[14] crosses under 20.

    Is that possible?

    #176529 quote
    robertogozzi
    Moderator
    Master

    There you go:

    timeframe(Weekly,UpdateOnClose)
    Wrsi = rsi[9]
    c1 = Wrsi crosses under 30
    Timeframe(Daily,UpdateOnClose)
    Drsi = rsi[14]
    c2 = Drsi crosses under 20
    Timeframe(Default)
    Cond = c1 AND c2
    IF Cond THEN
       buy at market
       set stop   ploss   200
       set target pprofit 400
    ENDIF
    #176531 quote
    robertogozzi
    Moderator
    Master

    At lines 1 and 4 you can replace UpdateOnClose with Default, not to wait the closing of the candle before updating variables.

    assafn thanked this post
    #176535 quote
    assafn
    Participant
    Average

    Thank you robertogozzi

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

Buy order after two conditions from 2 time frames


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
assafn @assafn Participant
Summary

This topic contains 3 replies,
has 2 voices, and was last updated by assafn
4 years, 5 months ago.

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