Forums › ProRealTime English forum › ProOrder support › Wanted: small code snippet for reinvestment › Reply To: Wanted: small code snippet for reinvestment
01/12/2018 at 1:58 PM
#59181
That is an interesting new look at SuperTrend. I wasn’t getting any colour with the way the code is written. Never seen ‘coloured as’ before? So I changed it slightly. You should maybe put it in the library for others to consider using.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
ONCE direction = 1 ONCE STlongold = 0 ONCE STshortold = 1000000000000 factor = 0.005 indicator1 = medianprice indicator3 = close indicator2 = indicator3 * factor STlong = indicator1 - indicator2 STshort = indicator1 + indicator2 If direction = 1 and STlong < STlongold then STlong = STlongold endif If direction = -1 and STshort > STshortold then STshort = STshortold endif If direction = 1 and indicator3 crosses under STlong then direction = -1 endif If direction = -1 and indicator3 crosses over STshort then direction = 1 endif STlongold = STlong STshortold = STshort If direction = 1 then ST = STlong R = 0 G = 128 else ST = STshort R = 128 G = 0 endif Return ST coloured(R,G,0) Style(Line,2) as "Supertrend" |