Explanation about breakout strategy parameters
Forums › ProRealTime English forum › ProOrder support › Explanation about breakout strategy parameters
- This topic has 4 replies, 2 voices, and was last updated 8 years ago by Yngve.
Viewing 5 posts - 1 through 5 (of 5 total)
-
-
11/24/2016 at 12:13 PM #1707711/24/2016 at 4:34 PM #1711711/24/2016 at 6:49 PM #17126
Hi Wing
Thanks for replying to my question!
Well for instant this code
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107<span class="token comment" spellcheck="true">// We do not store datas until the system starts.</span><span class="token comment" spellcheck="true">// If it is the first day that the system is launched and if it is afternoon,</span><span class="token comment" spellcheck="true">// it will be waiting until the next day for defining sell and buy orders </span><span class="token keyword">DEFPARAM</span> <span class="token keyword">PreLoadBars</span> <span class="token operator">=</span> <span class="token number">0</span><span class="token comment" spellcheck="true">// Position is closed at 7h45 PM, frenh time (in case of CAC40 trading)</span><span class="token keyword">DEFPARAM</span> <span class="token keyword">FlatAfter</span> <span class="token operator">=</span> <span class="token number">194500</span><span class="token comment" spellcheck="true">// No new position will be initiated after the 5h00 PM candlestick</span>LimitHour <span class="token operator">=</span> <span class="token number">171500</span><span class="token comment" spellcheck="true">// Market scan begin with the 15 minute candlestick that closed at 9h15 AM</span>StartHour <span class="token operator">=</span> <span class="token number">091500</span><span class="token comment" spellcheck="true">// The 24th and 31th days of December will not be traded because market close before 7h45 PM</span><span class="token keyword">IF</span> <span class="token punctuation">(</span><span class="token keyword">Month</span> <span class="token operator">=</span> <span class="token number">5</span> <span class="token keyword">AND</span> <span class="token keyword">Day</span> <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">)</span> <span class="token keyword">OR</span> <span class="token punctuation">(</span><span class="token keyword">Month</span> <span class="token operator">=</span> <span class="token number">12</span> <span class="token keyword">AND</span> <span class="token punctuation">(</span><span class="token keyword">Day</span> <span class="token operator">=</span> <span class="token number">24</span> <span class="token keyword">OR</span> <span class="token keyword">Day</span> <span class="token operator">=</span> <span class="token number">25</span> <span class="token keyword">OR</span> <span class="token keyword">Day</span> <span class="token operator">=</span> <span class="token number">26</span> <span class="token keyword">OR</span> <span class="token keyword">Day</span> <span class="token operator">=</span> <span class="token number">30</span> <span class="token keyword">OR</span> <span class="token keyword">Day</span> <span class="token operator">=</span> <span class="token number">31</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token keyword">THEN</span>TradingDay <span class="token operator">=</span> <span class="token number">0</span><span class="token keyword">ELSE</span>TradingDay <span class="token operator">=</span> <span class="token number">1</span><span class="token keyword">ENDIF</span><span class="token comment" spellcheck="true">// Variables that would be adapted to your preferences</span><span class="token keyword">if</span> <span class="token keyword">time</span> <span class="token operator">=</span> <span class="token number">084500</span> <span class="token keyword">then</span>PositionSize <span class="token operator">=</span> <span class="token keyword">max</span><span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token number">2</span><span class="token operator">+</span><span class="token keyword">ROUND</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token keyword">strategyprofit</span><span class="token operator">-</span><span class="token number">1000</span><span class="token punctuation">)</span><span class="token operator">/</span><span class="token number">1000</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token comment" spellcheck="true">//gain re-invest trade volume</span><span class="token comment" spellcheck="true">//PositionSize = 2 //constant trade volume over the time</span><span class="token keyword">endif</span>MaxAmplitude <span class="token operator">=</span> <span class="token number">58</span>MinAmplitude <span class="token operator">=</span> <span class="token number">11</span>OrderDistance <span class="token operator">=</span> <span class="token number">4</span>PourcentageMin <span class="token operator">=</span> <span class="token number">30</span><span class="token comment" spellcheck="true">// Variable initilization once at system start</span><span class="token keyword">ONCE</span> StartTradingDay <span class="token operator">=</span> <span class="token operator">-</span><span class="token number">1</span><span class="token comment" spellcheck="true">// Variables that can change in intraday are initiliazed</span><span class="token comment" spellcheck="true">// at first bar on each new day</span><span class="token keyword">IF</span> <span class="token punctuation">(</span><span class="token keyword">Time</span> <span class="token operator"><=</span> StartHour <span class="token keyword">AND</span> StartTradingDay <span class="token operator"><</span><span class="token operator">></span> <span class="token number">0</span><span class="token punctuation">)</span> <span class="token keyword">OR</span> IntradayBarIndex <span class="token operator">=</span> <span class="token number">0</span> <span class="token keyword">THEN</span>BuyTreshold <span class="token operator">=</span> <span class="token number">0</span>SellTreshold <span class="token operator">=</span> <span class="token number">0</span>BuyPosition <span class="token operator">=</span> <span class="token number">0</span>SellPosition <span class="token operator">=</span> <span class="token number">0</span>StartTradingDay <span class="token operator">=</span> <span class="token number">0</span><span class="token keyword">ELSIF</span> <span class="token keyword">Time</span> <span class="token operator">>=</span> StartHour <span class="token keyword">AND</span> StartTradingDay <span class="token operator">=</span> <span class="token number">0</span> <span class="token keyword">AND</span> TradingDay <span class="token operator">=</span> <span class="token number">1</span> <span class="token keyword">THEN</span><span class="token comment" spellcheck="true">// We store the first trading day bar index </span>DayStartIndex <span class="token operator">=</span> IntradayBarIndexStartTradingDay <span class="token operator">=</span> <span class="token number">1</span><span class="token keyword">ELSIF</span> StartTradingDay <span class="token operator">=</span> <span class="token number">1</span> <span class="token keyword">AND</span> <span class="token keyword">Time</span> <span class="token operator"><=</span> LimitHour <span class="token keyword">THEN</span><span class="token comment" spellcheck="true">// For each trading day, we define each 15 minutes</span><span class="token comment" spellcheck="true">// the higher and lower price value of the instrument since StartHour</span><span class="token comment" spellcheck="true">// until the buy and sell tresholds are not defined</span><span class="token keyword">IF</span> BuyTreshold <span class="token operator">=</span> <span class="token number">0</span> <span class="token keyword">OR</span> SellTreshold <span class="token operator">=</span> <span class="token number">0</span> <span class="token keyword">THEN</span>HighLevel <span class="token operator">=</span> <span class="token indicators">Highest</span><span class="token punctuation">[</span>IntradayBarIndex <span class="token operator">-</span> DayStartIndex <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">(</span><span class="token keyword">High</span><span class="token punctuation">)</span>LowLevel <span class="token operator">=</span> <span class="token indicators">Lowest</span> <span class="token punctuation">[</span>IntradayBarIndex <span class="token operator">-</span> DayStartIndex <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">(</span><span class="token keyword">Low</span><span class="token punctuation">)</span><span class="token comment" spellcheck="true">// Spread calculation between the higher and the </span><span class="token comment" spellcheck="true">// lower value of the instrument since StartHour</span>DaySpread <span class="token operator">=</span> HighLevel <span class="token operator">-</span> LowLevel<span class="token comment" spellcheck="true">// Minimal spread calculation allowed to consider a significant price breakout</span><span class="token comment" spellcheck="true">// of the higher and lower value </span>MinSpread <span class="token operator">=</span> DaySpread <span class="token operator">*</span> PourcentageMin <span class="token operator">/</span> <span class="token number">100</span><span class="token comment" spellcheck="true">// Buy and sell tresholds for the actual if conditions are met</span><span class="token keyword">IF</span> DaySpread <span class="token operator"><=</span> MaxAmplitude <span class="token keyword">THEN</span><span class="token keyword">IF</span> SellTreshold <span class="token operator">=</span> <span class="token number">0</span> <span class="token keyword">AND</span> <span class="token punctuation">(</span><span class="token keyword">Close</span> <span class="token operator">-</span> LowLevel<span class="token punctuation">)</span> <span class="token operator">>=</span> MinSpread <span class="token keyword">THEN</span>SellTreshold <span class="token operator">=</span> LowLevel <span class="token operator">+</span> OrderDistance<span class="token keyword">ENDIF</span><span class="token keyword">IF</span> BuyTreshold <span class="token operator">=</span> <span class="token number">0</span> <span class="token keyword">AND</span> <span class="token punctuation">(</span>HighLevel <span class="token operator">-</span> <span class="token keyword">Close</span><span class="token punctuation">)</span> <span class="token operator">>=</span> MinSpread <span class="token keyword">THEN</span>BuyTreshold <span class="token operator">=</span> HighLevel <span class="token operator">-</span> OrderDistance<span class="token keyword">ENDIF</span><span class="token keyword">ENDIF</span><span class="token keyword">ENDIF</span><span class="token comment" spellcheck="true">// Creation of the buy and sell orders for the day</span><span class="token comment" spellcheck="true">// if the conditions are met </span><span class="token keyword">IF</span> SellTreshold <span class="token operator">></span> <span class="token number">0</span> <span class="token keyword">AND</span> BuyTreshold <span class="token operator">></span> <span class="token number">0</span> <span class="token keyword">AND</span> <span class="token punctuation">(</span>BuyTreshold <span class="token operator">-</span> SellTreshold<span class="token punctuation">)</span> <span class="token operator">>=</span> MinAmplitude <span class="token keyword">THEN</span><span class="token keyword">IF</span> BuyPosition <span class="token operator">=</span> <span class="token number">0</span> <span class="token keyword">THEN</span><span class="token keyword">IF</span> <span class="token keyword">LongOnMarket</span> <span class="token keyword">THEN</span>BuyPosition <span class="token operator">=</span> <span class="token number">1</span><span class="token keyword">ELSE</span><span class="token keyword">BUY</span> PositionSize <span class="token keyword">CONTRACT</span> <span class="token keyword">AT</span> BuyTreshold <span class="token keyword">STOP</span><span class="token keyword">ENDIF</span><span class="token keyword">ENDIF</span><span class="token keyword">IF</span> SellPosition <span class="token operator">=</span> <span class="token number">0</span> <span class="token keyword">THEN</span><span class="token keyword">IF</span> <span class="token keyword">ShortOnMarket</span> <span class="token keyword">THEN</span>SellPosition <span class="token operator">=</span> <span class="token number">1</span><span class="token keyword">ELSE</span><span class="token keyword">SELLSHORT</span> PositionSize <span class="token keyword">CONTRACT</span> <span class="token keyword">AT</span> SellTreshold <span class="token keyword">STOP</span><span class="token keyword">ENDIF</span><span class="token keyword">ENDIF</span><span class="token keyword">ENDIF</span><span class="token keyword">ENDIF</span><span class="token comment" spellcheck="true">// Conditions definitions to exit market when a buy or sell order is already launched</span><span class="token keyword">IF</span> <span class="token keyword">LongOnMarket</span> <span class="token keyword">AND</span> <span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token keyword">Time</span> <span class="token operator"><=</span> LimitHour <span class="token keyword">AND</span> SellPosition <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">)</span> <span class="token keyword">OR</span> <span class="token keyword">Time</span> <span class="token operator">></span> LimitHour<span class="token punctuation">)</span> <span class="token keyword">THEN</span><span class="token keyword">SELL</span> <span class="token keyword">AT</span> SellTreshold <span class="token keyword">STOP</span><span class="token keyword">ELSIF</span> <span class="token keyword">ShortOnMarket</span> <span class="token keyword">AND</span> <span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token keyword">Time</span> <span class="token operator"><=</span> LimitHour <span class="token keyword">AND</span> BuyPosition <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">)</span> <span class="token keyword">OR</span> <span class="token keyword">Time</span> <span class="token operator">></span> LimitHour<span class="token punctuation">)</span> <span class="token keyword">THEN</span><span class="token keyword">EXITSHORT</span> <span class="token keyword">AT</span> BuyTreshold <span class="token keyword">STOP</span><span class="token keyword">ENDIF</span><span class="token comment" spellcheck="true">// Maximal risk definition of loss per position </span><span class="token comment" spellcheck="true">// in case of bad evolution of the instrument price</span><span class="token keyword">SET STOP</span> <span class="token keyword">PLOSS</span> MaxAmplitude11/24/2016 at 11:54 PM #17148Something like this, for that strategy:
MaxAmplitude = maximum stop loss/maximum daily range to trade
MinAmplitude = minimum daily range to trade
OrderDistance = Distance from range that order is placed when breakout has occured
PourcentageMin = How large of a movement is considered an outbreak, measured in percent of today’s range so far (high-low).
1 user thanked author for this post.
11/26/2016 at 12:03 PM #17224 -
AuthorPosts
Viewing 5 posts - 1 through 5 (of 5 total)
Find exclusive trading pro-tools on
Similar topics: