help for a newby Time specific actions
Forums › ProRealTime English forum › ProRealTime platform support › help for a newby Time specific actions
- This topic has 8 replies, 3 voices, and was last updated 7 years ago by Bob Harris.
-
-
07/24/2017 at 2:17 PM #41507
Hi,
I have written a script that is intended to run once a day at a specific time,
//Testing if it’s time to wake up !
IF (CurrentTime = 120101)AND not DaysForbiddenEntry THEN
///get entry for current candle – variable B
B = (Open[0])//// get entry possition for previou candle – variable A
A = (Open[1])When I try to backtest no positions are opened, is this because you cant backtest a specific time, or is there a fault else-ware in the code?
thanks
07/24/2017 at 3:12 PM #41512Hi,
Can’t say why a backtest doesn’ take positions without seeing the full code with instructions “buy” or “sellshort”, but assuming the rest of this unseen backtest is based on presented time condition only, in case it helps, a common beginner confusion about time in PRT is to assume “time” should return the same value as your watch. But “Time” in PRT is not pure current time, it is the closing time of a candle. For example, when you’re looking at an instrument in a 1h timeframe, a 1h candle starting at 14h would see its “time” value be 15h regardless of when between 14h and 15h you look at it (well, 150000 rather, because of format, but you get the idea).
Consequently, any test of a candle “time” being compared to 120101 would work only for timeframes in x seconds having candles in its history finishing at 12h01mn01s exactly, but wouldn’t work with any “x minutes” or “x hour” timeframes which couldn’t possibly finish at 12h01mn01s.
(further details on temporal constants p.8-9 https://www.prorealtime.com/en/pdf/probuilder.pdf
>> Please update your country flag by choosing a location in your profile settings. Thank you 🙂 <<
07/24/2017 at 4:14 PM #41520Noobywan is right, to do what you want you should use a 1-sec Timeframe or wait for the multitimeframe feature that is rumoured to be released by the end of this year.
07/25/2017 at 4:49 PM #41596Thank you for your help, you really helped, But as always one solution highlights the next issue
when i place a trade, is there any way I can stop a subsequent trade being place for a set period of time, I’m using
DEFRARM CumulateOrders = False
to stop orders in the same direction from being placed, but if the market moves against me it tries to place an order in the opposite direction and effectively closes the position.
any pointers gratefully received
Thanks
07/25/2017 at 8:06 PM #416051DEFPARAM CumulateOrders = ....is only evaluated when the strategy is launched and cannot be modified at runtime.
To achieve your goal you have to use
1timeto allow trading or not, as follows:
123456789101112DEFPARAM CumulateOrders = FALSE...IF time >= 100000 AND time <= 160000 thenIF (long conditions) THENBUY 1 CONTRACT AT MARKETENDIFIF (short conditions) THENSELLSHORT 1 CONTRACT AT MARKETENDIFENDIFIf that is what you mean.
07/26/2017 at 10:01 AM #41634Thank you for that. I have solved the opening in a time window issue but it has highlighted a second issue
But I don’t think I expressed my problem very well
For an example,
The conditions are set up to go long and it opens a position.
I want that position to stay open until either the stop-loss is hit or profit is triggered (hopefully the profit).
As it stand currently if, while the position is open, the conditions to ‘go short’ are met it trues to open a short position and effectively closes my trade early.
is there any way that, while any position is open it cant place any further trades until the current position closes by hitting the profit target or the stop loss.
Thanks
07/26/2017 at 1:07 PM #41666“onmarket” should be the useful keyword to avoid “take and reverse” when you want the existing trade to go all the way not stopped prematurely by opposite entry conditions being met (p.17 https://www.prorealtime.com/en/pdf/probacktest.pdf )
Would use it by adding the condition “if not onmarket” to your existing entry conditions, so that it considers a new entry only if onmarket=0, then it shouldn’t open any opposite direction trade while there’s one still ongoing
12345if not onmarket and [add here your long order entry conditions] thenbuy etc...if not onmarket and [add here your short order entry conditions] thensellshort etc...07/26/2017 at 1:40 PM #41676Sorry for not being able to insert code because I’m over my phone till friday.
DEFPARAM FlatAfter=hhmmss should not be used in your case, ’cause it closes any open trade at that specific time.
DEFPARAM CumulateOrders=True should not be used ’cause it allows more than one trade open at the same time.
So the solution is to ban more than one trade and let it run till a SL or TP is hit.
In case some conditions, the other way round, arise you may test LONGONMARKET to close any long trade open and then start a new SHORT trade. Test SHORTONMARKET, instrad, to close short trades and then go Long.
Roberto
07/27/2017 at 9:00 AM #41767Brilliant, Thanks for that, the script works perfectly in back testing
Now to see if it work’s in the real world
Thank you to all who helped
-
AuthorPosts
Find exclusive trading pro-tools on