imonlysleeping
New member
Hi, i had the idea to create a lower study that shows the average price move between swings over time. My first thought was to use a swing high/low indicator, which I already have, and simply measure and average the price move between each swing high and low.
Being able to average the price moves and plot that as a lower study is beyond my abilities, or perhaps beyond the abilities of thinkscript? I think maybe via the use of CompoundValue and/or fold function, this can be accomplished, I just can't figure it out.
Would be extra cool to have a user input to be able to only extract and average the price moves during a certain time of the day each day. Mainly looking to play with this indicator on a lower timeframe chart.
Would be double extra cool to give two readings - the average size of the moves to the downside and the average size of the moves to the upside.
Can anyone let me know if this is possible to do using thinkscript?
This is the swing high/low indicator i found here in the forums a few months ago, which i have been attempting to alter and use for the creation of the new indicator:
Being able to average the price moves and plot that as a lower study is beyond my abilities, or perhaps beyond the abilities of thinkscript? I think maybe via the use of CompoundValue and/or fold function, this can be accomplished, I just can't figure it out.
Would be extra cool to have a user input to be able to only extract and average the price moves during a certain time of the day each day. Mainly looking to play with this indicator on a lower timeframe chart.
Would be double extra cool to give two readings - the average size of the moves to the downside and the average size of the moves to the upside.
Can anyone let me know if this is possible to do using thinkscript?
This is the swing high/low indicator i found here in the forums a few months ago, which i have been attempting to alter and use for the creation of the new indicator:
Code:
#SWING HIGH LOW
input LookbackPeriod = 3;
input HideCurrentTF = no;
#--------------------------------------------------------------
def _highInPeriod1 = Highest(high, LookbackPeriod);
def _lowInPeriod1 = Lowest(low, LookbackPeriod);
#--------------------------------------------------------------
def marketLow1 = if _lowInPeriod1 < _lowInPeriod1[-LookbackPeriod] then _lowInPeriod1 else _lowInPeriod1[-LookbackPeriod];
def _markedLow1 = low == marketLow1;
rec _lastMarkedLow1 = CompoundValue(1, if IsNaN(_markedLow1) then _lastMarkedLow1[1] else if _markedLow1 then low else _lastMarkedLow1[1], low);
#--------------------------------------------------------------
def marketHigh1 = if _highInPeriod1 > _highInPeriod1[-LookbackPeriod] then _highInPeriod1 else _highInPeriod1[-LookbackPeriod];
def _markedHigh1 = high == marketHigh1;
rec _lastMarkedHigh1 = CompoundValue(1, if IsNaN(_markedHigh1) then _lastMarkedHigh1[1] else if _markedHigh1 then high else _lastMarkedHigh1[1], high);
#--------------------------------------------------------------
plot Resistance1 = _lastMarkedHigh1;
plot Support1 = _lastMarkedLow1 ;
#--------------------------------------------------------------
Resistance1.SetPaintingStrategy(PaintingStrategy.DASHES);
Resistance1.SetDefaultColor(Color.GREEN);
Resistance1.SetHiding(HideCurrentTF);
#--------------------------------------------------------------
Support1.SetPaintingStrategy(PaintingStrategy.DASHES);
Support1.SetDefaultColor(Color.RED);
Support1.SetHiding(HideCurrentTF);
Last edited: