NexusFi: Find Your Edge


Home Menu

 





Fear/Greed Indicator


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one Fat Tails with 5 posts (16 thanks)
    2. looks_two PegasusDK with 5 posts (10 thanks)
    3. looks_3 Mehul with 4 posts (0 thanks)
    4. looks_4 cory with 3 posts (9 thanks)
      Best Posters
    1. looks_one Fat Tails with 3.2 thanks per post
    2. looks_two cory with 3 thanks per post
    3. looks_3 PegasusDK with 2 thanks per post
    4. looks_4 Loukas with 0.3 thanks per post
    1. trending_up 27,726 views
    2. thumb_up 36 thanks given
    3. group 18 followers
    1. forum 31 posts
    2. attach_file 9 attachments




 
Search this Thread

Fear/Greed Indicator

  #21 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102


Mehul View Post
Hi fat tails

How Ve you been doing with your fear and greed, any more progress?

Thanks

Mehul

I have been completely absorbed by other projects and forgotten my fear and greed.

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
MC PL editor upgrade
MultiCharts
Trade idea based off three indicators.
Traders Hideout
Bigger Wins or Fewer Losses?
Traders Hideout
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
33 thanks
Tao te Trade: way of the WLD
24 thanks
My NQ Trading Journal
14 thanks
GFIs1 1 DAX trade per day journal
11 thanks
HumbleTraders next chapter
11 thanks
  #22 (permalink)
PegasusDK
Odense, Denmark
 
Posts: 5 since Oct 2011
Thanks Given: 1
Thanks Received: 10

Hi Mehul & others,

I'd love to provide you with a sample spread sheet!
I'm pretty much hung up at the moment, but I will most certainly post an example in the near future.

Stay tuned...

/PegasusDK

Reply With Quote
  #23 (permalink)
Mehul
London, united kingdom
 
Posts: 27 since Nov 2011
Thanks Given: 2
Thanks Received: 3


Hi

Thanks for the reply , look forward to the excel example.

What products do you trade !

Regards

Mehul



PegasusDK View Post
Hi Mehul & others,

I'd love to provide you with a sample spread sheet!
I'm pretty much hung up at the moment, but I will most certainly post an example in the near future.

Stay tuned...

/PegasusDK


Reply With Quote
  #24 (permalink)
PegasusDK
Odense, Denmark
 
Posts: 5 since Oct 2011
Thanks Given: 1
Thanks Received: 10

I've promised a sample spread sheet with the fear/greed and the Trender, but this one will be delayed due to my other activities the next month or so.
I've then decided to put my code to Vikingen here, as it's much easier for me.
If you have any questions about the code, please put them here.

Here goes...

 
Code
par(Main             : Instrument;
    MidPointEMAlen   : Integer;     // Parameters for Trender
    TrueRangeEMAlen  : Integer;
    StdDevPeriod     : Integer;
    StdDevFactor     : Real;
    UseClose         : Boolean;
    W1orE2           : Integer;     // Parameters for FearGreed
    FastMA           : Integer;
    SlowMA           : Integer;
    ShiftBack        : Integer;     // Also used for the TrueRange over "ShiftBack" periods
    SmoothMA         : Integer;
    BuyLevel,
    SellLevel        : Real;
    Out TrenderRes,
        TrenderSup   : RealVector;
    Out FearGreed    : RealVector;
    Out LinZero,
        LinBuy,
        LinSell      : RealVector;
    Out ChangePct    : RealVector;
    Out BuyAge,
        SellAge      : RealVector;
    Out Buy, Sell    : BooleanVector);

var i,
    Lengde,
    StartPos,
    TotPeriod        : Integer;
    Support          : Boolean;
    r1, r2,
    r3, r4           : RealVector;
    StdDevTrueRange  : RealVector;
    MidPoint,
    AdjMidPoint      : RealVector;
    Trender,
    HiPrice,
    LoPrice,
    ClsPrice,
    HiPricePeriod,
    LoPricePeriod    : RealVector;
    ZeroVector,
    UnDefVector      : RealVector;
    TrueRange,
    TrueRangeUp,
    TrueRangeEMA,
    TrueRangeDwn     : RealVector;
    TRfastUp,
    TRfastDwn,
    TRslowUp,
    TRslowDwn        : RealVector;
    FGraw,
    FastDiff,
    SlowDiff         : RealVector;
    b1, s1,
    b2, s2           : BooleanVector;

