How to limited one stop order per day?

Viewing 2 posts - 16 through 17 (of 17 total)
  • Author
    Posts
  • #113906 quote
    BC
    Participant
    Master

    Hi PRT Master

     

    I am back on this stop order project but still cannot solve this issue.

    Will V11 add a command like Tradestation EntriesToday(date) to simplify this kind of case?

    #113952 quote
    BC
    Participant
    Master

    Below syntax seem can limited one pending stop order (either Long or Short) per day when triggered and closed on same bar,

    but still cannot make maximum one long and one short per day.

     

    Defparam Preloadbars = 5000
    Defparam Cumulateorders = False
     
    // Max Stop Loss
    MaxStopLossPoint = 50
     
    // Trade only on below time
    Once StartBetTime = 91500
    Once LastBetTime = 160000
    TradingTime = Time >= StartBetTime and Time <= LastBetTime
     
    // Cloase all Position
    Once ClosePositionTime = 163000
     
    // Capture Yesterday High Low
    If DayofWeek = 1 then
    Dayhigh = DHigh(2)
    DayLow = DLow(2)
    EndIf
     
    If DayofWeek >=2 and DayofWeek < 6 then
    Dayhigh = DHigh(1)   // YesterdayHigh
    DayLow = DLow(1)     // YesterdayLow
    EndIf
     
    // OffSet Setting
    LongLocation = Dayhigh + (0.2 * AverageTrueRange[14](Close))
    ShortLocation = DayLow - (0.2 * AverageTrueRange[14](Close))
    
    // Trade Order Process
    If Time <= StartBetTime then
    
    // Reset Daily TradeIndex
    CheckTradeIndex = TradeIndex
    
    ElsIf Time >= StartBetTime then
     
    // Long Entry
    If TradingTime and CheckTradeIndex = TradeIndex then
    Buy 1 Contract at LongLocation Stop
    EndIf
    
    // Short entry
    If TradingTime and CheckTradeIndex = TradeIndex then
    SellShort 1 Contract at ShortLocation Stop
    EndIf
    
    EndIf
     
    // Close all position
    If Time = ClosePositionTime then
    If LongonMarket then
    Sell at Market
    Endif
    If ShortonMarket  then
    ExitShort at Market
    Endif
    Endif
     
    // Stop Loss
    Set Stop pLOSS MaxStopLossPoint
    
    graph CheckTradeIndex
    graph TradeIndex
Viewing 2 posts - 16 through 17 (of 17 total)
  • You must be logged in to reply to this topic.

How to limited one stop order per day?


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
BC @robin_chan Participant
Summary

This topic contains 16 replies,
has 3 voices, and was last updated by BC
6 years, 3 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 10/23/2019
Status: Active
Attachments: 3 files
Logo Logo
Loading...