– On the basis of a program written by Leo entitled “LEO MOVING AVERAGE” I propose a simple strategy to initiate positions in “Against Trend” on detection of new higher or lower …
– The program displays the maximum and minimum levels, indicates the position and the direction of the input with a planned Stop Loss indicating the extreme points. It colors the background trend on the unit of time used in blue if the asset is bullish or yellow if it is bearish. A simple 200-period moving average was added to validate the medium-term trend …
Variables make it possible to adapt this strategy to your liking:
// Scalping Counter Trend | Graph Indicator
// 06.03.2019 (Release 1.0)
// Swapping @ www.forexswap.fr
// Sharing ProRealTime knowledge (alt+16)
// Program adapted from "LEO MOVING AVERAGE" indicator created by LEO contributer of website ProrealCode.com
// --- Property Settings ---
Period = 20 // (Value Leo Moving Average)
Offset = 12 // (offset text candle)
Color = 33 // (transparency background)
BackColor = 1 // 0=true; 1=false (option background color)
Text = 1 // 0=false; 1=true (option text hidden)
// --- end
color = max(color,0) // Limited input "Max-Min" data
color = min(color,255)
// supports and resistances
once support = low
once resistance = high
LMA = 2*weightedaverage[period](close)-average[period](close)
smoothLMA = weightedaverage[period](LMA)
sma = average[200](customclose)
// ---> Storage of minimums and maximums
if barindex > 1 then
if low < lowest[period](low[1]) then
mintemp = low // minimum temporal
posmintemp = barindex // position of minimum temporal
direction = 1 // Background Color Chart and Segment
if direction = 1 then
endif
endif
if high > highest[period](high[1]) then
maxtemp = high // maximum temporal
posmaxtemp = barindex // position maximum temporal
direction = -1 // Background Color Chart and Segment
if direction = -1 then
endif
endif
endif
// ---> Background Color Chart with (enable or disable) condition
if BackColor = 1 and direction < 0 then
BackGroundColor(0,255,255,color) // Bullish blue
else
BackGroundColor(255,255,0,color) // Bearish yellow
endif
if BackColor = 0 then // BackgroundColor disabled
BackGroundColor(0,0,0,0)
endif
if LMA crosses over smoothLMA then // --> Detecting and locating a local minimum
LEVMIN = mintemp
POSLEVMIN = posmintemp
support = LEVMIN
//DrawArrowUp(POSLEVMIN+0,LEVMIN-2) coloured(20,200,0,170) // Option Arrow Up
DrawText("•",poslevmin,levmin-offset*0.2,Serif,Bold,16) coloured(33,200,33) // Glyphe alt+7
if Text = 1 then
DrawText("SL #levmin#",poslevmin,levmin-offset,SansSerif,Bold,11) coloured(33,200,33)
endif
elsif LMA crosses under smoothLMA then // --> Detecting and locating a local maximum
LEVMAX = maxtemp
POSLEVMAX = posmaxtemp
resistance = LEVMAX
//DrawArrowDown(POSLEVMAX+0,LEVMAX+2) coloured(200,20,0,170) // Option Arrow Down
DrawText("•",poslevmax,levmax-offset*0.2,Serif,Bold,16) coloured(200,33,33) // Glyphe alt+7
if Text = 1 then
DrawText("SL #levmax#",poslevmax,levmax+offset,SansSerif,Bold,11) coloured(200,33,33)
endif
endif
support = min(low,support)
resistance = max(high,resistance)
return LMA as " LMA", resistance coloured by resistance as " Resistance", support coloured by support as " Support", smoothLMA coloured by smoothLMA as " smoothLMA", sma coloured by sma as " SMA"