Stop daily trade function

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #191929 quote
    jackjour
    Participant
    New

    Please help, the back test working , but not working on demo trade.

    When doing back test, I can graph count and checked that when count = 3 then it stop trading for whole remaining day. However, I cannot graph “count” during demo trade and check it why the trade is not stopped.

    I use this function to stop whole remaining day trading if stop lost 3 times.

    if IntradayBarIndex = 0 then
    count = 0
    endif
    
    if strategyprofit - strategyprofit[1] = -800 then
    count = count + 1
    endif
    
    IF count < 3 and ((c1 and c10 and C11) or (c1 and C20) or (c20 and c10 and c11)) THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    #191935 quote
    robertogozzi
    Moderator
    Master

    It’s very rare that a loss is exactly 800 currency units, I suggest that you replace line 5 with:

    if strategyprofit - strategyprofit[1] <= -800 then
    #191940 quote
    jackjour
    Participant
    New

    Any suggested code for counting number of stop loss? I just wanna to stop remaining day trading when stop loss up to 3 times.

    As I set stop loss at -800 currency unit, it is work in the back test result.

    #191950 quote
    robertogozzi
    Moderator
    Master

    You can use this, without any constant value:

    if strategyprofit < strategyprofit[1] then
    #191977 quote
    JS
    Participant
    Senior

    Hi @jackjour,

    Try this:

    if IntradayBarIndex = 0 then
    count = 0
    endif
     
    if TradePrice * PositionPerf < -800 then
    count = count + 1
    endif
     
    IF count < 3 and ((c1 and c10 and C11) or (c1 and C20) or (c20 and c10 and c11)) THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    
    Nicolas thanked this post
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.

Stop daily trade function


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
jackjour @jackjour Participant
Summary

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

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 04/20/2022
Status: Active
Attachments: No files
Logo Logo
Loading...