BEGIN
  LinZero := 0;
  ZeroVector := 0;
  StartPos := 14;
  HiPrice := FILL(Main.High);
  LoPrice := FILL(Main.Low);
  ClsPrice := FILL(Main.Close);
  Lengde := LEN(ClsPrice) - 1;
  // Calculate True Range
  R1 := HiPrice - LoPrice;
  R2 := ABS(LoPrice - Shift(ClsPrice, 1));
  R3 := ABS(HiPrice - Shift(ClsPrice, 1));
  R4 := ALT((R1 > R2), R1, R2);
  TrueRange := ALT((R3 > R4), R3, R4);
  TrueRangeEMA := MAVX(TrueRange, TrueRangeEMAlen);
  StdDevTrueRange := STDEV(TrueRangeEMA, StdDevPeriod);
  MidPoint := (LoPrice + HiPrice) / 2;
  AdjMidPoint := MAVX(MidPoint, MidPointEMAlen) + (TrueRangeEMA / 2);
  AdjMidPoint := AdjMidPoint + (StdDevTrueRange * StdDevFactor);
  // Calculate support and resistance lines for the Trender
  //---------------------------------------------------------
  TrenderRes := AdjMidPoint;
  TrenderSup := MAVX(MidPoint, MidPointEMAlen) - (TrueRangeEMA / 2);
  TrenderSup := TrenderSup - (StdDevTrueRange * StdDevFactor);
  // Find initial direction = the active Trender
  Support := (ClsPrice[StartPos] > TrenderRes[StartPos]);
  i := StartPos;
  Loop;
    i := i + 1;
    if (i > Lengde) then Exit; end;
    if Support then
      if (TrenderSup[i-1] > TrenderSup[i]) then
        TrenderSup[i] := TrenderSup[i-1];
      end;
      if (ClsPrice[i] < TrenderSup[i]) then
        // Make TrenderRes the new Trender => go from buy to sell
        s1[i] := TRUE;
        Support := FALSE;
        Trender[i] := TrenderRes[i];
      else
        b1[i] := TRUE;
        Trender[i] := TrenderSup[i];
      end;
    else
      if (TrenderRes[i-1] < TrenderRes[i]) then
        TrenderRes[i] := TrenderRes[i-1];
      end;
      if (ClsPrice[i] > TrenderRes[i]) then
        // Make TrenderSup the new Trender => go from sell to buy
        b1[i] := TRUE;
        Support := TRUE;
        Trender[i] := TrenderSup[i];
      else
        s1[i] := TRUE;
        Trender[i] := TrenderRes[i];
      end;
    end;
  end;  // Loop...
  TrenderRes := ALT((s1 = TRUE), Trender, UnDefVector);
  TrenderSup := ALT((b1 = TRUE), Trender, UnDefVector);
  // Calculate FearGreed
  //---------------------
  LoPricePeriod := Std.MIN(LoPrice, ShiftBack);
  HiPricePeriod := Std.MAX(HiPrice, ShiftBack);
  // Calculate new TrueRange for "ShiftBack" periods
  R1 := HiPricePeriod - LoPricePeriod;
  R2 := ABS(LoPricePeriod - Shift(ClsPrice, 1));
  R3 := ABS(HiPricePeriod - Shift(ClsPrice, 1));
  R4 := ALT((R1 > R2), R1, R2);
  TrueRange := ALT((R3 > R4), R3, R4);
  TrueRangeUp := ALT((ClsPrice > SHIFT(ClsPrice, ShiftBack)), TrueRange, ZeroVector);
  TrueRangeDwn := ALT((ClsPrice < SHIFT(ClsPrice, ShiftBack)), TrueRange, ZeroVector);
  if (W1orE2 = 1) then
    TRfastUp := MAVW(TrueRangeUp, FastMA);
    TRfastDwn := MAVW(TrueRangeDwn, FastMA);
    TRslowUp := MAVW(TrueRangeUp, SlowMA);
    TRslowDwn := MAVW(TrueRangeDwn, SlowMA);
  else
    TRfastUp := MAVX(TrueRangeUp, FastMA);
    TRfastDwn := MAVX(TrueRangeDwn, FastMA);
    TRslowUp := MAVX(TrueRangeUp, SlowMA);
    TRslowDwn := MAVX(TrueRangeDwn, SlowMA);
  end;
  FastDiff := (TRfastUp - TRfastDwn);
  SlowDiff := (TRslowUp - TRslowDwn);
  FGraw := (FastDiff - SHIFT(SlowDiff, ShiftBack));
  if (W1orE2 = 1) then
    FearGreed := MAVW(FGraw, SmoothMA);
  else
    FearGreed := MAVX(FGraw, SmoothMA);
  end;
  TotPeriod := LEN(FearGreed) - 1;
  // Depending on the current time period (M, W or D), the corresponding period for MIN and MAX is set.
  if TimeUnit(TimeVec) = 2 then
    i := 822;
  else
    if TimeUnit(TimeVec) = 3 then
      i := 182;
    else
      i := 42;
    end;
  end;
  if i > TotPeriod then
    i := TotPeriod - 5;
  end;
  R1 := Std.MAX(FearGreed, i);
  R4 := Std.MIN(FearGreed, i);
  LinBuy := (R1[TotPeriod] * BuyLevel) / 100;
  LinSell := (R4[TotPeriod] * SellLevel) / 100;
  b2 := (b1 = TRUE);
  s2 := (s1 = TRUE);
  Buy := FilterBuy(b2, s2);
  Sell := FilterSell(b2, s2);
  i := std.GetBuySellAge(Buy, Sell, BuyAge, SellAge);
  ChangePct := DiffFromSignal(Buy OR Sell, ClsPrice);
