Click here to Login





                                                   Convert TOS Strategy to Quantshare Strategy

  0

0
Ted Penner
2016-01-24 09:36:37


I need to convert this into code for quantshare. Any assistance is greatly appreciated.

declare Once_Per_Bar;

# EMACross
input price = close;
input fastLength = 20;
input slowLength = 50;
input averageType = AverageType.EXPONENTIAL;
plot FastMA = MovingAverage(averageType, price, fastLength);
plot SlowMA = MovingAverage(averageType, price, slowLength);
FastMA.SetDefaultColor(GetColor(1));
SlowMA.SetDefaultColor(GetColor(2));

# ADX Strategy conversion -> Replace 'plot' with 'def', add the line below it, then comment out the GetColor line.

input length = 14;
input ADXaverageType = AverageType.WILDERS;
def ADX = DMI(length, ADXaverageType).ADX;
def ADXCheck = ADX > 20; # Create a filter using the variable we just defined.
#ADX.SetDefaultColor(GetColor(5));

# MACDHistogram Strategy conversion -> Replace 'plot' with 'def' add the line below it, then comment out the lines that begin with 'Diff'.

#plot Diff = MACD(fastLength, slowLength, MACDLength, averageType).Diff;
input MACDfastLength = 12;
input MACDslowLength = 26;
input MACDLength = 9;
input MACDaverageType = AverageType.EXPONENTIAL;
Def Diff = MACD(MACDfastLength, MACDslowLength, MACDLength, MACDaverageType).Diff;
def filterLongMACD = Diff > 0;
def filterShortMACD = Diff < 0;
#Diff.SetDefaultColor(GetColor(5));
#Diff.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
#Diff.SetLineWeight(3);
#Diff.DefineColor("Positive and Up", Color.GREEN);
#Diff.DefineColor("Positive and Down", Color.DARK_GREEN);
#Diff.DefineColor("Negative and Down", Color.RED);
#Diff.DefineColor("Negative and Up", Color.DARK_RED);
#Diff.AssignValueColor(if Diff >= 0 then if Diff > Diff[1] then Diff.Color("Positive and Up") else Diff.Color("Positive and Down") else if Diff < Diff[1] then Diff.Color("Negative and Down") else Diff.Color("Negative and Up"));

# ORDER CONDITIONS

AddOrder(OrderType.BUY_TO_OPEN, FastMA crosses above SlowMA and ADXCheck is true and filterLongMACD is true, tickcolor = GetColor(1), arrowcolor = GetColor(1), name = "LE");

AddOrder(OrderType.SELL_TO_CLOSE, FastMA crosses below SlowMA, tickcolor = GetColor(1), arrowcolor = GetColor(1), name = "LX");



No more messages
0




Reply:

No html code. URLs turn into links automatically.

Type in the trading objects you want to include: - Add Objects
To add a trading object in your message, type in the object name, select it and then click on "Add Objects"










QuantShare

Trading Items
Reverse Collar Option Strategy
Global Market Rotation Strategy V1.4
Global Market Rotation Strategy V1.1
Earnings Surprise Strategy
Staggered Entry and Exit Strategy

How-to Lessons
How to improve the performance of QuantShare databases?
How to run QuantShare offline
How to use QuantShare with Metastock data
How to install the previous version of QuantShare
How to create and trade a Neural Network model

Related Forum Threads
Trading strategy over a socket connection
Capital allocation - total capital is split in Long/Short strateg...
Adding Market Direction Filter to a Strategy
Momemtum Strategy
How to Debug a Strategy using data variables values by day by Tic...

Blog Posts
Optimizing the Strategy Equity Curve
Trading the Strategy Equity Curve
Backtesting a Strategy Based on Bond and Stock Index ETFs
Money Management: Scale-in Trading Strategy
How to turn any ordinary trading strategy into a very profitable ...









QuantShare
Product
QuantShare
Features
Create an account
Affiliate Program
Support
Contact Us
Trading Forum
How-to Lessons
Manual
Company
About Us
Privacy
Terms of Use

Copyright © 2024 QuantShare.com
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
Google+
Follow us on Google+
RSS Trading Items



Trading financial instruments, including foreign exchange on margin, carries a high level of risk and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in financial instruments or foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with trading and seek advice from an independent financial advisor if you have any doubts.