price question

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #69608 quote
    Pjotterd
    Participant
    Average

    Hi,

    I’m using the code below. There is just one thing I want to change. I don’t want the order to start on ‘close’ but I want the order to start when the price hits “orderhigh” or “orderlow”. What do I have to adjust in the code below?

    // RANGE between 0000h to 0600h
    IF TIME=060000 THEN
    channelhigh = Highest[12](high)
    channellow = Lowest[12](low)
    ENDIF
    
    // orderlines 3.5
    orderhigh= channelhigh + 3.5*pipsize
    orderlow= channellow - 3.5*pipsize
    
    
    // BREAKOUT Conditions
    c1= close > orderhigh
    c2= close < orderlow
    
    // LONG Positions-Opening
    IF Operationaltime and c1 AND alreadytraded = 0 THEN
    BUY 10 CONTRACT AT MARKET
    alreadytraded = 1
    ENDIF
     
    // SHORT Positions-Opening
    IF Operationaltime and c2 AND alreadytraded = 0 THEN
    SELLSHORT 10 CONTRACT AT MARKET
    alreadytraded = 1
    ENDIF
    #69615 quote
    Nicolas
    Keymaster
    Master

    You have to use pending STOP orders:

    if onmarket then 
     alreadytraded=1 
    endif
    
    // RANGE between 0000h to 0600h
    IF TIME=060000 THEN
    channelhigh = Highest[12](high)
    channellow = Lowest[12](low)
    ENDIF
    
    // orderlines 3.5
    orderhigh= channelhigh + 3.5*pipsize
    orderlow= channellow - 3.5*pipsize
    
    
    // LONG Positions-Opening
    IF Operationaltime AND alreadytraded = 0 THEN
    BUY 10 CONTRACT AT orderhigh stop
    //alreadytraded = 1
    ENDIF
     
    // SHORT Positions-Opening
    IF Operationaltime AND alreadytraded = 0 THEN
    SELLSHORT 10 CONTRACT AT orderlow stop
    //alreadytraded = 1
    ENDIF

    Because we can’t know in advance when the order is triggered, the “alreadytraded” variable is to test only when you are on market (and at the beginning of the code, to prevent new pending order while already at market and because the code is read from top to bottom).

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

price question


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Pjotterd @pjotterd Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by Nicolas
7 years, 10 months ago.

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