END;
EDIT(added): Mehul & others, sorry I haven't answered your PM's, but I need at least 5 post to do so, and I don't want to spam this forum with unimportant posts, just to be allowed to answer a PM.

Reply With Quote
Thanked by:
  #25 (permalink)
PegasusDK
Odense, Denmark
 
Posts: 5 since Oct 2011
Thanks Given: 1
Thanks Received: 10

Hi all,

Well, it went a bit faster than I expected ;-)
It was pretty tricky to convert the code to Excel, but it should work now.

The Excel sheet is zipped, no password, no macros.
It was written in the danish version of Excel 2007. I guess it will convert automatically to the target language...

Best regards to you all!

Attached Files
Elite Membership required to download: FearGreedTrender_BMT.zip
Reply With Quote
Thanked by:
  #26 (permalink)
Mehul
London, united kingdom
 
Posts: 27 since Nov 2011
Thanks Given: 2
Thanks Received: 3

great work ... i will see how it works with my data and let you know....

Reply With Quote
  #27 (permalink)
frankfurtm
Sao Paulo/Brasil
 
Posts: 1 since Mar 2012
Thanks Given: 0
Thanks Received: 0


PegasusDK View Post
Hi Fat Tails,

I am very interested in getting more details about your progress with this Fear/Greed "twin".
I've been working on re-engineering both the Bloomberg Trender and the Fear/Greed-indicator for a while, so far with succes as for the Trender overlay, but I get stuck calculating the F/G.
I would be very happy if you could elaborate your work so far...

Regarding the Trender, I would be glad to provide the code and/or method.
I'm not an NT programmer (I code solely in Vikingen, a Scandinavian TA software package), so please advise me where to put it (forum/thread), if you want it.

Best regards
PegasusDK

Hi Pegasus, i would like to take a look at the bbg trender method pls.

Reply With Quote
  #28 (permalink)
 tradermark2009 
Concord, CA
 
Experience: Intermediate
Platform: Sierra Charts and NT7
Broker: AMP/CQG
Trading: Mini's and CL
Posts: 230 since Oct 2009
Thanks Given: 975
Thanks Received: 276

Hi Fat Tails, could you please post the code for this.....I am not a coder so it would be great if you could post this ....please


Fat Tails View Post
Just had a look at the picture. I love that type of challenge. Rebuilding an indicator without knowing the formula. This is the approach I followed:

-> calculated two range series from the average true range, one from upcloses, the other one from down closes
-> used a fast period to calculate a weighted moving average from both series
-> use a slow period to calculate a weighted moving average from both series, but shift them first by n bars
-> then calculate a MACD type indicator from the four weighted moving averages

The result is an indicator, which is similar to Bloomberg's Fear Greed Oscillator, but not identical. Personally I feel that it looks better than the Bloomberg indicator, so I am happy that I have not created any copy. This is still work in progress, so I do not post it here. Might create an elite thread later.

