spread indicator for strategy
Forums › ProRealTime English forum › ProBuilder support › spread indicator for strategy
- This topic has 18 replies, 2 voices, and was last updated 12 months ago by daskonzept.
Tagged: spread
-
-
10/16/2017 at 3:29 AM #49454
Hi!
You can set the spread in PRT.
But I wonder. First create an static indicator based on information of the spread for different trading hours from IG website for i.e. the dax.
Then use the call function to get the information and code the spread in the strategy manually and have a more accurate backtest when trading 24h.
Is it worth it or is it not possible to code ?
I tried to get an indicator running for a visual impression.
What’s wrong with this code. Between 22u and 8u shows 0, which should be 5. Other spreads are displayed correct.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849//spread settings dax// Start Trading WindowONCE stw1 = 090000ONCE stw2 = 173000ONCE stw3 = 220000ONCE stw4 = 080000// End Trading WindowONCE etw1 = 173000ONCE etw2 = 220000ONCE etw3 = 080000ONCE etw4 = 090000// Trading Window specifiedtw11 = time >= stw1tw12 = time < etw1tw21 = time >= stw2tw22 = time < etw2tw31 = time >= stw3tw32 = time < etw3tw41 = time >= stw4tw42 = time < etw4// trade window groupedtw1 = tw11 and tw12tw2 = tw21 and tw22tw3 = tw31 and tw32tw4 = tw41 and tw42other = not tw1 and not tw2 and not tw3 and not tw4// trade window setupif other thenspread=0elsif tw1 thenspread=1elsif tw2 thenspread=2elsif tw3 thenspread=5elsif tw4 thenspread=2endifreturn spread coloured(255,69,0) style(line,2) as "spread"1 user thanked author for this post.
10/16/2017 at 7:48 AM #49476Hi, your tw3 can never be true, because a number can’t be at the same time above 220000 and below 080000, so you need to approach differently the coding of night hours (something like “between 22h and 24h” or “between 0h and 8h”).
Also, please use the <> button (insert PRT code) in the message editor toolbar in order to make PRT code appear in the appropriate format, thanks.
10/16/2017 at 11:55 AM #49542After writing it down, I realised the same as you said. I modified it, it works but the coding doesn’t look good.
static spread indicator1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162//spread settings dax// Start Trading WindowONCE stw1 = 090000ONCE stw2 = 173000ONCE stw3 = 220000ONCE stw31= 000000ONCE stw4 = 080000// End Trading WindowONCE etw1 = 173000ONCE etw2 = 220000ONCE etw31 =235900ONCE etw3 = 080000ONCE etw4 = 090000// Trading Window specifiedtw11 = time >= stw1tw12 = time < etw1tw21 = time >= stw2tw22 = time < etw2tw31 = time >= stw3tw32 = time <= etw31tw33 = time >= stw31tw34 = time < etw3tw41 = time >= stw4tw42 = time < etw4// trade window groupedtw1 = tw11 and tw12tw2 = tw21 and tw22tw3 = tw31 and tw32tw3a = tw33 and tw34tw4 = tw41 and tw42other = not tw1 and not tw2 and not tw3 and not tw3a and not tw4// trade window setupif other thenspread=0elsif tw1 thenspread=1elsif tw2 thenspread=2elsif tw3 thenspread=5elsif tw3a thenspread=5elsif tw4 thenspread=2endifreturn spread coloured(255,69,0) style(line,2) as "spread"10/16/2017 at 12:05 PM #4954310/16/2017 at 12:25 PM #49550cleaned up code
1234567891011121314151617181920212223242526272829303132333435363738394041424344// spread settings dax// start/end trading windowONCE stw1 = 090000ONCE etw1 = 173000ONCE stw2 = 173000ONCE etw2 = 220000ONCE stw3 = 220000ONCE etw3c= 235959 //currentdayONCE stw3n= 000000 //nextdayONCE etw3 = 080000ONCE stw4 = 080000ONCE etw4 = 090000// trade window groupedtw1 = time >=stw1 and time < etw1tw2 = time >=stw2 and time < etw2tw3c= time >=stw3 and time <=etw3ctw3n= time >=stw3n and time < etw3tw4 = time >=stw4 and time < etw4// other trading timesott = not tw1 and not tw2 and not tw3c and not tw3n and not tw4// trade window setupif ott thenspread=0elsif tw1 thenspread=1elsif tw2 thenspread=2elsif tw3c thenspread=5elsif tw3n thenspread=5elsif tw4 thenspread=2endifreturn spread coloured(255,69,0) style(line,2) as "spread"10/17/2017 at 7:34 PM #4972903/02/2018 at 11:17 PM #64248Hi, is there any way to measure the actual spread using a prorealcode program? for example, leave it running over 1 week, and then plot a graph (or store data) to record spread at different times of day and different days? thanks
03/05/2018 at 2:09 PM #6444307/15/2018 at 3:02 AM #76025Bonjour, je profite de ce fil pour poser ma question :
En effet, après avoir rentré mon code pour le backtest, je souhaiterai l’appliquer en auto avec proorder auto trading (jusque là ça va de soit). le problème c’est que j’ai le message suivant :
“Les changements suivants doivent etre appliquées avant d’envoyer le code à proorder : Remplacer les variables par des valeurs fixes : pour préparer ce système pour le trading automatique, retirer les variables qui sont dans l’onglet “probacktest” et remplacez les par des valeurs fixes dans votre code.”
Je pense qu’il s’agit du capital et du spread (je n’ai que ça)…? Et si oui , quel code dois je inclure pour remplacer justement ces valeurs fixe du probacktest? Quelqu’un peut il m’aider?
07/15/2018 at 8:06 AM #76028vins – Welcome to the forums. There are some simple rules that you will need to follow. Please only use English in the English speaking forums. There is a French speaking forum if you wish to use that language. Also please update your country flag.
vins – Bienvenue sur les forums. Il y a quelques règles simples que vous devrez suivre. Veuillez n’utiliser que l’anglais dans les forums anglophones. Il y a un forum francophone si vous souhaitez utiliser cette langue. Veuillez également mettre à jour le drapeau de votre pays.
07/15/2018 at 8:14 AM #7602907/15/2018 at 12:37 PM #76041oh sorry vonasi, i didn’t know and i understand. 🙂
Ok, just my question is : What is the code for to put the capital and the propagation in my probacktest code (my strategy)..? By example i want to put 10000€ (capital) and 1 for the propagation.
07/15/2018 at 2:32 PM #76047Unless you are using some form of money management within your code it is not necessary to have the capital in the code – just put the starting capital in the box shown in this image:
I’m not certain what you mean by propagation. If you mean position size then you can just do the following. Some instruments/brokers might need you to use PIPSIZE to get the correct size.
123456789buy 1 contract at marketsell 1 contract at market//orpositionsize = 1buy positionsize contracts at marketsell positionsize contracts at market//orbuy 1 * pipsize contracts at marketsell 1 * pipsize contracts at market06/05/2020 at 11:16 PM #134808Hi All,
This spread issue is a problem. In PRT, there should be a way to display bid/ask price on the chart. From there it should be possible to build some code to get instantaneous values by calling these price indicators. Since these prices (bid/ask/middle) can be displayed on the chart, they can become an indicator. No?
For example, a MACD can be calculated on bid/ask/middle price. This can change a bit the result of the indicator, at some point in the day. (due to trading hours, volumes, liquidity, etc…).
So to begin with:
- Does anyone know how to configure the price line on the charts ? (bid/ask/middle). I just can’t find this setup.
- Did anyone already build a spread indicator? (to detect real live spread widening, not pre-coded static theoretical ones for back testing purpose)
Thank you.
Best
06/06/2020 at 12:17 PM #134852there should be a way to display bid/ask price on the chart
You can use the Bid/Ask Line Indicator … I have it on all the time.
Just put Bid in the Indicator search on PRT and you will see it.
If you use it on forex on low TF’s (1 min etc) you can see the Bid/Ask band flash widen very often. not so much on Indices, but it does happen out of market hours.
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on