//-------------------------------------------------------------------------
// Codice principale : RSI2P_LarryConnors_4h
//
// CAC40 mini TF 4 h
//-------------------------------------------------------------------------
////////////////RSI2p CAC40 /////////////////////////////////
DEFPARAM CUMULATEORDERS = true
//defparam FLATBEFORE = 080000
endtime = 210000
starttime = 045500
//n = 4 // mettre ce que vous voulez
Reinvest=0
if reinvest then
//Capital = 10000
Capital = 5000
//Risk = 1//in % pr position
Risk = 3//0.1//in % pr position
StopLoss = 48
//StopLoss = 70
REM Calculate contracts
equity = Capital + StrategyProfit
maxrisk = round(equity*(Risk/100))
MAXpositionsize=5000
//MINpositionsize=1
MINpositionsize=1
Positionsize= MAX(MINpositionsize,MIN(MAXpositionsize,abs(round((maxrisk/StopLoss)))))//*Pointsize))))
else
Positionsize=1
StopLoss = 48
//StopLoss = 70
Endif
n = positionsize
//positive = Dclose(1) > Dopen(1)
inside = low > low[1] and high <high[1]
/// moltiplicatore
x1 = n+1
// INDICATEURS
MM200 = average[100](close)
//MM10 = average[10](close)
//MM20 = average[20](close)
//MM5 = average[5](close)
RSI2 = RSI[2](close)
// NEW only for short high > bbup
///////////////
ha1 = high > BollingerUP[20]
//low100 = low > MM200+5
//////////////////
//GAP
gap = open < low[1]
/////
// ACHAT
//ca1 = close > MM200
ca2 = RSI2 < 10
if currentdayofweek < 5 then
if CurrentMonth <> 8 then
if time > starttime and time < endtime then
if not GAP then
IF ca2 and not inside AND Currentmonth < 5 then
BUY x1 shares at high stop
//reversal = 0
ELSE
IF ca2 and not inside then
BUY n shares at high stop
//reversal = 0
ENDIF
endif
endif
endif
endif
endif
// --- SHORT
cv1 = close < MM200
cv2 = RSI2 > 90
//IF cv1 and cv2 THEN
//SELLSHORT n shares at market
//ENDIF
//if CurrentdayOfWeek < 3 then
if time > starttime and time < endtime then
IF cv1 and cv2 and ha1 and not inside THEN
//IF cv1 and cv2 THEN
SELLSHORT n shares at low stop
//reversal = 0
ENDIF
endif
//Stop loss utileper AUD/USD
SET STOP %LOSS 2.9
SET Target %profit 0.7 // 1.2 - 1.9
//***************************************************************************************
trailingstart = 5 //3,14 trailing will start @trailinstart points profit
trailingstep = 1 //1 trailing step to move the "stoploss"
//reset the stoploss value
IF NOT ONMARKET THEN
newSL=0
ENDIF
//manage long positions
IF LONGONMARKET THEN
//first move (breakeven)
IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THEN
newSL = tradeprice(1)+trailingstep*pipsize
ENDIF
//next moves
IF newSL>0 AND close-newSL>=trailingstep*pipsize THEN
newSL = newSL+trailingstep*pipsize
ENDIF
ENDIF
//manage short positions
IF SHORTONMARKET THEN
//first move (breakeven)
IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THEN
newSL = tradeprice(1)-trailingstep*pipsize
ENDIF
//next moves
IF newSL>0 AND newSL-close>=trailingstep*pipsize THEN
newSL = newSL-trailingstep*pipsize
ENDIF
ENDIF
//stop order to exit the positions
IF newSL>0 THEN
SELL AT newSL STOP
EXITSHORT AT newSL STOP
ENDIF
/// ------------------------