Exit problem
Forums › ProRealTime English forum › ProOrder support › Exit problem
- This topic has 2 replies, 3 voices, and was last updated 4 years ago by robertogozzi.
-
-
05/15/2020 at 12:14 PM #131759
Good morning,
The program below, depending on the type of bar, enters short or long.
If you enter long, you must remain on the market until the first red bar, therefore when closing the latter, you must close the long position and immediately return to the market based on the type of bar just closed.
If you enter short, you must remain on the market until the first green bar, then when closing the latter, you must close the short position and immediately return to the market based on the type of bar just closed.
The problem is that the program closes and enters immediately if for example they are long and at the first red bar I have to close and enter short. If they are long, I have to close and re-enter long, close, but they do not immediately return to the market. Same goes for the short case.
how can this be solved?
I enclose the program123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106// v1: 04/04/2020//***************************************************************************************//DEFPARAM CumulateOrders = FalseDEFPARAM PreLoadBars = 10000////////////////////////////////////////////////////////////////////////////////////////ONCE Capitale = 4196ONCE LotNumber = 10ONCE MinLots = 1ONCE SpreadEntrata = 20 * pipsizeONCE StopMinimo = 40 * pipsizeONCE StopMassimo = 200 * pipsizeBarraVerde = Open < CloseBarraRossa = Open > CloseTradingDay = OpenDayOfWeek >= 1 AND OpenDayOfWeek <= 5 //trade only Mon. to Fri.//Definisco il tipo barraIF (close >= (high + low) / 2) THENTipoBarra = 1ELSIF (close < (high + low) /2) THENTipoBarra = 2ENDIFIF BarraVerde THENSpikeSuperiore = high - closeSpikeInferiore = open - lowELSIF BarraRossa THENSpikeSuperiore = high - openSpikeInferiore = close - lowENDIF//Il profitto è dato dal capitale + il ricavato dal programmaMyProfit = Capitale + StrategyProfit//Aumento della size al cambio del meseIF Month <> Month[1] THENLotNumber = max(MinLots, (MyProfit / Capitale))ENDIFIF NOT ONMARKET THEN //Inizio prima entrata a mercatoIF TipoBarra = 1 AND TradingDay THENSELLSHORT LotNumber CONTRACT AT MARKETTipoPosizione = -1IF SpikeSuperiore >= 220 THENStopEntrata = StopMassimo + SpreadEntrataSET STOP pLOSS StopEntrataELSEStopEntrata = SpikeSuperiore + SpreadEntrataSET STOP pLOSS max(StopMinimo,StopEntrata)ENDIFELSIF TipoBarra = 2 AND TradingDay THENBUY LotNumber CONTRACT AT MARKETTipoPosizione = 1IF SpikeInferiore >= 220 THENStopEntrata = StopMassimo + SpreadEntrataSET STOP pLOSS StopEntrataELSEStopEntrata = SpikeInferiore + SpreadEntrataSET STOP pLOSS max(Stopminimo,StopEntrata)ENDIFENDIFELSE // Inizio se sono già a mercatoIF TipoPosizione = 1 AND BarraRossa THEN //Se sono LONG e Barra Rossa chiudi posizioneSELL AT MARKETIF TipoBarra = 1 AND TradingDay THEN //Se la barra appena chiusa e tipo 1 entra SHORTSELLSHORT LotNumber CONTRACT AT MARKETIF SpikeSuperiore >= 220 THENStopEntrata = StopMassimo + SpreadEntrataSET STOP pLOSS StopEntrataELSEStopEntrata = SpikeSuperiore + SpreadEntrataSET STOP pLOSS max(StopMinimo,StopEntrata)ENDIFELSIF TipoBarra = 2 AND TradingDay THEN //Se la barra appena chiusa e tipo 2 entra LONGBUY LotNumber CONTRACT AT MARKETIF SpikeInferiore >= 220 THENStopEntrata = StopMassimo + SpreadEntrataSET STOP pLOSS StopEntrataELSEStopEntrata = SpikeInferiore + SpreadEntrataSET STOP pLOSS max(StopMinimo,StopEntrata)ENDIFENDIFELSIF TipoPosizione = -1 AND BarraVerde THEN //Se sono SHORT e Barra Verde chiudi posizioneEXITSHORT AT MARKETIF TipoBarra = 1 AND TradingDay THEN //Se la barra appena chiusa e tipo 1 entra SHORTSELLSHORT LotNumber CONTRACT AT MARKETIF SpikeSuperiore >= 220 THENStopEntrata = StopMassimo + SpreadEntrataSET STOP pLOSS StopEntrataELSEStopEntrata = SpikeSuperiore + SpreadEntrataSET STOP pLOSS max(StopMinimo,StopEntrata)ENDIFELSIF TipoBarra = 2 AND TradingDay THEN //Se la barra appena chiusa e tipo 2 entra LONGBUY LotNumber CONTRACT AT MARKETIF SpikeInferiore >= 220 THENStopEntrata = StopMassimo + SpreadEntrataSET STOP pLOSS StopEntrataELSEStopEntrata = SpikeInferiore + SpreadEntrataSET STOP pLOSS max(StopMinimo,StopEntrata)ENDIFENDIFENDIFENDIF05/15/2020 at 12:26 PM #131760BertonTomas – Please update your country flag in your profile.
There are some simple rules that everyone using the forums is expected to follow. Your post has broken one or more of these rules.
The forum rules are as follows. I have highlighted in bold the rule/rules that you have not followed:
Post your topic in the correct forum.
ProRealTime Platform Support only platform related issues.
ProOrder only strategy topics.
ProBuilder only indicator topics.
ProScreener only screener topics
General Discussion any other topics.
Welcome New Members for new forum members to introduce themselves.Only post in the language of the forum that you are posting in. For example English only in the English speaking forums and French only in the French speaking forums.
Always use the ‘Insert PRT Code’ button when putting code in your posts to make it easier for others to read.
Do not double post. Ask your question only once and only in one forum. All double posts will be deleted anyway so posting the same question multiple times will just be wasting your own time and will not get you an answer any quicker. Double posting just creates confusion in the forums.
Be careful when quoting others in your posts. Only use the quote option when you need to highlight a particular bit of text that you are referring to or to highlight that you are replying to a particular member if there are several involved in a conversation. Do not include large amounts of code in your quotes. Just highlight the text you want to quote and then click on ‘Quote’.
Give your topic a meaningful title. Describe your question or your subject in your title. Do not use meaningless titles such as ‘Coding Help Needed’.
Do not include personal information such as email addresses or telephone numbers in your posts. If you would like to contact another forum member directly outside of the forums then contact the forums administrator via ‘Contact Us’ and they will pass your details on to the member that you wish to contact.
Always be polite and courteous to others.
Have fun.I have edited your post where required. Please ensure that your future posts meet these few simple forum rules. 🙂
05/15/2020 at 1:45 PM #131772I already warned you:
- to post in the forum of the language you want to speak
- to use the correct support forum
- to use the button to insert code
- to update your flag
Now I need to also warn you to not double post!
I deleted your topic in the italian forum.
No matter what language you choose you seem not to be able to read the rules. Would you take a minute to point out the most difficult words so that we can improve the wording?
Thank you 🙂
-
AuthorPosts
Find exclusive trading pro-tools on