cristian.d

Camarilla Strategy - breakouts of H4 and L4

Breakout strategy of H4 and L4 levels. Manual entries and exits - higher profits BUT because I am a novice in pinescript,
Can someone please:

1. Show me how to add exit strategy lines : close> ema (close,3) for exit short and opposite for long. I added myself but I can't make it to work in relation to camarilla entries; instead it shows all ema crossings..
2.Why some entries over/above my pivots are not shown.. Example:11.15 AM (short) and 13.10 PM (long) AAPL , October 15, today? Today would've been 3 signals, not one..

Thank you in advance for any advice. I am a strong Camarilla follower, but I am not a coder.
Open-source Skript

Ganz im Sinne von TradingView hat der Autor dieses Skripts es als Open-Source veröffentlicht, damit Trader es verstehen und überprüfen können. Ein Hoch auf den Autor! Sie können es kostenlos verwenden, aber die Wiederverwendung dieses Codes in einer Publikation unterliegt den Hausregeln. Sie können das Skript den Favoriten hinzufügen, um es auf dem Chart zu verwenden.

Möchten Sie dieses Skript auf einem Chart verwenden?
//@version=2
//Created by CristianD
strategy(title="CamarillaStrategy", shorttitle="CD_Camarilla_Strategy", overlay=true) 
//sd = input(true, title="Show Daily Pivots?")
EMA = ema(close,3)

//Camarilla
pivot = (high + low + close ) / 3.0 
range = high - low
h5 = (high/low) * close 
h4 = close + (high - low) * 1.1 / 2.0
h3 = close + (high - low) * 1.1 / 4.0
h2 = close + (high - low) * 1.1 / 6.0
h1 = close + (high - low) * 1.1 / 12.0
l1 = close - (high - low) * 1.1 / 12.0
l2 = close - (high - low) * 1.1 / 6.0
l3 = close - (high - low) * 1.1 / 4.0
l4 = close - (high - low) * 1.1 / 2.0
h6 = h5 + 1.168 * (h5 - h4) 
l5 = close - (h5 - close)
l6 = close - (h6 - close)

// Daily line breaks
//sopen = security(tickerid, "D", open [1])
//shigh = security(tickerid, "D", high [1])
//slow = security(tickerid, "D", low [1])
//sclose = security(tickerid, "D", close [1])
//
// Color
//dcolor=sopen != sopen[1] ? na : black
//dcolor1=sopen != sopen[1] ? na : red
//dcolor2=sopen != sopen[1] ? na : green

//Daily Pivots 
dtime_pivot = security(tickerid, 'D', pivot[1]) 
dtime_h6 = security(tickerid, 'D', h6[1]) 
dtime_h5 = security(tickerid, 'D', h5[1]) 
dtime_h4 = security(tickerid, 'D', h4[1]) 
dtime_h3 = security(tickerid, 'D', h3[1]) 
dtime_h2 = security(tickerid, 'D', h2[1]) 
dtime_h1 = security(tickerid, 'D', h1[1]) 
dtime_l1 = security(tickerid, 'D', l1[1]) 
dtime_l2 = security(tickerid, 'D', l2[1]) 
dtime_l3 = security(tickerid, 'D', l3[1]) 
dtime_l4 = security(tickerid, 'D', l4[1]) 
dtime_l5 = security(tickerid, 'D', l5[1]) 
dtime_l6 = security(tickerid, 'D', l6[1]) 

//offs_daily = 0
//plot(sd and dtime_pivot ? dtime_pivot : na, title="Daily Pivot",color=dcolor, linewidth=2)
//plot(sd and dtime_h6 ? dtime_h6 : na, title="Daily H6", color=dcolor2, linewidth=2)
//plot(sd and dtime_h5 ? dtime_h5 : na, title="Daily H5",color=dcolor2, linewidth=2)
//plot(sd and dtime_h4 ? dtime_h4 : na, title="Daily H4",color=dcolor2, linewidth=2)
//plot(sd and dtime_h3 ? dtime_h3 : na, title="Daily H3",color=dcolor1, linewidth=3)
//plot(sd and dtime_h2 ? dtime_h2 : na, title="Daily H2",color=dcolor2, linewidth=2)
//plot(sd and dtime_h1 ? dtime_h1 : na, title="Daily H1",color=dcolor2, linewidth=2)
//plot(sd and dtime_l1 ? dtime_l1 : na, title="Daily L1",color=dcolor2, linewidth=2)
//plot(sd and dtime_l2 ? dtime_l2 : na, title="Daily L2",color=dcolor2, linewidth=2)
//plot(sd and dtime_l3 ? dtime_l3 : na, title="Daily L3",color=dcolor1, linewidth=3)
//plot(sd and dtime_l4 ? dtime_l4 : na, title="Daily L4",color=dcolor2, linewidth=2)
//plot(sd and dtime_l5 ? dtime_l5 : na, title="Daily L5",color=dcolor2, linewidth=2)
//plot(sd and dtime_l6 ? dtime_l6 : na, title="Daily L6",color=dcolor2, linewidth=2)

longCondition = close >dtime_h4
if (longCondition)
    strategy.entry("My Long Entry Id", strategy.long)
    


shortCondition = close <dtime_l4
if (shortCondition)
    strategy.entry("My Short Entry Id", strategy.short)
    

Kommentare

Hii how is it working...... different in different timeframe...how can i make it for short term or intraday...
+4 Antworten
Hi Cristian.D,

Great strategy from you & I have studied your camarilla strategy. For "exits based on EMA" (instead of stop loss...etc) below is what worked for me:

if longCondition
strategy.entry("Long", strategy.long)
//strategy.exit("Exit Long", "Long", trail_points=40, trail_offset=1, loss=70)
strategy.close_all(when = EMA > close)

You have to move "strategy.close_all(when = EMA > close)" out of "if" statement. Else, the "exit will be in the same bar". Also, "strategy.close_all" is the only one I could get to work. Hope this gives you something to improve on.

Thanks a lot.

Hareesha C
+2 Antworten
Hareesha Hareesha
the code should look as below (spaces at the beginning are important):

if longCondition
strategy.entry("Long", strategy.long)
//strategy.exit("Exit Long", "Long", trail_points=40, trail_offset=1, loss=70)
strategy.close_all(when = EMA > close)
+2 Antworten
Hareesha Hareesha
sorry, again this comment section automatically removes spaces at the beginning automatically after posting comment.
Antworten
Does it repaint?
Antworten
waytonavneet RenanPaivaSiqueira
Antworten
@waytonavneet, sadly repaints... when i tested forward, gave me wrong signals
Antworten
sir , this repaint?
Antworten