ÿþstrategy Colored_Mav_strat; // made by Werner Voets for WH Selfinvest input lots = 1, price = close, period = 25, simple = true, exponential = false, weighted = false, linear = false, hull = false, displacement = 0; vars lst = 0, line(series); begin // identify what Ma is needed and Fill variable if simple = true then begin line := displace(sma(price,period), displacement); end else if exponential = true then begin line := displace(ema(price,period), displacement); end else if weighted = true then begin line := displace(wma(price,period), displacement); end else if linear = true then begin line := displace(linreg(price, period), displacement); end else if hull = true then begin line := displace(wma(2*wma(price, int(period/2)) - wma(price, period), int(SQRT(period))), displacement); end else line := displace(sma(price,period), displacement); // fill counter lst := back(line); if lst < front(line) then return; // buy and sell conditions If (line[lst] > line[lst-1]) and (line[lst-1] < line[lst-2]) then begin if short() then exitshort(); buy(lots); //then open a buy end; If (line[lst] < line[lst-1]) and (line[lst-1] > line[lst-2]) then begin if long() then exitlong(); sell(lots); //then open a sell end; end.