Can someone code a script for me that I'll pay for?

Z

zee2881

New member
VIP
Would like a script based on the trend reversal indicator, with the addition of:
1) Add Fibonacci levels after up or down arrow is triggered: A) start "up" fib draw at low of candle preceding up arrow, and end fib draw at high of candle with up arrow (see NQ uptrend picture) and: B) start "down" fib draw at high of candle preceding down arrow, and end fib draw at low of candle with down arrow (see NQ downtrend picture). As an FYI, blue arrows are generated by the trend reversal indicator and orange arrows are where I'd like fib draws to begin and end.
2) I want 50% and 61.8% retracement lines drawn
3) Add a script that will create a box in the upper left of either the price panel or RSI panel that says "RSI uptrend" or RSI downtrend"





Any help or direction would be greatly appreciated!
 
BenTen

BenTen

Administrative
Staff
VIP
In case you're not aware, the trend reversal is a repainting indicator. If you apply whatever condition to it, that signal will also disappear along with the trend reversal arrows. In other words, the Fibonacci lines that you want will also go away. I'm not sure how helpful that would be for real trading.
 
Z

zee2881

New member
VIP
Hi Ben! Yes sir, I'm aware of that and I'm ok with that, considering if it repaints that typically means I'm wrong and I bail on the trade. In your expert opinion, can this be done? And if so, would you be able to create it, or know someone that could? As I mentioned, not looking for any freebies. Thanks for your response!
 
BenTen

BenTen

Administrative
Staff
VIP
As long as you understand what you're messing with :)

Tagging @korygill and @diazlaz here as they may be able to help with your request.
 
korygill

korygill

