STOP not executing on first trade forward test

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #18786 quote
    IGOSNELL
    Participant
    Average

    Hi

    I have the below code below that simply sets a stop based on the ATR when either in a long or short position. I have been forward testing on MY IG demo account since back testing does not give reliable results.

    The strategy works on a daily time frame on the South African TOP 40 index. The thing I find very strange is that it does not set the stop on the first trade, only on the second trade does it set the stop, Why is this?

    Am I the only person to experiencing this or is this peculiar to prorealtime?

    rang= AverageTrueRange[2]
    
    if longonmarket then
     SET STOP pLOSS (.16 * rang)
    endif
    
    if shortonmarket then
     SET STOP pLOSS (.15 * rang)
    endif
    #18815 quote
    Nicolas
    Keymaster
    Master

    Do these lines of codes are written before or after the BUY/SELLSHORT instructions?

    #18835 quote
    IGOSNELL
    Participant
    Average

    Hi Nicolas

    After the BUY and SELLSHORT instruction.

    I was wandering whether it should be enclosed within the BUY or SELLSHORT instruction.

    Regards

    Ian

    #18840 quote
    Nicolas
    Keymaster
    Master

    You can try to make a new variable named “stoploss” for instance, and give it the value of your calculated SL points (make it different when you initiate your orders BUY and SELLSHORT).

    Then, later in the code, add the SET stop loss line as is:

    SET STOP pLOSS stoploss
    #18873 quote
    IGOSNELL
    Participant
    Average

    Ok .  So if I understand correctly I will set the variable  in the buy or sellshort instruction and later in the code use the stop loss  command using the variable originally set  in the buy or sellshort command.

    Thanks, I will give it a try.

    Regards

    Ian

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

STOP not executing on first trade forward test


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
IGOSNELL @igosnell Participant
Summary

This topic contains 4 replies,
has 2 voices, and was last updated by IGOSNELL
9 years, 2 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 12/19/2016
Status: Active
Attachments: No files
Logo Logo
Loading...