TAKE PROFIT when 2 EMA crosses
Forums › ProRealTime English forum › ProOrder support › TAKE PROFIT when 2 EMA crosses
- This topic has 8 replies, 4 voices, and was last updated 2 years ago by pmattez.
-
-
11/26/2021 at 7:23 PM #182355
Hi everyone, I’m new with coding and I would appreciate your support.
I have defined a rule to buy/sell based on some conditions:
IF NOT LongOnMarket and plage and condition1 THEN
BUY 1 CONTRACTS AT MARKETENDIF
I would like to add that Take Profit will be done as soon as 2 EMAs are crossing under
AND
I would like to define the Stop Loss at the most recent Lowest price
Could you help ?
Thanks a lot,
Patrice.
11/26/2021 at 7:50 PM #182363For the SL, the most recent low is that of the current bar, when the strategy places the opening order of an operation:
1Set Stop Loss abs(close - low)TP can be detected at this bearish crossover:
123IF average[10,0](close) CROSSES UNDER average[100,0](close) THENSELL AT MARKETENDIF11/26/2021 at 9:25 PM #182367Thanks. I have tried the following but it is not behaving at all as expected.
Instead of Average I would like as well to work with exponential average.
Here is the code I used which is not working correctly:
// Conditions pour ouvrir une position acheteuse
IF NOT LongOnMarket and condition THEN
BUY 1 CONTRACTS AT MARKET
IF average[8](close) CROSSES UNDER average[20](close) THEN
SELL AT MARKET
ENDIF
ENDIF// Conditions pour ouvrir une position en vente à découvert
IF NOT ShortOnMarket and condition THEN
SELL 1 CONTRACTS AT MARKET
IF average[8](close) CROSSES OVER average[20](close) THEN
BUY AT MARKET
ENDIF
ENDIFThanks a lot for your help
11/26/2021 at 10:18 PM #1823681IF average[8,1](close) CROSSES UNDER average[20,1](close) THENthis will give you EMA
11/26/2021 at 10:23 PM #18236911/27/2021 at 12:38 AM #18237112/01/2021 at 5:37 PM #182636Hi
I have still an issue with my code. The code enter the market according to the condition defined. no problem.
Stop loss is ok but Target profit is not taken based on the condition. Could you help ? Many thanks
indicateur2= ExponentialAverage[20](close)
indicateur5= ExponentialAverage[8](close)
c9short= (indicateur5 < indicateur2)
// Conditions pour ouvrir une position acheteuse
IF NOT LongOnMarket and plage and c1long and c1longbis and c1longtiers and c4long and c8long and c9long and c10long THEN
BUY 1 CONTRACTS AT MARKET
SET STOP LOSS 20
IF c9short THEN
SELL 1 CONTRACTS AT MARKET
ENDIF
ENDIFThanks again
12/01/2021 at 5:51 PM #182640Move the last ENDIF to immediately BEFORE IF c9short THEN.
12/01/2021 at 7:13 PM #182642 -
AuthorPosts
Find exclusive trading pro-tools on