Help take position quickly!?
Forums › ProRealTime English forum › ProOrder support › Help take position quickly!?
- This topic has 12 replies, 4 voices, and was last updated 6 years ago by
Stefanb.
-
-
09/12/2019 at 9:00 AM #107316
Have a question about how to code so that position is taken faster than the next candle (if possible).
According to the ring in the chart.
The price breaks above the blue MA10.
Right there I want algo take position for buy.
If it takes position at the next candle it is too late as the course has increased 70 points since.
Is this possible?
09/12/2019 at 9:13 AM #107318Use a pending STOP order. You have to place it every bar you want it on the market as they only last one bar. x is whatever price (worse price than the current one) that you want it to be.
1Buy 1 contract at x stophttps://www.prorealcode.com/documentation/stop-pending/
09/12/2019 at 9:14 AM #107319Simple answer is both yes and no:
No its not possible, because you would need to anticipate that move. You need to buy before that big candle happens.
Yes it is possible, if you go down to a smaller timeframe and start trading it as its breaking out upwards.
Edit: Price breaks over the MA 10 line, but it dosnt actually break above it until the candle finishes, right?
You dont know if price will close above or below, until the candle finishes.
09/12/2019 at 9:16 AM #107320You need to use Multi Time Frame support and launch your strategy from a very short TF, say 1 minute or even less, to be able to detect such occurrences almost as soon as they happen.
The drawback is that your lowest TF becomes the default TF, the one on the chart, thus reducing the number of data history available for backtests.
09/12/2019 at 9:18 AM #10732109/12/2019 at 9:25 AM #107325123if not onmarket and close < average[10](close) thenbuy 1 contract at average[10] stopendifSomething like the above achieves what you are saying you want to do.
How can he know when there will be a crossover and at what price?
09/12/2019 at 9:37 AM #107327You and Jebus 89 are correct Roberto – I was forgetting that we do not know what the MA[10] level will be in the next candle when we place the pending order at the end of the current candle. MTF is the only way then by checking the time frame we want the MA[10] in using DEFAULT and then for the trade to be opened in a faster time frame such as 1 second. more coffee needed!
09/12/2019 at 9:47 AM #107329The code look like this.
Tick by tick.
Spread=1
Timeframe 15 min
I am just started with the code and run a WF just for fun..
Optimized only om 2019 data.
The result?
123456789101112131415161718192021// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivated// Conditions to enter long positionsindicator1 = Average[10](close)c1 = (close CROSSES OVER indicator1)IF c1 THENBUY 1 CONTRACT AT MARKETENDIF// Conditions to exit long positionsindicator2 = Average[d](close)c2 = (close CROSSES UNDER indicator2)IF c2 THENSELL AT MARKETENDIF// Stops and targetsSET STOP pLOSS a pTRAILING bSET TARGET pPROFIT c09/12/2019 at 9:50 AM #10733109/12/2019 at 9:58 AM #10733309/12/2019 at 9:58 AM #107334This is the MTF version, try launching it from a 1-minute or 10-second TF:
1234567891011121314151617181920212223// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivated//TIMEFRAME (15 minute, default)// Conditions to enter long positionsindicator1 = Average[10](close)c1 = (close CROSSES OVER indicator1)// Conditions to exit long positionsindicator2 = Average[d](close)c2 = (close CROSSES UNDER indicator2)//TIMEFRAME (default)IF c1 AND Not OnMarket THENBUY 1 CONTRACT AT MARKETENDIFIF c2 AND LongOnMarket THENSELL AT MARKETENDIF// Stops and targets// --- NOT ALLOWED ---> SET STOP pLOSS a pTRAILING b//uncomment one of the following lines//SET STOP pLOSS a//SET STOP pTRAILING b09/12/2019 at 10:08 AM #10733509/12/2019 at 10:14 AM #107337 -
AuthorPosts
Find exclusive trading pro-tools on