Pause code until tomorrow

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #99391 quote
    youngusyoungus
    Participant
    Junior

    Hello,

    Would someone help me with the code that will make the strategy pause until tomorrow when a target profit is hit. I want to use it in timeframe 5 minutes.
    The system will take trades but when a certain amount of profit is reached, the system will pause for the rest of the day and will continue tomorrow.

    Thank you

    #99395 quote
    JC_BywanJC_Bywan
    Moderator
    Master

    Moderation message: Topic moved from “platform support” forum  to the more appropriate “pro order” forum

    #99486 quote
    NicolasNicolas
    Keymaster
    Legend

    a certain amount of profit is reached

    You mean profit of the current day?

    #99657 quote
    youngusyoungus
    Participant
    Junior

    Yes, I was meaning the current day, something like:

    if todayProfit > X then
    pause strategy until tomorrow
    endif

    and the strategy will continue the day after because the todayProfit variable will be reinitialised to zero

    Thank you

    #99659 quote
    Juan SalasJuan Salas
    Participant
    Master

    Hi Youngus,

    I think you could use this

    // STRATEGYPROFIT per DAY //////////////////////////////////////////////////////////////////////////////
    // It resets the variable each new day
    IF INTRADAYBARINDEX = 0 THEN
    stratprofit = STRATEGYPROFIT //saves the previous day Profit
    nomoretrading = 0
    ENDIF
     
    // Finishing DAILY operations when reaching target profit/loss
    IF (STRATEGYPROFIT-stratprofit)>=40 THEN //current day's profit
    SELL AT MARKET
    EXITSHORT AT MARKET
    nomoretrading=1
    ENDIF
     
    IF (STRATEGYPROFIT-stratprofit)<=-40 THEN //current day's loss
    SELL AT MARKET
    EXITSHORT AT MARKET
    nomoretrading=1
    ENDIF

    In this case, when your operation is closed and your benefit is >=40 (currency, not points) your code will not launch any more orders. It also works for daily losses.

    In order to do that you should include in every BUYING/SELLING order nometrading=0

    IF yourconditions AND nomoretrading=0 THEN
    BUY 1 contract at market
    ENDIF

    I hope it is what you are looking for.

    Regards

    Nicolas thanked this post
    #99724 quote
    youngusyoungus
    Participant
    Junior

    Hello Juan,

    Thanks for the code. I’ll try implement it.

    Cheers

Viewing 6 posts - 1 through 6 (of 6 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

Pause code until tomorrow


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
youngus @youngus Participant
Summary

This topic contains 5 replies,
has 4 voices, and was last updated by youngusyoungus
7 years, 4 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 05/24/2019
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...