BCParticipant
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?
BCParticipant
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