Fear/Greed Indicator - NinjaTrader Programming | futures io social day trading
futures io futures trading


Fear/Greed Indicator
Updated: Views / Replies:14,971 / 31
Created: by Loukas Attachments:8

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors – all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you don’t need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 8  
 
Thread Tools Search this Thread
 

Fear/Greed Indicator

  #21 (permalink)
Elite Member
Berlin, Europe
 
Futures Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker/Data: Interactive Brokers
Favorite Futures: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,651 since Mar 2010
Thanks: 4,226 given, 25,597 received
Forum Reputation: Legendary


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
 
  #22 (permalink)
Trading Apprentice
Odense, Denmark
 
Futures Experience: Advanced
Platform: Vikingen, BCview
Favorite Futures: Stocks & ETF's (DK+SE)
 
Posts: 5 since Oct 2011
Thanks: 1 given, 10 received

Example in Excel, sure!

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)
Trading Apprentice
London, united kingdom
 
Futures Experience: Intermediate
Platform: Stellar
Favorite Futures: Spread trading / pairs trading
 
Posts: 27 since Nov 2011
Thanks: 2 given, 3 received


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)
Trading Apprentice
Odense, Denmark
 
Futures Experience: Advanced
Platform: Vikingen, BCview
Favorite Futures: Stocks & ETF's (DK+SE)
 
Posts: 5 since Oct 2011
Thanks: 1 given, 10 received

Code for fear/greed

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.


Last edited by PegasusDK; November 27th, 2011 at 05:35 PM. Reason: Missed something...
Reply With Quote
The following 3 users say Thank You to PegasusDK for this post:
 
  #25 (permalink)
Trading Apprentice
Odense, Denmark
 
Futures Experience: Advanced
Platform: Vikingen, BCview
Favorite Futures: Stocks & ETF's (DK+SE)
 
Posts: 5 since Oct 2011
Thanks: 1 given, 10 received

Bloomberg FearGreed and Trender in MS Excel - at last!

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
Register to download File Type: zip FearGreedTrender_BMT.zip (1.45 MB, 310 views)
Reply With Quote
The following 4 users say Thank You to PegasusDK for this post:
 
  #26 (permalink)
Trading Apprentice
London, united kingdom
 
Futures Experience: Intermediate
Platform: Stellar
Favorite Futures: Spread trading / pairs trading
 
Posts: 27 since Nov 2011
Thanks: 2 given, 3 received

thank you pegasus

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

Reply With Quote
 
  #27 (permalink)
Trading Apprentice
Sao Paulo/Brasil
 
Futures Experience: Intermediate
Platform: TradeStation
Favorite Futures: oil
 
Posts: 1 since Mar 2012
Thanks: 0 given, 0 received


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)
Elite Member
Concord, CA
 
Futures Experience: Intermediate
Platform: Sierra Charts and NT7
Broker/Data: AMP/CQG
Favorite Futures: Mini's and CL
 
Posts: 225 since Oct 2009
Thanks: 927 given, 272 received

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.

Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).


Reply With Quote
 
  #29 (permalink)
Trading for Fun
Scottsdale
 
Futures Experience: Intermediate
Platform: ThinkorSwim
Favorite Futures: Stocks
 
Posts: 120 since Feb 2012
Thanks: 33 given, 96 received


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)
Elite Member
GER
 
Futures Experience: Advanced
Platform: MC
Favorite Futures: ES
 
Posts: 144 since May 2011
Thanks: 11 given, 211 received



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

Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).


Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).

Reply With Quote

Reply



futures io > > > > > Fear/Greed Indicator

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Linda Bradford Raschke: Reading The Tape

Elite only

Adam Grimes: TBA

Elite only

NinjaTrader: TBA

January

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
How does one deal with greed? tellytub Psychology and Money Management 13 March 30th, 2016 07:06 PM
The Psychology of Greed liquidcci Psychology and Money Management 9 September 25th, 2011 09:22 PM
MOODY'S ANALYST BREAKS SILENCE : Conflicts, Corruption, And Greed kbit News and Current Events 1 August 19th, 2011 04:51 PM
Stock Market Investors Battle Fear, Fear and Fear Quick Summary News and Current Events 0 August 11th, 2011 06:10 AM
Using Greed—and Lots of Cash—to Fight Against Greed Quick Summary News and Current Events 0 February 8th, 2011 07:20 PM


All times are GMT -4. The time now is 09:39 AM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts
Page generated 2017-12-11 in 0.17 seconds with 20 queries on phoenix via your IP 54.226.227.175