How to limited one stop order per day?
Forums › ProRealTime English forum › ProOrder support › How to limited one stop order per day?
- This topic has 16 replies, 3 voices, and was last updated 6 years ago by
BC.
-
-
10/23/2019 at 2:56 PM #110938
Hi PRT Master
I copy the syntax from below Blog to control the trade (Stop order, Long & Short) per day, but I found it will out of order if the 1st trade close at the 1st bar, is there any solution to solve this issue?
https://www.prorealcode.com/blog/automated-breakout-trading-strategy-french-cac40/
Thanks.
10/23/2019 at 3:08 PM #11094210/23/2019 at 11:19 PM #11099610/24/2019 at 2:57 AM #111004Hi BC I notice you are from HK as well.
Feel free to contact me at [deleted by moderator] for more discussion and sharing of ideas.
btw i leave the message here because i don’t see any inbox function on this forum, or have I missed it?
10/24/2019 at 7:56 AM #111019@solar Sorry but there is no private messaging in the forum and sharing personal link is not allowed.
@BC You can use the snippet below, it returns a boolean if we were at market on the previous bar, and even if an order has opened and closed during it.
123456if ( (not onmarket and onmarket[1] and not onmarket[2]) or (tradeindex(1)=tradeindex(2) and tradeindex(1)=barindex[1] and tradeindex(1)>0) ) and lastcheck<>barindex thenlastcheck = barindexwasonmarket=1elsewasonmarket=0endif10/24/2019 at 9:21 AM #11103310/24/2019 at 10:45 AM #11104910/24/2019 at 12:06 PM #11105310/24/2019 at 2:36 PM #111076Hi Nicolas
I tried but not work on below code, it seem [wasonmarket] will return=0 after a position close.
What I did wrong?
Thanks
My stop order code123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081Defparam Preloadbars = 5000Defparam Cumulateorders = False// no MM Position SizeOnce noMMPositionSizeLong = 1Once noMMPositionSizeShort = 1// Target Profit and Stop Lost SetupTProfitMultipeRate = 1.5SLostMultipeRate = 0.75// Function SwitchMaxStopLoss = 1// Max Stop LossMaxStopLossPoint = 100// Trade only on below timeOnce StartBetTime = 91500Once LastBetTime = 160000TradingTime = Time >= StartBetTime and Time <= LastBetTime// Cloase all PositionOnce ClosePositionTime = 163000// Capture Yesterday High LowIf DayofWeek = 1 thenDayhigh = DHigh(2)DayLow = DLow(2)YesterdayRange = Dayhigh - DayLowEndIfIf DayofWeek >=2 and DayofWeek < 6 thenDayhigh = DHigh(1)DayLow = DLow(1)YesterdayRange = Dayhigh - DayLowEndIf// Trade ProcessIf TradingTime then// Nicolas Codeif ( (not onmarket and onmarket[1] and not onmarket[2]) or (tradeindex(1)=tradeindex(2) and tradeindex(1)=barindex[1] and tradeindex(1)>0) ) and lastcheck<>barindex thenlastcheck = barindexwasonmarket=1elsewasonmarket=0EndIf// Long EntryIf wasonmarket = 0 thenBuy noMMPositionSizeLong Contract at Dayhigh StopEndIf// Short entryIf wasonmarket = 0 thenSellShort noMMPositionSizeShort Contract at DayLow StopEndifEndIf// Close all positionIf Time = ClosePositionTime thenIf LongonMarket thenSell at MarketEndifIf ShortonMarket thenExitShort at MarketEndifEndif// Stop Loss and Target ProfitIf MaxStopLoss thenSet Stop pLOSS Min(MaxStopLossPoint,(YesterdayRange*SLostMultipeRate))ElseSet Stop pLOSS YesterdayRange*SLostMultipeRateEndIfSet Target pPROFIT YesterdayRange*TProfitMultipeRategraph wasonmarket10/24/2019 at 3:27 PM #111094You didn’t adapt it correctly to your own strategy, because you should only reset the variable one time each day:
delete lines 46 and 47 and put that at the beginning of the code:
123if day<>day[1] or intradaybarindex=0 thenwasonmarket=0endif10/25/2019 at 12:33 AM #111133Hi Nicolas
I tried to follow your instruction, but seem not work correctly.
Thanks
My stop order code123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384Defparam Preloadbars = 5000Defparam Cumulateorders = False// no MM Position SizeOnce noMMPositionSizeLong = 1Once noMMPositionSizeShort = 1// Target Profit and Stop Lost SetupTProfitMultipeRate = 1.5SLostMultipeRate = 0.75// Function SwitchMaxStopLoss = 1// Max Stop LossMaxStopLossPoint = 100// Trade only on below timeOnce StartBetTime = 91500Once LastBetTime = 160000TradingTime = Time >= StartBetTime and Time <= LastBetTime// Cloase all PositionOnce ClosePositionTime = 163000// Capture Yesterday High LowIf DayofWeek = 1 thenDayhigh = DHigh(2)DayLow = DLow(2)YesterdayRange = Dayhigh - DayLowEndIfIf DayofWeek >=2 and DayofWeek < 6 thenDayhigh = DHigh(1)DayLow = DLow(1)YesterdayRange = Dayhigh - DayLowEndIf// Trade Processif day<>day[1] or intradaybarindex=0 thenwasonmarket=0endifIf TradingTime then// Nicolas Codeif ( (not onmarket and onmarket[1] and not onmarket[2]) or (tradeindex(1)=tradeindex(2) and tradeindex(1)=barindex[1] and tradeindex(1)>0) ) and lastcheck<>barindex thenlastcheck = barindexwasonmarket=1EndIf// Long EntryIf wasonmarket = 0 thenBuy noMMPositionSizeLong Contract at Dayhigh StopEndIf// Short entryIf wasonmarket = 0 thenSellShort noMMPositionSizeShort Contract at DayLow StopEndifEndIf// Close all positionIf Time = ClosePositionTime thenIf LongonMarket thenSell at MarketEndifIf ShortonMarket thenExitShort at MarketEndifEndif// Stop Loss and Target ProfitIf MaxStopLoss thenSet Stop pLOSS Min(MaxStopLossPoint,(YesterdayRange*SLostMultipeRate))ElseSet Stop pLOSS YesterdayRange*SLostMultipeRateEndIfSet Target pPROFIT YesterdayRange*TProfitMultipeRategraph wasonmarket10/25/2019 at 8:50 AM #111154Because you included the condition into “tradingtime”, so the test cannot be made outside the time conditions. Anyway, I also made a small add to the condition to check another ‘wasonmarket’ situation that was not included.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384Defparam Preloadbars = 5000Defparam Cumulateorders = False// no MM Position SizeOnce noMMPositionSizeLong = 1Once noMMPositionSizeShort = 1// Target Profit and Stop Lost SetupTProfitMultipeRate = 1.5SLostMultipeRate = 0.75// Function SwitchMaxStopLoss = 1// Max Stop LossMaxStopLossPoint = 100// Trade only on below timeOnce StartBetTime = 91500Once LastBetTime = 160000TradingTime = Time >= StartBetTime and Time <= LastBetTime// Cloase all PositionOnce ClosePositionTime = 163000// Capture Yesterday High LowIf DayofWeek = 1 thenDayhigh = DHigh(2)DayLow = DLow(2)YesterdayRange = Dayhigh - DayLowEndIfIf DayofWeek >=2 and DayofWeek < 6 thenDayhigh = DHigh(1)DayLow = DLow(1)YesterdayRange = Dayhigh - DayLowEndIf// Trade Processif day<>day[1] or intradaybarindex=0 thenwasonmarket=0endif// Nicolas Codeif ( (not onmarket and onmarket[1] and not onmarket[2]) or (tradeindex(1)=tradeindex(2) and tradeindex(1)=barindex[1] and tradeindex(1)>0) or (not onmarket and onmarket[1])) and lastcheck<>barindex thenlastcheck = barindexwasonmarket=1EndIfIf TradingTime then// Long EntryIf wasonmarket = 0 thenBuy noMMPositionSizeLong Contract at Dayhigh StopEndIf// Short entryIf wasonmarket = 0 thenSellShort noMMPositionSizeShort Contract at DayLow StopEndifEndIf// Close all positionIf Time = ClosePositionTime thenIf LongonMarket thenSell at MarketEndifIf ShortonMarket thenExitShort at MarketEndifEndif// Stop Loss and Target ProfitIf MaxStopLoss thenSet Stop pLOSS Min(MaxStopLossPoint,(YesterdayRange*SLostMultipeRate))ElseSet Stop pLOSS YesterdayRange*SLostMultipeRateEndIfSet Target pPROFIT YesterdayRange*TProfitMultipeRategraph wasonmarket1 user thanked author for this post.
10/25/2019 at 1:59 PM #11121610/25/2019 at 4:07 PM #11122510/26/2019 at 8:26 AM #111252 -
AuthorPosts
Find exclusive trading pro-tools on