Moving average and vix price above/below FisherTransform signal strategy?

Superfast

New member
Good day, I have been trying to build a strategy around the fishertransformationsignal. However, the buy signal must only be taken IF the price is above the 55 period moving average and the price of VIX is below the mean for the last 55 periods. I have been working this for the last few days and its not working. Can someone assist?
Code:
## Archive Name: TrueMomentumOscilWithFisher_v04_JQ
## Archive Section:
## Suggested Tos Name: TrueMomentumOscilWithFisher_v04_JQ
## Archive Date: 10.6.2018
## Archive Notes:

#  v02 JQ added FE code to generate points
#  v03 JQ added FisherTransform crossover arrows to confirm TMO
#  v04 JQ Remoed all Fractal Energy code
## "##" indicates an addition by the Archivist



# TMO ((T)rue (M)omentum (O)scilator)
# Mobius
# V01.05.2018
#hint: TMO calculates momentum using the delta of price. Giving a much better picture of trend, tend reversals and divergence than momentum oscillators using price.

input length = 14;
input calcLength = 5;
input smoothLength = 3;
input displayFisherLabels = no;

def o = open;
def c = close;
def data = fold i = 0 to length
with s
do s + (if c > GetValue(o, i)
then 1
else if c < GetValue(o, i)
then - 1
else 0);
def EMA5 = ExpAverage(data, calcLength);
def Main = ExpAverage(EMA5, smoothLength);
def Signal = ExpAverage(Main, smoothLength);
#Main.AssignValueColor(if Main > Signal
#then Color.GREEN
#else Color.RED);
#Signal.AssignValueColor(if Main > Signal
#then Color.GREEN
#else Color.RED);
#Signal.HideBubble();
#Signal.HideTitle();
#AddCloud(Main, Signal, Color.GREEN, Color.RED);
#plot zero = if IsNaN(c) then Double.NaN else 0;
#zero.SetDefaultColor(Color.GRAY);
#zero.HideBubble();
#zero.HideTitle();
def ob = if IsNaN(o) then Double.NaN else Round(length * .5);
#ob.SetDefaultColor(Color.GRAY);
#ob.HideBubble();
#ob.HideTitle();
def os = if IsNaN(c) then Double.NaN else -Round(length * .5);
#os.SetDefaultColor(Color.GRAY);
#os.HideBubble();
#os.HideTitle();
#AddCloud(ob, length, Color.LIGHT_RED, Color.LIGHT_RED, no);
#AddCloud(-length, os, Color.LIGHT_GREEN, Color.LIGHT_GREEN);


# End Code TMO



#    JQ_FisherTransform_wLabels  v02
#    assistance provided by AlphaInvestor, amalia, randyr and nube

# v02 9.23.2018  JQ added arrows

input Fisherprice = hl2;
input FisherLength = 10;
input TriggerLineOffset = 1;  # Ehler's value of choice is 1
input TriggerLine_Color_Choice = {"magenta", "cyan", "pink", default "gray", "Mustard", "red", "green", "dark_gray", "Pale Yellow", "white"};
input deBug = no;

input BuyLabelText = " TMO Buy ";
input SellLebelText = " TMO Sell ";

def maxHigh = Highest(Fisherprice, FisherLength);
def minLow = Lowest(Fisherprice, FisherLength);
def range = maxHigh - minLow;
def value = if IsNaN(Fisherprice)
    then Double.NaN
    else if IsNaN(range)
        then value[1]
        else if range == 0
            then 0
            else 0.66 * ((Fisherprice - minLow) / range - 0.5) + 0.67 * value[1];
def truncValue = if value > 0.99 then 0.999 else if value < -0.99 then -0.999 else value;
def fish = 0.5 * (Log((1 + truncValue) / (1 - truncValue)) + fish[1]);
def FTOneBarBack = fish[TriggerLineOffset];
def FT = fish;

def FisherBullCross = if FT crosses above FTOneBarBack then LowestAll(Main) else Double.NaN;
#FisherBullCross.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
#FisherBullCross.SetDefaultColor(Color.UPTICK);

def FisherBearCross = if FT crosses below FTOneBarBack then HighestAll(Main) else Double.NaN;
#FisherBearCross.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
#FisherBearCross.SetDefaultColor(Color.DOWNTICK);


def arrow = if FT crosses above FTOneBarBack then fish else Double.NaN;
#arrow.SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
#arrow.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
#arrow.SetDefaultColor(Color.GREEN);

def arrowD = if FT crosses below FTOneBarBack then fish else Double.NaN;
#arrowD.SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
#arrowD.SetPaintingStrategy(PaintingStrategy.ARROW_Down);
#arrowD.SetDefaultColor(Color.RED);

#AddLabel (displayFisherLabels, "" + if FT >= FTOneBarBack then #BuyLabelText else SellLebelText + "       ",
   # (if FT > FTOneBarBack
   # then Color.LIGHT_GREEN
   # else if FT  < FTOneBarBack
   # then Color.LIGHT_RED
   # else Color.GRAY));

Alert(FisherBullCross, " ", Alert.BAR, Sound.Ring);
Alert(FisherBearCross, " ", Alert.BAR, Sound.Ring);

#------vix-------
input price = FundamentalType.LOW;
input smaLength = 20;

def priceVix = Fundamental(price, "VIX");
def smaVix = Average(priceVix, smaLength);
input n = 55;
def WVF = (Highest (Close, n) - Low) / (Highest(Close, n)) * 100;
  
def mean = inertiaAll(WVF);
    #----------------------

input length1 = 55;
input displace = 0;
input showBreakoutSignals = no;

def SMA = Average(close[-displace], length1);
def UpSignal = price crosses above SMA;
def DownSignal = price crosses below SMA;
#-----------------------------------

AddOrder(OrderType.BUY_AUTO, condition = signal < os and main < os and fisherbullcross, tickcolor = Color.CYAN, arrowcolor = Color.CYAN, name = "Fisher_LE");

Addorder(ordertype.sell_to_close, condition = signal > ob and main > ob and fisherbearcross, name = "Fisher_SE");


AddOrder(OrderType.SELL_AUTO, condition = signal > ob and main > ob and fisherbearcross, tickcolor = Color.CYAN, arrowcolor = Color.CYAN, name = "Fisher_SE");

addorder(ordertype.buy_to_close, condition =  signal < os and main < os and fisherbullcross,name = "Fisher_LE");
 
Last edited by a moderator:
I had actually included it but the same triggers showed up on the charts , so I took it off as it wasn't working. E.g. for the buy order I included just after and close crosses above SimpleMovingAvg("length" = 55)."SMA".....and there were signals that weren't supposed to be on the long side being taken. I'll reinsert it and send the chart as well or I may just do some more work on it. Thx.
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
408 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top