Hello,
How can I write a code for buying Heiken ashi candles when close green. Also the code to short when close red?
Or where can I find this info.
Thanks
Tony
Can someone tell me how to code to buy long when Heiken ashi close green only. I know how to set my sell code and indicators. I just dont know the code for buy using Heiken ashi.
Thanks
Tony
TRezin,
Kindly try first the search engine of this site. It is quite an efficient tool were you’ll find everthing you need..
A simple Heiken Ashi Trading Strategy
Thank you.
Hello Inertia,
Sorry but the code you provide dose not quite enter on the green and red. Could you help me again and adjust the code as follows:
Buy on close of Green Hieken Ashi candle
Sell when the Red Hieken Ashi candle closes below the 13EMA
I dont want a short position.
Thanks
Tony
Hi TRezin,
I just helped you out on how to search on this great forum.
Kindly note that I am not a coder but I have done the following according to your request.
To be verified 😉
xClose = (Open+High+Low+Close)/4
if(barindex>2) then
xOpen = (xOpen[1] + xClose[1])/2
endif
c1 = xClose>xOpen AND xClose[1]<xOpen[1]
if c1 AND Not LongOnMarket then
BUY 1 SHARE AT MARKET
endif
indicator1 = ExponentialAverage[13](close)
c2 = (close CROSSES UNDER indicator1)
IF c2 THEN
SELL AT MARKET
ENDIF
Hello,
Thanks for your help again.
I have added some codes to your system that are proven to show good back testing now.
I have attached for you.
Thanks
Tony
xClose = (Open+High+Low+Close)/4
if(barindex>2) then
xOpen = (xOpen[1] + xClose[1])/2
endif
c1 = xClose>xOpen AND xClose[1]<xOpen[1]
if c1 AND Not LongOnMarket then
BUY 1 SHARE AT MARKET
endif
indicator1 = ExponentialAverage[20](close)
c2 = (close CROSSES UNDER indicator1)
indicator2 = RSI[30](open)
c3 = (indicator2 >50)
indicator3 = CCI[65](open)
c4 = (indicator3 >75)
IF c2 and c3 and c4 THEN
SELL AT MARKET
ENDIF
// stops and targets
atr = averagetruerange[14](close)
set stop ploss atr*2.5
xClose = (Open+High+Low+Close)/4
if(barindex>2) then
xOpen = (xOpen[1] + xClose[1])/2
endif
c1 = xClose>xOpen AND xClose[1]<xOpen[1]
indicator2 = RSI[30](open)
c3 = (indicator2 >51)
indicator3 = CCI[65](open)
c4 = (indicator3 >10)
if c1 and c3 and c4 and Not LongOnMarket then
BUY 1 SHARE AT MARKET
endif
indicator1 = ExponentialAverage[20](close)
c2 = (close CROSSES UNDER indicator1)
IF c2 THEN
SELL AT MARKET
ENDIF
// stops and targets
atr = averagetruerange[25](close)
set stop ploss atr*2.5
Sorry thats it sorted.
Thanks
Good.
FYI: For the DAX I do not find any edge in any UT.
Inertia,
If you have time
One more thing. Do you know why this code is not shorting the market?
//conditions to enter long positions
c1 = Close<Open[5] and Close>Close[3]
indicator2 = RSI[30](close)
c3 = (indicator2 >50)
indicator3 = CCI[65](close)
c4 = (indicator3 >65)
indicator4 = exponentialaverage[20](close)
c5 = (close >indicator4)
if c1 and c3 and c4 and c5 and Not LongOnMarket then
BUY 1 SHARE AT MARKET
endif
// conditions to exit long positions
indicator1 = ExponentialAverage[50](close)
c2 = (close CROSSES UNDER indicator1)
IF c2 THEN
SELL AT MARKET
ENDIF
//conditions to enter short positions
c6 = Close>Open[5] and Close<Close[1]
indicator2 = RSI[30](close)
c7 = (indicator2 <50)
indicator3 = CCI[65](close)
c8 = (indicator3 <-10)
indicator4 = exponentialaverage[20](close)
c9 = (close >indicator4)
if c6 and c7 and c8 and c9 and Not shortOnMarket then
BUY 1 SHARE AT MARKET
endif
// conditions to exit long positions
indicator1 = ExponentialAverage[50](close)
c10 = (close CROSSES over indicator1)
IF c10 THEN
SELL AT MARKET
ENDIF
// stops and targets
atr = averagetruerange[14](close)
set stop ploss atr*2.5
Thanks
EricParticipant
Master
Inertia,
If you have time
One more thing. Do you know why this code is not shorting the market?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
//conditions to enter long positions
c1 = Close<Open[5] and Close>Close[3]
indicator2 = RSI[30](close)
c3 = (indicator2 >50)
indicator3 = CCI[65](close)
c4 = (indicator3 >65)
indicator4 = exponentialaverage[20](close)
c5 = (close >indicator4)
if c1 and c3 and c4 and c5 and Not LongOnMarket then
BUY 1 SHARE AT MARKET
endif
// conditions to exit long positions
indicator1 = ExponentialAverage[50](close)
c2 = (close CROSSES UNDER indicator1)
IF c2 THEN
SELL AT MARKET
ENDIF
//conditions to enter short positions
c6 = Close>Open[5] and Close<Close[1]
indicator2 = RSI[30](close)
c7 = (indicator2 <50)
indicator3 = CCI[65](close)
c8 = (indicator3 <–10)
indicator4 = exponentialaverage[20](close)
c9 = (close >indicator4)
if c6 and c7 and c8 and c9 and Not shortOnMarket then
BUY 1 SHARE AT MARKET
endif
// conditions to exit long positions
indicator1 = ExponentialAverage[50](close)
c10 = (close CROSSES over indicator1)
IF c10 THEN
SELL AT MARKET
ENDIF
// stops and targets
atr = averagetruerange[14](close)
set stop ploss atr*2.5
|
Thanks
https://www.prorealcode.com/topic/journey-prt/#post-68453
Do you know why this code is not shorting the market?
Because there is no SELLSHORT instruction in the code.
Hi Eric,
from #post69174,
line 34, sellshort instead of buy
and in that case, line 42 exitshort.
Thanks for the fix. Its working now.