Calculating weekly strategy profit

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #56675 quote
    Juan SalasJuan Salas
    Participant
    Master

    Hi all,

    I am working on a code that work from Monday to Friday. I will open on Monday and will close on Friday unless the code reach x profit or y losses.

    To modify the strategyprofit for just one day, Roberto showed a nice piece of code that I have just changed to a weekly strategy profit. I just wanted to have confirmation that it is correct.

    // STRATEGYPROFIT per WEEK. It resets the variable each new week
    IF dayofweek=1 AND INTRADAYBARINDEX = 0 THEN
    stratprofit = STRATEGYPROFIT //saves the previous week Profit
    nomoretrading = 0
    ENDIF
    
    //Finishing WEEKLY operations when reaching target profit/loss
    IF (STRATEGYPROFIT-stratprofit)>=100 THEN //current week's profit
    SELL AT MARKET
    EXITSHORT AT MARKET
    nomoretrading=1
    ENDIF
    
    IF (STRATEGYPROFIT-stratprofit)<=-100 THEN //current week's loss
    SELL AT MARKET
    EXITSHORT AT MARKET
    nomoretrading=1
    ENDIF

    Thanks,

    Juan

    #56678 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    The logic is fine, in case line 2 doesn’t work as expected try

    IF Opendayofweek=1 AND INTRADAYBARINDEX = 0 THEN

    You only have to demo it!

    Juan Salas and Nicolas thanked this post
    #56682 quote
    Juan SalasJuan Salas
    Participant
    Master

    Hi Roberto,

    Thanks again. I will try your option in case does not work.

    Regards,

    Juan

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

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Calculating weekly strategy profit


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Juan Salas @juan-salas Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by Juan SalasJuan Salas
8 years, 9 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 12/27/2017
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...