Help Double SL and Target with reversal exit
Forums › ProRealTime English forum › ProOrder support › Help Double SL and Target with reversal exit
- This topic has 7 replies, 3 voices, and was last updated 3 years ago by JC_Bywan.
-
-
01/06/2021 at 8:19 PM #156664
Hello everyone 🙂 ,
I come to you because I am lost and I spend almost the entire day trying to sort out this problem.
The problem comes from the tp/sl and reversal of the strategy.
I’d like that if the condition “l1” is ok that it buys at market with a sl that is this condition:
1If xHigh crosses under (OpenPrice-x) thenand that it gets a 10 tp. BUT then I’d like that if the results of this trade is negative that it immediatly opens a trade in the other way with the SL condition:
1If xLow crosses over(OpenPrice+x) thenand a TP of the amount of the losses of the previous trade.
If someone could help me it would be amazing…!
Thanks! 😀
Just to help you, here is the base of the code.. 😉
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136DEFPARAM CumulateOrders = falseDEFPARAM Preloadbars = 50000//HORAIRES DE TRADINGCtime = time >= 153000 and time < 220000//--------------------------------------//Nouveau OpenPrice et OpenDay a 15:30IF OPENTIME = (153000) thenOpenPrice = OpenOpenD = OpenDayENDIF//------------------------------------//Représentation graphique Heikin-Ashionce xOpen = openPrice = (open + close + low + high)/4if barindex > 0 thenxOpen = (xOpen + Price[1]) / 2endifxLow = min(low,min(Price,xOpen))xHigh = max(high,max(Price,xOpen))GreenHA = Price > xOpenRedHA = Price < xOpen//------------------------------------x=20 //Taille de la zone autour de l'ouverture pour activation/Désactivation//Remise à 0 des variablesIf OpenD<>OpenD[1] thenl = 0s = 0Endif// STRATEGIE ---------------------------------------------------------------------------------// Conditions ShortIf s=0 and l=0and ctime thenIf xHigh=xOpen and xHigh<(OpenPrice-x) thens1 = 1Elses1 = 0EndifEndif//Conditions LongIf l=0 and s=0 and ctime thenIf xLow=xOpen and xLow>(OpenPrice+x) thenl1 = 1Elsel1=0EndifEndif//-------------------------------------------------------------------------------------------//POSITION LONGUEIF l1 THENBuy 1 contract at marketl1 = 0l = 1a = 1ENDIFIF LONGONMARKET THENSET TARGET PROFIT (10)If xHigh crosses under (OpenPrice-x) thenSell at markets1 = 1endifENDIFIf SHORTONMARKET and s1 thenSellshort 1 contract at markets1=0Endif//POSITION LONGUE//IF l1 THEN//Buy 1 contract at market//l1 = 0//l = 1//posl1 = tradeindex//ENDIF////if Posl1>0 then//Set target pprofit 10//If xHigh crosses under (OpenPrice-x) then//sell at market//posl1 = 0//If positionperf(1)>0 then//graph positionperf(1)//Sellshort 1 contract at market//Posl2 = tradeindex//endif//Endif//Endif////If posl2>0 then//Exitshort at (OpenPrice+x) stop//Set target pprofit 30//Posl2 = 0//Endif////POSITION COURTE//IF s1 THEN//Sellshort 1 contract at market//s1 = 0//s = 1//poss1 = 1//ENDIF//////////if poss1>0 then//Set target pprofit 10//If xLow crosses over (OpenPrice+x) then//Exitshort at market//poss1 = 0//If positionperf(1)>0 then//Buy 1 contract at market//poss2 = tradeindex//Endif//Endif//Endif////If poss2>0 then//sell at (OpenPrice-x) stop//Set target pprofit 20//poss2 = 0//endif//01/06/2021 at 9:08 PM #15667001/06/2021 at 9:50 PM #156671@Robertogozzi, @Nicolas , If you come by do not hesitate if you find something… I would be very grateful…
01/07/2021 at 8:16 AM #15668901/07/2021 at 8:54 AM #156699Hello Nicolas, Happy new year andvery glad to see you here 😀 ,
Maybe I should told it differently:
I’d like the system to take long or short with this condition:
12345// Conditions ShortIf xHigh=xOpen and xHigh<(OpenPrice-x) then//Conditions LongIf xLow=xOpen and xLow>(OpenPrice+x) thenThis order would have a Take Profit of 10 and the Stop Loss would be :
12345//In the case of a LongIf xHigh crosses under (OpenPrice-x) then//In the case of a ShortIf xLow crosses over (OpenPrice+x) thenThen if the results of this first closed trade is negative that it immediatly opens a trade in the opposite direction (short if it was long / long if it was short) with the (same) SL condition:
12345//In the case of a LongIf xHigh crosses under (OpenPrice-x) then//In the case of a ShortIf xLow crosses over (OpenPrice+x) thenand a TP of the amount of the loss of the previous trade.
The idea of this code is to get a ruban of 20 points above and under the opening of the US market at 15:30 to 22:00. When a full heikin ashi with a “flat ass” exits of the band it should buy or sell (depend if it exits by the top or the bottom). If the trade get 10 points it closed the position and waits for the next day. However, if it had a losses (by exiting the band in the other side) it should immediatly take another trade in the opposite direction of the first one with a take profit equals to the loss of the previous trade.
With this program I should have only one trade (if it is positive) or two trades (if the first one is a loss ) a day
Hope it make more sense…
Thanks so much!
01/07/2021 at 5:19 PM #15679001/08/2021 at 9:08 AM #156858Well, so based on these conditions, open the new orders:
12345678//In the case of a LongIf xHigh crosses under (OpenPrice-x) thensellshort at marketendif//In the case of a ShortIf xLow crosses over (OpenPrice+x) thenbuy at marketendif01/18/2021 at 2:55 PM #158291 -
AuthorPosts
Find exclusive trading pro-tools on