Applied it to AAPL just to compare it with the other screenshot.



Reply With Quote
  #29 (permalink)
Rock Sexton
Scottsdale
 
Posts: 120 since Feb 2012
Thanks Given: 33
Thanks Received: 96


PegasusDK View Post
I've promised a sample spread sheet with the fear/greed and the Trender, but this one will be delayed due to my other activities the next month or so.
I've then decided to put my code to Vikingen here, as it's much easier for me.
If you have any questions about the code, please put them here.

Here goes...

 
Code
par(Main             : Instrument;
    MidPointEMAlen   : Integer;     // Parameters for Trender
    TrueRangeEMAlen  : Integer;
    StdDevPeriod     : Integer;
    StdDevFactor     : Real;
    UseClose         : Boolean;
    W1orE2           : Integer;     // Parameters for FearGreed
    FastMA           : Integer;
    SlowMA           : Integer;
    ShiftBack        : Integer;     // Also used for the TrueRange over "ShiftBack" periods
    SmoothMA         : Integer;
    BuyLevel,
    SellLevel        : Real;
    Out TrenderRes,
        TrenderSup   : RealVector;
    Out FearGreed    : RealVector;
    Out LinZero,
        LinBuy,
        LinSell      : RealVector;
    Out ChangePct    : RealVector;
    Out BuyAge,
        SellAge      : RealVector;
    Out Buy, Sell    : BooleanVector);

var i,
    Lengde,
    StartPos,
    TotPeriod        : Integer;
    Support          : Boolean;
    r1, r2,
    r3, r4           : RealVector;
    StdDevTrueRange  : RealVector;
    MidPoint,
    AdjMidPoint      : RealVector;
    Trender,
    HiPrice,
    LoPrice,
    ClsPrice,
    HiPricePeriod,
    LoPricePeriod    : RealVector;
    ZeroVector,
    UnDefVector      : RealVector;
    TrueRange,
    TrueRangeUp,
    TrueRangeEMA,
    TrueRangeDwn     : RealVector;
    TRfastUp,
    TRfastDwn,
    TRslowUp,
    TRslowDwn        : RealVector;
    FGraw,
    FastDiff,
    SlowDiff         : RealVector;
    b1, s1,
    b2, s2           : BooleanVector;

