[Beginner] How to sell a position after 1 week

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #47537 quote
    fitdude
    Participant
    New

    Hi,

    I want to backtest a strategy were I buy at RSI>30 and sell (not going short) after 1 week. I’m having trouble finding out how to define the sell contidion. Is it possible to set this condition in “simplified creation” tab? Or do i have to code it?

    #47614 quote
    Wing
    Participant
    Veteran

    Try this on for example the 30m timeframe:

    MyRSI=RSI[14]
    once DayToSell=10
    once TimeToSell=000000
    
    if MyRSI>30 and MyRSI[1]<30 and onmarket=0 then
    buy 1 lot at market
    DayToSell=dayofweek
    TimeToSell=time
    endif
    
    if dayofweek=DayToSell and time<TimeToSell and time>TimeToSell-10000
    sell 1 lot at market
    endif
    
    
    

    Does something like that work?

    #48046 quote
    fitdude
    Participant
    New

    Thank you for your help. Unfortunately, the code has an error in line 11.

    #48071 quote
    Despair
    Blocked
    Master

    Add the word THEN in the end of the line 11.

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

[Beginner] How to sell a position after 1 week


General Trading: Market Analysis & Manual Trading

New Reply
Author
author-avatar
fitdude @fitdude Participant
Summary

This topic contains 3 replies,
has 3 voices, and was last updated by Despair
8 years, 4 months ago.

Topic Details
Forum: General Trading: Market Analysis & Manual Trading
Language: English
Started: 09/27/2017
Status: Active
Attachments: No files
Logo Logo
Loading...