Active member
VIP
I'm sure it can be done. It's a little unclear exactly how the fibs are drawn (just over 2 bars, or extended somehow between signals, but using the RSI signals as an example for an UP/DOWN signal, they can be drawn like show in the image. Also, need to define increasing RSI...is this just RSI greater than or less than the prev value, or over some smoothing period? I colored RSI based on just prev value in the middle pane. The lower pane is the RSI with signals so I can trigger the drawings. Adding a label for the current RSI red/green value would be trivial (and not shown).

 
Z

zee2881

New member
VIP
Thanks for the response Kory! Hopefully this clarifies. When a down arrow appears, I want a fib draw started from the high of the candle that precedes the candle with the arrow, to the low of the candle where the arrow appeared. And when an up arrow appears, I want the fib draw started from the low of the candle that precedes the candle with the the arrow, to the high of the candle where the arrow appeared. I just want the fibs tied to the arrow only, and completely independent of RSI.

Regarding RSI, I really like the RSI you showed in the middle pane, I think that gives a perfect visual compared to the standard RSI on TOS.

If you're willing to create this for me, I'd be more than happy to compensate you. If you're interested, send me a PM with your number and we can discuss in more detail.

Thanks again!!!
 
Z

zee2881

New member
VIP
@Ramesh16 Here's the code for the "trend reversal indicator". All you'll need to do is add RSI on the bottom pane.
 
Last edited by a moderator:
H

HighBredCloud

Well-known member
VIP
@korygill What code did you use to make the RSI plot line vs point like in your chart so that it changes colors from GREEN to RED? Sorry I am not a coder...I was looking for something like this but couldn't find it. Below is what I tried but it does not work...FAILED.

RSI.AssignValueColor(if RSI > RSI[1] then Color.GREEN else Color.RED);
 
horserider

horserider

Well-known member
VIP
Where does it fail? Could be from somewhere else in the study.
 
korygill

korygill

Active member
VIP
Try something like this @HighBredCloud

Code:
def vrsi = RSI().RSI;
plot p_rsi = vrsi;
def isIncreasing = vrsi >= vrsi[1];
p_rsi.AssignValueColor(if isIncreasing then Color.GREEN else Color.RED);
p_rsi.SeTPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
 
H

HighBredCloud

Well-known member
VIP
Try something like this @HighBredCloud

Code:
def vrsi = RSI().RSI;
plot p_rsi = vrsi;
def isIncreasing = vrsi >= vrsi[1];
p_rsi.AssignValueColor(if isIncreasing then Color.GREEN else Color.RED);
p_rsi.SeTPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
Thanks @korygill will try it.
 
H

HighBredCloud

Well-known member
VIP
@korygill Hey Kory...so I attempted to copy and paste codes to make a MTF RSI crossing the 5 SMA...I believe you are familiar with such a code as I saw your version somewhere on here. Now...I got the code to work...but trying to integrate what you suggested in post #11 to the MTF RSI just doesn't work...it works on regular RSI crossing the 5 SMA just not on the MTF RSI crossing the 5 SMA...is it even possible to integrate your code from post #11 to this RSI code here and have it work? I am not a coder...I copy and past things and pray for the best...sometimes it works and sometimes it doesn't.

The reason why I am asking for this is I would like to use the MTF RSI below to serve as an exit indicator. For example...IF I am trading a 2 min chart...I would set the MTF RSI to 5 min...I would use the line vs point code that you made in post #11 as an "exit" indication on the 2 min chart. but I am stuck here...when I plug the code from post #11 it appears to plot the RSI line for the current timeframe and not the MTF aggregation.
Code:
declare lower;

input length = 14;
input over_Bought = 70;
input over_Sold = 30;
input price = close;
input averageType = AverageType.WILDERS;
input showBreakoutSignals = no;
input rsiMALength = 5; #hint rsiMALength: RSI Moving Average Length
input rsiAverageType = AverageType.SIMPLE;
input aggregationPeriod1 = AggregationPeriod.FIVE_MIN;



def price1 = close(period = aggregationPeriod1);


def NetChgAvg = MovingAverage(averageType, price1 - price1[1], length);
def TotChgAvg = MovingAverage(averageType, AbsValue(price1 - price1[1]), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;

plot RSI = 50 * (ChgRatio + 1);
plot OverSold = over_Sold;
plot OverBought = over_Bought;
plot UpSignal = if RSI crosses above OverSold then OverSold else Double.NaN;
plot DownSignal = if RSI crosses below OverBought then OverBought else Double.NaN;



# plot the RSI Moving Average
def rsiMA = MovingAverage(rsiAverageType, RSI, rsiMALength);
plot prsiMA = rsiMA;

#prsiMA.AssignValueColor(if prsiMA > prsiMA[1] then Color.GREEN else Color.RED);

#plot Fifty_Line = 50;
#fifty_line.SetDefaultColor(GetColor(8));
#fifty_line.HideTitle();
#fifty_line.SetStyle(Curve.long_dASH);

UpSignal.SetHiding(!showBreakoutSignals);
DownSignal.SetHiding(!showBreakoutSignals);

RSI.DefineColor("OverBought", GetColor(5));
RSI.DefineColor("Normal", GetColor(7));
RSI.DefineColor("OverSold", GetColor(1));
RSI.AssignValueColor(if RSI > over_Bought then RSI.Color("OverBought") else if RSI < over_Sold then RSI.Color("OverSold") else RSI.Color("Normal"));
OverSold.SetDefaultColor(GetColor(8));
OverBought.SetDefaultColor(GetColor(8));
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
 
horserider

horserider

Well-known member
VIP
Remove other RSI coloring

RSI.DefineColor("OverBought", GetColor(5));
RSI.DefineColor("Normal", GetColor(7));
RSI.DefineColor("OverSold", GetColor(1));
RSI.AssignValueColor(if RSI > over_Bought then RSI.Color("OverBought") else if RSI < over_Sold then RSI.Color("OverSold") else RSI.Color("Normal"));

and add.

def isIncreasing = rsi >= rsi[1];
rsi.AssignValueColor(if isIncreasing then Color.GREEN else Color.RED);
rsi.SeTPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
 
H

HighBredCloud

Well-known member
VIP
Remove other RSI coloring

RSI.DefineColor("OverBought", GetColor(5));
RSI.DefineColor("Normal", GetColor(7));
RSI.DefineColor("OverSold", GetColor(1));
RSI.AssignValueColor(if RSI > over_Bought then RSI.Color("OverBought") else if RSI < over_Sold then RSI.Color("OverSold") else RSI.Color("Normal"));

and add.

def isIncreasing = rsi >= rsi[1];
rsi.AssignValueColor(if isIncreasing then Color.GREEN else Color.RED);
rsi.SeTPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
@horserider WOW...THANK YOU so much! I really appreciate it. It took me forever until I made this post asking for help. If you don't mind can you please tell me what I need to do in order to have the 5 SMA change color in the same manner as the RSI...I used the line of code below

#prsiMA.AssignValueColor(if prsiMA > prsiMA[1] then Color.GREEN else Color.RED);

but the SMA line comes out all jagged and it just doesn't make sense in my eyes...I would like to see the SMA also change color when its increasing and when its decreasing. Anyway that can be done even thought its an MTF or will that SMA line always look like the pic? Pic is ONLY of the SMA...

 
horserider

horserider

Well-known member
VIP
The line will look jagged due to it being a higher time frame from chart time frame. Higher you make the agg, the more jagged it becomes. It is the say ten minute steps on the 2 minute chart. Only updates the line every ten minutes while chart is moving along at 2 minutes.
 
H

HighBredCloud

Well-known member
VIP
The line will look jagged due to it being a higher time frame from chart time frame. Higher you make the agg, the more jagged it becomes. It is the say ten minute steps on the 2 minute chart. Only updates the line every ten minutes while chart is moving along at 2 minutes.
That's what I figured...I just wasn't sure...I saw the TREND MAGIC indicator and even on higher timeframes I don't believe it was as jagged as my pic therefore I thought perhaps I did something wrong. Anyways thank you so much for your help this really is very useful for me and hopefully others.
 
A

Alex

Member
VIP
@horserider WOW...THANK YOU so much! I really appreciate it. It took me forever until I made this post asking for help. If you don't mind can you please tell me what I need to do in order to have the 5 SMA change color in the same manner as the RSI...I used the line of code below

#prsiMA.AssignValueColor(if prsiMA > prsiMA[1] then Color.GREEN else Color.RED);

but the SMA line comes out all jagged and it just doesn't make sense in my eyes...I would like to see the SMA also change color when its increasing and when its decreasing. Anyway that can be done even thought its an MTF or will that SMA line always look like the pic? Pic is ONLY of the SMA...

Do you mind sharing your chart setup?
 
H

HighBredCloud

Well-known member
VIP
Do you mind sharing your chart setup?
I am testing a SuperTrend right now that is not fully ready...BUT when it will be ready for release with all the bugs out a post will be made here for sure. In the mean time you can find the test version here:

https://usethinkscript.com/threads/...rading-system-v3-0-csa.1596/page-6#post-16734
The arrows are from the HIGH/LOW Swing indicator in the code below...
Code:
# Swing High and Swing Low
# tomsk
# 11.18.2019
# As requested by chillc15 I have modified @RobertPayne code to include SwingHigh
# points which are now plotted in CYAN with the swing high points painted in PINK.
# So now you have both swing high and low on your charts
# +------------------------------------------------------------+
# | Example: How to extend levels to the right of the chart |
# | Robert Payne |
# | https://funwiththinkscript.com |
# +------------------------------------------------------------+
# SWING LOW
# define swing low points
input length = 10;
def bn = BarNumber();
def lastBar = HighestAll(if IsNaN(close) then 0 else bn);
def offset = Min(length - 1, lastBar - bn);
def swingLow = low < Lowest(low[1], length - 1) and low == GetValue(Lowest(low, length), -offset);
# identify the very last swing low point
def lowPointOneBarNumber = HighestAll(if swingLow then bn else 0);
def lowPointOneValue = if bn == lowPointOneBarNumber then low else lowPointOneValue[1];
plot low1 = if bn < lowPointOneBarNumber then Double.NaN else lowPointOneValue;
low1.SetDefaultColor(Color.LIGHT_RED);
# identify the 2nd to last swing low point
def lowPointTwoBarNumber = HighestAll(if swingLow and bn < lowPointOneBarNumber then bn else 0);
def lowPointTwoValue = if bn == lowPointTwoBarNumber then low else lowPointTwoValue[1];
plot low2 = if bn < lowPointTwoBarNumber then Double.NaN else lowPointTwoValue;
low2.SetDefaultColor(Color.Light_RED);
# just keep doing ths for as many lines as you want to add to the chart
# identify then 3rd to last swingHigh point low
def lowPointThreeBarNumber = HighestAll(if swingLow and bn < lowPointTwoBarNumber then bn else 0);
def lowPointThreeValue = if bn == lowPointThreeBarNumber then low else lowPointThreeValue[1];
plot low3 = if bn < lowPointThreeBarNumber then Double.NaN else lowPointThreeValue;
low3.SetDefaultColor(Color.Light_RED);
# identify then 4th to last swingHigh point low
def lowPointFourBarNumber = HighestAll(if swingLow and bn < lowPointThreeBarNumber then bn else 0);
def lowPointFourValue = if bn == lowPointFourBarNumber then low else lowPointFourValue[1];
plot low4 = if bn < lowPointFourBarNumber then Double.NaN else lowPointFourValue;
low4.SetDefaultColor(Color.Light_RED);
# identify then 5th to last swingHigh point low
def lowPointFiveBarNumber = HighestAll(if swingLow and bn < lowPointFourBarNumber then bn else 0);
def lowPointFiveValue = if bn == lowPointFiveBarNumber then low else lowPointFiveValue[1];
plot low5 = if bn < lowPointFiveBarNumber then Double.NaN else lowPointFiveValue;
low5.SetDefaultColor(Color.Light_RED);
# identify then 6th to last swingHigh point low
def lowPointSixBarNumber = HighestAll(if swingLow and bn < lowPointFiveBarNumber then bn else 0);
def lowPointSixValue = if bn == lowPointSixBarNumber then low else lowPointSixValue[1];
plot low6 = if bn < lowPointSixBarNumber then Double.NaN else lowPointSixValue;
low6.SetDefaultColor(Color.Light_RED);
# identify then 7th to last swingHigh point low
def lowPointSevenBarNumber = HighestAll(if swingLow and bn < lowPointSixBarNumber then bn else 0);
def lowPointSevenValue = if bn == lowPointSevenBarNumber then low else lowPointSevenValue[1];
plot low7 = if bn < lowPointSevenBarNumber then Double.NaN else lowPointSevenValue;
low7.SetDefaultColor(Color.Light_RED);
# identify then 8th to last swingHigh point low
def lowPointEightBarNumber = HighestAll(if swingLow and bn < lowPointSevenBarNumber then bn else 0);
def lowPointEightValue = if bn == lowPointEightBarNumber then low else lowPointEightValue[1];
plot low8 = if bn < lowPointEightBarNumber then Double.NaN else lowPointEightValue;
low8.SetDefaultColor(Color.Light_RED);
# identify then 9th to last swingHigh point low
def lowPointNineBarNumber = HighestAll(if swingLow and bn < lowPointEightBarNumber then bn else 0);
def lowPointNineValue = if bn == lowPointNineBarNumber then low else lowPointNineValue[1];
plot low9 = if bn < lowPointNineBarNumber then Double.NaN else lowPointNineValue;
low9.SetDefaultColor(Color.Light_RED);
# identify then 10th to last swingHigh point low
def lowPointTenBarNumber = HighestAll(if swingLow and bn < lowPointNineBarNumber then bn else 0);
def lowPointTenValue = if bn == lowPointTenBarNumber then low else lowPointTenValue[1];
plot low10 = if bn < lowPointTenBarNumber then Double.NaN else lowPointTenValue;
low10.SetDefaultColor(Color.Light_RED);


# SWING HIGH
# define swing high points
def swingHigh = high > Highest(high[1], length - 1) and high == GetValue(Highest(high, length), -offset);
# identify the very last swing high point
def highPointOneBarNumber = HighestAll(if swingHigh then bn else 0);
def highPointOneValue = if bn == highPointOneBarNumber then high else highPointOneValue[1];
plot high1 = if bn < highPointOneBarNumber then Double.NaN else highPointOneValue;
high1.SetDefaultColor(Color.CYAN);
# identify the 2nd to last swing high point
def highPointTwoBarNumber = HighestAll(if swingHigh and bn < highPointOneBarNumber then bn else 0);
def highPointTwoValue = if bn == highPointTwoBarNumber then high else highPointTwoValue[1];
plot high2 = if bn < highPointTwoBarNumber then Double.NaN else highPointTwoValue;
high2.SetDefaultColor(Color.CYAN);
# just keep doing ths for as many lines as you want to add to the chart
def highPointThreeBarNumber = HighestAll(if swingHigh and bn < highPointTwoBarNumber then bn else 0);
def highPointThreeValue = if bn == highPointThreeBarNumber then high else highPointThreeValue[1];
plot high3 = if bn < highPointThreeBarNumber then Double.NaN else highPointThreeValue;
high3.SetDefaultColor(Color.CYAN);
def highPointFourBarNumber = HighestAll(if swingHigh and bn < highPointThreeBarNumber then bn else 0);
def highPointFourValue = if bn == highPointFourBarNumber then high else highPointFourValue[1];
plot high4 = if bn < highPointFourBarNumber then Double.NaN else highPointFourValue;
high4.SetDefaultColor(Color.CYAN);
def highPointFiveBarNumber = HighestAll(if swingHigh and bn < highPointFourBarNumber then bn else 0);
def highPointFiveValue = if bn == highPointFiveBarNumber then high else highPointFiveValue[1];
plot high5 = if bn < highPointFiveBarNumber then Double.NaN else highPointFiveValue;
high5.SetDefaultColor(Color.CYAN);
def highPointSixBarNumber = HighestAll(if swingHigh and bn < highPointFiveBarNumber then bn else 0);
def highPointSixValue = if bn == highPointSixBarNumber then high else highPointSixValue[1];
plot high6 = if bn < highPointsixBarNumber then Double.NaN else highPointsixValue;
high6.SetDefaultColor(Color.CYAN);
def highPointSevenBarNumber = HighestAll(if swingHigh and bn < highPointSixBarNumber then bn else 0);
def highPointSevenValue = if bn == highPointSevenBarNumber then high else highPointSevenValue[1];
plot high7 = if bn < highPointSevenBarNumber then Double.NaN else highPointSevenValue;
high7.SetDefaultColor(Color.CYAN);
def highPointEightBarNumber = HighestAll(if swingHigh and bn < highPointSevenBarNumber then bn else 0);
def highPointEightValue = if bn == highPointEightBarNumber then high else highPointEightValue[1];
plot high8 = if bn < highPointEightBarNumber then Double.NaN else highPointEightValue;
high4.SetDefaultColor(Color.CYAN);
def highPointNineBarNumber = HighestAll(if swingHigh and bn < highPointEightBarNumber then bn else 0);
def highPointNineValue = if bn == highPointNineBarNumber then high else highPointNineValue[1];
plot high9 = if bn < highPointNineBarNumber then Double.NaN else highPointNineValue;
high4.SetDefaultColor(Color.CYAN);
def highPointTenBarNumber = HighestAll(if swingHigh and bn < highPointNineBarNumber then bn else 0);
def highPointTenValue = if bn == highPointTenBarNumber then high else highPointTenValue[1];
plot high10 = if bn < highPointTenBarNumber then Double.NaN else highPointTenValue;
high4.SetDefaultColor(Color.CYAN);

# ADJUST CANDLE COLORS
# change candle colors just to make it easier to see what we are working with
#AssignPriceColor(if swingLow then Color.cyan else if swingHigh then Color.mageNTA else Color.current);

plot HighArrow = swingHigh;
HighArrow.SetLineWeight(5);
HighArrow.SetDefaultColor(Color.RED);
HighArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

plot LowArrow = swingLow;
LowArrow.SetLineWeight(5);
LowArrow.SetDefaultColor(Color.GREEN);
LowArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);

# End Swing High and Swing Low
 
H

HighBredCloud

Well-known member
VIP
@horserider Hey just want to give you an update...That MTF RSI 5 SMA crossover that you made works really good. It helped me bring my strategy together more. I was wondering though...since you're an RSI fan...would you be able to do a little bit more work to that script if you have the time? I am having some difficulties with this one...

I would like to add two additional "POINTS" above the OverBought and OverSold lines that reflect the same condition of change color when RSI increases/decreases on one of them and on the other the color change to be based on the RSI crossing the 5 SMA.

I would like one of the "POINTS" to be MTF...and the other to display current timeframe...Just the POINTS...no SMA line.

So essentially the whole study would like like this: The RSI LINE vs POINT 5 SMA crossover remains the same as the study you modified...The additional two POINTS would placed above and below the OB/OS lines not to clutter the middle that displays the MTF RSI and 5 SMA. I would like to be able to set the MTF RSI to whatever aggregation that I want and the other would display current timeframe chart.

This would help me out a lot...Right now I am running 3 versions of RSI and I would like to free up the space.

The reason for my request is for this strategy: Let's say I am trading on a 3 min time frame...The main RSI that displays the 5 SMA cross over like the one you modded would be set to a 15 min aggregation. That shows me where the RSI is on the 15 min obviously but while looking at a 3 min chart. The second MTF RSI that I would like to add I would set to 5 min. That would serve as my "exit" or "re-entry." And the last POINT would serve as current timeframe RSI.

With the current timeframe RSI POINT...would you be able to set the condition to change color not when the RSI is increasing or decreasing such as on the MTF RSI...but rather to have the colors change when the RSI crosses the 5 SMA line?

In theory from my observations...when ALL RSI's show the same color that is the strongest trend in that direction...AND when the current timeframe RSI condition is set to color based on the 5 SMA crossover...and the secondary MTF RSI that set to 5 min with the condition to change color based on RSI increase/decrease match up it indicates time to either EXIT or RE-ENTER the TRADE assuming the primary MTF RSI with the LINE VS POINTS and the 5 SMA line are all in confluence.

I hope this makes sense to you...IF you would be able to do this I would greatly appreciate it. This is a very simple strategy that just works.
 

Similar threads

Top