Pause code until tomorrow

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #99391 quote
    youngus
    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_Bywan
    Moderator
    Master

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

    #99486 quote
    Nicolas
    Keymaster
    Master

    a certain amount of profit is reached

    You mean profit of the current day?

    #99657 quote
    youngus
    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 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
    youngus
    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.

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 youngus
6 years, 9 months ago.

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