BEGIN
  LinZero := 0;
  ZeroVector := 0;
  StartPos := 14;
  HiPrice := FILL(Main.High);
  LoPrice := FILL(Main.Low);
  ClsPrice := FILL(Main.Close);
  Lengde := LEN(ClsPrice) - 1;
  // Calculate True Range
  R1 := HiPrice - LoPrice;
  R2 := ABS(LoPrice - Shift(ClsPrice, 1));
  R3 := ABS(HiPrice - Shift(ClsPrice, 1));
  R4 := ALT((R1 > R2), R1, R2);
  TrueRange := ALT((R3 > R4), R3, R4);
  TrueRangeEMA := MAVX(TrueRange, TrueRangeEMAlen);
  StdDevTrueRange := STDEV(TrueRangeEMA, StdDevPeriod);
  MidPoint := (LoPrice + HiPrice) / 2;
  AdjMidPoint := MAVX(MidPoint, MidPointEMAlen) + (TrueRangeEMA / 2);
  AdjMidPoint := AdjMidPoint + (StdDevTrueRange * StdDevFactor);
  // Calculate support and resistance lines for the Trender
  //---------------------------------------------------------
  TrenderRes := AdjMidPoint;
  TrenderSup := MAVX(MidPoint, MidPointEMAlen) - (TrueRangeEMA / 2);
  TrenderSup := TrenderSup - (StdDevTrueRange * StdDevFactor);
  // Find initial direction = the active Trender
  Support := (ClsPrice[StartPos] > TrenderRes[StartPos]);
  i := StartPos;
  Loop;
    i := i + 1;
    if (i > Lengde) then Exit; end;
    if Support then
      if (TrenderSup[i-1] > TrenderSup[i]) then
        TrenderSup[i] := TrenderSup[i-1];
      end;
      if (ClsPrice[i] < TrenderSup[i]) then
        // Make TrenderRes the new Trender => go from buy to sell
        s1[i] := TRUE;
        Support := FALSE;
        Trender[i] := TrenderRes[i];
      else
        b1[i] := TRUE;
        Trender[i] := TrenderSup[i];
      end;
    else
      if (TrenderRes[i-1] < TrenderRes[i]) then
        TrenderRes[i] := TrenderRes[i-1];
      end;
      if (ClsPrice[i] > TrenderRes[i]) then
        // Make TrenderSup the new Trender => go from sell to buy
        b1[i] := TRUE;
        Support := TRUE;
        Trender[i] := TrenderSup[i];
      else
        s1[i] := TRUE;
        Trender[i] := TrenderRes[i];
      end;
    end;
  end;  // Loop...
  TrenderRes := ALT((s1 = TRUE), Trender, UnDefVector);
  TrenderSup := ALT((b1 = TRUE), Trender, UnDefVector);
  // Calculate FearGreed
  //---------------------
  LoPricePeriod := Std.MIN(LoPrice, ShiftBack);
  HiPricePeriod := Std.MAX(HiPrice, ShiftBack);
  // Calculate new TrueRange for "ShiftBack" periods
  R1 := HiPricePeriod - LoPricePeriod;
  R2 := ABS(LoPricePeriod - Shift(ClsPrice, 1));
  R3 := ABS(HiPricePeriod - Shift(ClsPrice, 1));
  R4 := ALT((R1 > R2), R1, R2);
  TrueRange := ALT((R3 > R4), R3, R4);
  TrueRangeUp := ALT((ClsPrice > SHIFT(ClsPrice, ShiftBack)), TrueRange, ZeroVector);
  TrueRangeDwn := ALT((ClsPrice < SHIFT(ClsPrice, ShiftBack)), TrueRange, ZeroVector);
  if (W1orE2 = 1) then
    TRfastUp := MAVW(TrueRangeUp, FastMA);
    TRfastDwn := MAVW(TrueRangeDwn, FastMA);
    TRslowUp := MAVW(TrueRangeUp, SlowMA);
    TRslowDwn := MAVW(TrueRangeDwn, SlowMA);
  else
    TRfastUp := MAVX(TrueRangeUp, FastMA);
    TRfastDwn := MAVX(TrueRangeDwn, FastMA);
    TRslowUp := MAVX(TrueRangeUp, SlowMA);
    TRslowDwn := MAVX(TrueRangeDwn, SlowMA);
  end;
  FastDiff := (TRfastUp - TRfastDwn);
  SlowDiff := (TRslowUp - TRslowDwn);
  FGraw := (FastDiff - SHIFT(SlowDiff, ShiftBack));
  if (W1orE2 = 1) then
    FearGreed := MAVW(FGraw, SmoothMA);
  else
    FearGreed := MAVX(FGraw, SmoothMA);
  end;
  TotPeriod := LEN(FearGreed) - 1;
  // Depending on the current time period (M, W or D), the corresponding period for MIN and MAX is set.
  if TimeUnit(TimeVec) = 2 then
    i := 822;
  else
    if TimeUnit(TimeVec) = 3 then
      i := 182;
    else
      i := 42;
    end;
  end;
  if i > TotPeriod then
    i := TotPeriod - 5;
  end;
  R1 := Std.MAX(FearGreed, i);
  R4 := Std.MIN(FearGreed, i);
  LinBuy := (R1[TotPeriod] * BuyLevel) / 100;
  LinSell := (R4[TotPeriod] * SellLevel) / 100;
  b2 := (b1 = TRUE);
  s2 := (s1 = TRUE);
  Buy := FilterBuy(b2, s2);
  Sell := FilterSell(b2, s2);
  i := std.GetBuySellAge(Buy, Sell, BuyAge, SellAge);
  ChangePct := DiffFromSignal(Buy OR Sell, ClsPrice);
END;
EDIT(added): Mehul & others, sorry I haven't answered your PM's, but I need at least 5 post to do so, and I don't want to spam this forum with unimportant posts, just to be allowed to answer a PM.

Anyone now how to convert this to Tradestation easy language?

Reply With Quote
  #30 (permalink)
 SPMC 
GER
 
Experience: Advanced
Platform: MC
Trading: ES
Posts: 144 since May 2011
Thanks Given: 11
Thanks Received: 213



Rock Sexton View Post
Anyone now how to convert this to Tradestation easy language?

Search for Jan Arps Fear / Greed : Arps Fear /Greed Indicator Radar1 (TS) - YouTube




Reply With Quote




Last Updated on January 16, 2013


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts