Identifying a range of bars

Questions about MultiCharts and user contributed studies.
Jonny473
Posts: 68
Joined: 04 Apr 2016
Has thanked: 5 times
Been thanked: 1 time

Identifying a range of bars

Postby Jonny473 » 04 Mar 2017

I have an divergence indicator that "stores" the value of specific price bars AND indicator values. This bar range can go from 5-60 bars. Lets say the indicator used is Stochastics, so having those two Stochastic values StoVal[oPivotBar2] and StoVal[oPivotBar1] connected to the price bars (oPivotBar1, oPivotBar2), I now want to identify the Stochastic highs and lows in between those two Stochastics points. Any idea how I can accomplish that?

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Identifying a range of bars

Postby TJ » 04 Mar 2017

I have an divergence indicator that "stores" the value of specific price bars AND indicator values. This bar range can go from 5-60 bars. Lets say the indicator used is Stochastics, so having those two Stochastic values StoVal[oPivotBar2] and StoVal[oPivotBar1] connected to the price bars (oPivotBar1, oPivotBar2), I now want to identify the Stochastic highs and lows in between those two Stochastics points. Any idea how I can accomplish that?
What do you mean by "stores"?


How you find the highs/lows depends on how you "stores" your data.

Jonny473
Posts: 68
Joined: 04 Apr 2016
Has thanked: 5 times
Been thanked: 1 time

Re: Identifying a range of bars

Postby Jonny473 » 10 Mar 2017

Hi,
thanks for the fast reply; to be more specific I have the following indicator:



Code: Select all

inputs:
MomentumLength(28),
Left_Strength( 5 ),
Right_Strength( 5 ),
Length( 60 ) ,
PlotSeries( 1 ) ; // 1 for Plot Series Stream 1, 2 for Plot Series Stream 2

variables:
MomVal(0),
oPivotPrice1(0),
oPivotPrice2(0),
oPivotPrice3(0),
oPivotPrice4(0),
oPivotBar1(0),
oPivotBar2(0),
oPivotBar3(0),
oPivotBar4(0),
HiLo( 0 ) ,{ pass in 1 for BearishDiv (based on SwingHighs), -1 for
BullishDiv (based on SwingLows) }
TL_IDBull( 0 ) ,
TL_IDBear( 0 );


Value1 = Momentum(C , MomentumLength) ;
MomVal=Momentum(C , MomentumLength) ;
Condition1=Pivot (MomVal,Length,Left_Strength,Right_Strength,1,-1,oPivotPrice1,oPivotBar1)<>-1
and (oPivotBar1-Right_Strength)=0;
Condition2=Pivot(MomVal,Length,Left_Strength,Right_Strength,2,-1,oPivotPrice2,oPivotBar2)<>-1;

If Condition1 and Condition2 and L[oPivotBar2]>=L[oPivotBar1] and MomVal[oPivotBar2]<MomVal[oPivotBar1] then
begin
Value2=TL_New(D[oPivotBar2], T[oPivotBar2], L[oPivotBar2], D[oPivotBar1], T[oPivotBar1], L[oPivotBar1]);
TL_SetColor(Value2, Blue);
TL_SetSize(Value2,3);
End;
Plot1(MomVal);
If Close>Highest(Close,Value2) then

Condition3=Pivot(MomVal,Length,Left_Strength,Right_Strength,1,1,oPivotPrice3,oPivotBar3)<>-1
and (oPivotBar1-Right_Strength)=0;
Condition4=Pivot(MomVal,Length,Left_Strength,Right_Strength,2,1,oPivotPrice4,oPivotBar4)<>-1;

If Condition3 and Condition4 and H[oPivotBar3]>=H[oPivotBar4] and MomVal[oPivotBar3]<MomVal[oPivotBar4] then
begin
Value3=TL_New(D[oPivotBar4], T[oPivotBar4], H[oPivotBar4], D[oPivotBar3], T[oPivotBar3], H[oPivotBar3]);
TL_SetColor(Value3, Red);
TL_SetSize(Value3,3);
End;
Plot1(MomVal);

I want to implement a "trigger" after a divergence is shown. I attached an example picture: For the trigger, the divergence length is looked at. For a bearish trigger, as shown in the example, the lowest Momentum point in that period is used. After the divergence setup becomes valid, price now has to decline and the momentum forming has to cross below that stored momentum low, which is the trigger for a sell. For a buy trigger vice versa.
Therefore I have to find the lowest/ highest momentum values within that divergence lenght; the trigger than comes into play once momentum crosses below/ above that momentum high/low afterwards.

Image


Return to “MultiCharts”