// Conditions to enter long positions
//
// Rikoshett trading system SCA 24 januari 2020 //
// Buy when ricoshet occurs //
// Constructer Erik Olsson //
// Exit days//
// Exit Stochastic //
// Exit Moving Average //
DEFPARAM CUMULATEORDERS = false
n = round(200000/dclose(0))
MM5sell = Average[18](close)
difflow = high[0]-low[0]
diffclose = close[0]-low[0]
rikoshettprocent = diffclose/difflow*100
closeyesterday = close[1]>open[0]
low5 = lowest[2](low)
low5days = low[0]<=low5
rikoshett = rikoshettprocent < 11
trade = rikoshett and closeyesterday and low5days
if trade then
buy n shares at market
endif
if onmarket and close[0] > MM5sell then
sell at market
endif
if onmarket and barindex-tradeindex = 8 then
sell at market
endif
//Stochastic
if onmarket and Stochastic[20,4](close) > Stochastic[2,8](close) then
sell at market
endif