premarket open price breakout strategy idea
Forums › ProRealTime English forum › ProOrder support › premarket open price breakout strategy idea
- This topic has 37 replies, 6 voices, and was last updated 5 years ago by aland.
-
-
04/10/2018 at 12:29 AM #67783
Thanks again Roberto and all For the last few days I wrote the basic test code but it is still not finished.
- I am still not sure how to cancel all positions and orders – is there a command (like QUIT but only for a single day) or do I need to manually SELL AT MARKET even when I didn’t buy yet
Pending orders expire when each bar closes, so you don’t need to do anything to cancel them, on the contrary you’ll have to place them again if you still want them to be pending for one more bar/candle.
There is no temporary QUIT, if you QUIT a strategy then you’ll have to restart it manually.
To close all open trades you’ll have to place a SELL order for Longs and EXITSHORT for Shorts.
No partial closing is allowed, when you exit a trade ALL contracts will be closed. - I am also not sure if all the code is run for each bar again and again (I am guessing the answer is yes)
Yes, you are right, it wouldn’t be automated trading otrherwise. - if the bar is a 3 minute bar does it wait till close to run the code is it not in “real time” tick for tick
Right again, as of this version of the platform, any strategy is run every time a candle/bar closes, just before the new one is opened. - if I want to look back and backtest the data from the last 12 month can I do it on a 3 min bar? it seems I have very limited access to the data on a 3 min bar
You can do it on any bar you want, but a 3-minute bar is a multiple of a 1-minute bar which, with 100k historic data, allows only a bit more than 3 months of backtesting.
Any help would be greatly appreciated Thanks Alan
1 user thanked author for this post.
05/02/2018 at 2:05 AM #69614Getting back to ProRealCode after a few weeks away…
Thanks for the answers. that makes more sense now.
I have a few quick questions:
- I see that adding or removing the “GRAPH” command causes the algorithm not to work or changes the results sometimes. any possible reason for that? is it a bug or am I missing something
- Does the location of the GRAPH command matter to the results? if I place a GRAPH X inside an IF statement would I get different results from outside the if statement for example
- Is StrategyProfit for each specific strategy? if I run 2 separate strategies will this parameter be changed? if I run manually trading and automatic trading will this parameter be altered
Thanks again,
A.
05/02/2018 at 9:34 AM #69616Getting back to ProRealCode after a few weeks away…
Thanks for the answers. that makes more sense now.
I have a few quick questions:
- I see that adding or removing the “GRAPH” command causes the algorithm not to work or changes the results sometimes. any possible reason for that? is it a bug or am I missing something
- Does the location of the GRAPH command matter to the results? if I place a GRAPH X inside an IF statement would I get different results from outside the if statement for example
- Is StrategyProfit for each specific strategy? if I run 2 separate strategies will this parameter be changed? if I run manually trading and automatic trading will this parameter be altered
Thanks again,
A.
1. I never experienced that, I assume it doesn’t affect strategies, it only may affect the VARIABLES window, if you exeperienced this issue you should post the whole code in order to replicate it.
2. Wherever you place GRAPH will never affect your strategies, but for sure the output on the screen will change if the code between the two GRAPH locations modifies the value of GRAPHed data. I just tried putting GRAPH in an IF statement and it ALWAYS displays the same value retained when the condition was last true.
3. STRATEGYPROFIT returns data relative to a single strategy; manual trades won’t affect automated strategies, unless you manually close/modify automated trades.
1 user thanked author for this post.
05/09/2018 at 11:23 AM #70062Thanks again.
Here is the skeleton of my code. I need a way to see were the program is at every stage (I am used to debugging and tools, system printouts, IDE etc…)
I created a state parameter and tried to set different values to it based on the position it is in, but the state stays 0 all the time.What am I doing wrong here? how can I quickly debug my code?
state is always 0 in this program1234567891011121314151617181920212223242526272829303132333435363738394041424344454647//removed all params just left the state and program skeleton to see why it is not changing the stateONCE State=0GRAPH StateEnableTrade=0LongTriggered=0ShortTriggered=0IF time = FirstHour THENState=1ENDIFIF ONMARKET THENState=2IF LONGONMARKET THENState=3ELSIF SHORTONMARKET THENState=4ENDIFENDIFIF NOT ONMARKET THENState=5IF EnableTrade=0 THENState=6ELSIF InitDailyProfit < StrategyProfit OR StopHour < time THENEnableTrade=0State=7ELSIF InitDailyProfit > StrategyProfit THENState=8if LongTriggered>0 AND ShortTriggered>0 THENEnableTrade=0State=9ELSIF LongTriggered>0 THENState=10ELSIF ShortTriggered>0 THENState=11ENDIFELSIF InitDailyProfit = StrategyProfit THENState=12ENDIFENDIF05/09/2018 at 12:10 PM #70065Line 21 can be replaced by ELSE and, if you do, line 23 must be commented out.
Apart from these details (not affecting the value of variable STATE), I can only recap all your conditions as follows
STATE values:
0 = initial
1 = when FirstHour is true, but will be immediately overridden by one of the following conditions (OnMarket or Not OnMarket)
2 = when OnMarket is true, but will be immediately overridden by the following two conditions (Long/ShortOnMarket)
3 = LongOnMarket
4 = ShortOnMarket
5 = Not OnMarket AND all of the following conditions (from ELSE through the last ENDIF) are FALSE
6 = Not OnMarket AND EnableTrade = 0
7 = Not OnMarket AND EnableTrade = 1 AND there was a Loss OR outside trading Hours
8 = Not OnMarket AND EnableTrade = 1 AND all the following conditions (from there through ENDIF before the last ELSIF) are false
9 = Not OnMarket AND EnableTrade = 1 AND both LongTriggered & ShortTriggered are TRUE
10 = Not OnMarket AND EnableTrade = 1 AND LongTriggered is TRUE
11 = Not OnMarket AND EnableTrade = 1 AND ShortTriggered is TRUE
12 = Not OnMarket AND EnableTrade = 1 AND no change in EquityThis is all I coud do without the full code, check if they are what you really wanted to happen within your strategy.1 user thanked author for this post.
05/09/2018 at 12:59 PM #70069Thanks Roberto for the quick reply.
Yes, the conditions are correct.
I managed to fix this problem by changing the time frame to 10 seconds instead of 1 min. That way it triggered correctly.
This causes another issue. I want to test the code on different dates and with 10 seconds I can only get today.
Changing the date frames (for example 5/3/18-6/3/18) in the date period on the right hand side of the proBackTest resulted in an error: “Please check your start and end date”
is there any way of backtesting with this short time frame?
BTW, I did see instances when adding a graph command removed the trading for that day and then removing it and re-adding it or changing it to “ONCE” made it work again…
could be a bug and I can PM the code if you like.05/09/2018 at 1:03 PM #7007105/09/2018 at 2:35 PM #70075ONCE is used to initialize a constant or a variable (PRT makes no difference between the two).
GRAPH is used to show the contents of constants/variables for debugging purposes only.
As for the time range when backtesting, there’s no limit; I used sometimes to shrink it to a couple of hours. That error message occurs once in a while, I usually close the running strategy and all backtest so far and open it again to restart and it always worked. On a worst case you could try to close PRT and restart it all over.
On a 10-second TF I have one week of data to backtest.
1 user thanked author for this post.
05/09/2018 at 5:39 PM #70094Thanks again,
I did restart the whole program but the message persists.
so my questions are:
- Is it possible to ask for a time frame in the past like 1.5.18 at 15:00 till 2.5.18 till 15:00 – and if so is there a support team to be contacted in case it does not work?
- I am shown only 1 day for 10sec frames. I can only choose 10,000 units so I was guessing that is the limit. are there any other options?
- How much money is “1 contract” considered? (I am used to manually typing the amount in PPT (pounds per point)
Thanks again
05/09/2018 at 6:17 PM #70101- It is possible to select the TFs you mentioned, in case you need assistance you may either type CTRL+M or click the help menu on the bar and select the assistance form (I don’t know the english name they assigned to that menu item);
- I have 100,000 units and I can backtest roughly one week, this is the limit for demo accounts (with my IG real account I have 200,000 units available);
- PRT (at least with IG accounts) makes 3 types of contracts available to trade DAX, normal (€ 250,000), mini (€ 50,000) and micro (€ 10,000) so that a single pip may have a value of € 25, 5 or 1; for major FX pairs they offer normal contracts (100,000 units of the involved currency) or mini contracts (10,000 units), so pips may have a value of 10 or 1 unit.
1 user thanked author for this post.
05/09/2018 at 10:29 PM #70113Thanks again, got it and will fill the help form.
Today I added another short script. It is very basic:
At the end of every daily bar exit all active positions and set new buy and sell orders with stoploss and limit
It works fine, but in the cases where for example the buy stoploss is activated and the sell should be triggered it reacts weird.
It shows me on the graph as if it created 2 orders but the profit is off and the equity curve gets hit as if the strategy lost thousands. that doesn’t make sense
I can’t debug it since I am using daily bars and can’t look into each sell/buy separately.Is the sell stoploss value maintained even after a buy was triggered and stopped? I am guessing that could be the problem
I think I can easily fix it with hourly bars but that seems like a complicated solution to a simple task which is why I want to verify I haven’t missed something here
1234567891011121314151617181920212223DEFPARAM CumulateOrders = falseONCE StopLoss=0ONCE StopLimit=10ONCE StakeSize=10ONCE EntryBuffer=0IF LONGONMARKET THENSELL AT MARKETELSIF SHORTONMARKET THENEXITSHORT AT MARKETENDIFMyBuyprice = High+EntryBufferMySellprice= Low-EntryBufferStopLoss = 100BUY StakeSize CONTRACTS AT MyBuyprice stopSELLSHORT StakeSize CONTRACTS AT MySellprice stopSET STOP LOSS StopLossSET TARGET PROFIT StopLimit05/10/2018 at 11:11 AM #70119Yes, that’s the issue. ProOrder takes control of operations when a bar closes to run a strategy, after that control is released to the broker, who is not aware of that strategy, so if there are two pendin orders sometimes they may be entered within the same bar, no matter what DEFPARAM CumulateOrders says.
This will change with the incoming MTF (Multi Time Frame) version, since your strategy will be able to setup any trade according to greater TFs but execute orders on a very low TF, even a second.
The main drawback is that you will need to launch the strategy from within the lower TF (say 1 second) so I’m afraid backtesting will be limited to a few days instead of years of data history available for the daily TF. This is a question I asked Nicolas this morning in another topic. I’m eager to know his answer!
1 user thanked author for this post.
05/10/2018 at 11:26 AM #70120Is it possible to ask for a time frame in the past like 1.5.18 at 15:00 till 2.5.18 till 15:00 – and if so is there a support team to be contacted in case it does not work?
I am shown only 1 day for 10sec frames. I can only choose 10,000 units so I was guessing that is the limit. are there any other options?
How much money is “1 contract” considered? (I am used to manually typing the amount in PPT (pounds per point)
See attached re 1 and 2.
Re 3 1 Contract is always £1 per point in UK with IG when spreadbetting.
2 users thanked author for this post.
05/11/2018 at 12:14 AM #70166Ok, Thanks
So until MTF comes out, how can I ask:
“give me the high (or low) of previous day” on a time frame of 3 min for example.
when I use :
high = highest[480](high)
it will not work on some days as there aren’t 480 bars per day I guess and it will definitely not work after a weekend – so I am getting results that differ from the actual high and low of the day
05/11/2018 at 12:17 AM #70167 - I am still not sure how to cancel all positions and orders – is there a command (like QUIT but only for a single day) or do I need to manually SELL AT MARKET even when I didn’t buy yet
-
AuthorPosts
Find exclusive trading pro-tools on