NexusFi: Find Your Edge


Home Menu

 





Polychromatic conversion to trade station


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one anahat with 12 posts (1 thanks)
    2. looks_two Nicolas11 with 6 posts (2 thanks)
    3. looks_3 RM99 with 2 posts (0 thanks)
    4. looks_4 Big Mike with 1 posts (1 thanks)
    1. trending_up 8,641 views
    2. thumb_up 4 thanks given
    3. group 5 followers
    1. forum 22 posts
    2. attach_file 0 attachments




 
Search this Thread

Polychromatic conversion to trade station

  #1 (permalink)
anahat
pinole california
 
Posts: 16 since Jul 2012
Thanks Given: 0
Thanks Received: 1

hello everybody,
You know i found a very interesting indicator while i was on think or swim, currently i am trying to back test the validity of this indicator with trade station but i am having a hell of a time getting the conversion of it..
here is the tos code

declare lower;

input price = close;
input length = 8;
input bxo = 0.2;
input sxo = -0.04;

def num = fold indexN = 1 to length + 1 with accuN do accuN + (price - getValue(price, indexN, length)) / Sqrt(indexN);
def denom = fold indexD = 1 to length + 1 with accuD do accuD + Sqrt(indexD);

i get all the basics of it ie.. def num . sxo .. bxo sqrt, but what i am having trouble with is the index and accu functions

i would appreciate the help guys thanks...

Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
How to apply profiles
Traders Hideout
About a successful futures trader who didnt know anythin …
Psychology and Money Management
MC PL editor upgrade
MultiCharts
Trade idea based off three indicators.
Traders Hideout
 
  #3 (permalink)
 
Nicolas11's Avatar
 Nicolas11 
near Paris, France
 
Experience: Beginner
Platform: -
Trading: -
Posts: 1,071 since Aug 2011
Thanks Given: 2,232
Thanks Received: 1,769


Hi,

Some initial disclaimers:

- I have never used ThinkOrSwim. I have just found the syntax of fold and getValue on Internet.

- I am not sure to have understood the syntax of getValue.

- I have never used TradeStation. The code below is for MultiCharts. But should be the same.

- Due to the above, you absolutely need to compare ThinkOrSwim results and Trade Station results, in order to check that there is no coding error.

- The code below could be optimized a little (less variables). But I wanted to better show the correspondence in the conversion.

ThinkOrSwim:
 
Code
input price = close;
input length = 8;
def num = fold indexN = 1 to length + 1 with accuN do accuN + (price - getValue(price, indexN, length)) / Sqrt(indexN);
def denom = fold indexD = 1 to length + 1 with accuD do accuD + Sqrt(indexD);
Possible code for MultiCharts / Trade Station:
 
Code
Inputs:
	price	( Close ),
	length	( 8 );
	
Variables:
	num		( 0 ),
	indexN		( 0 ),
	accuN		( 0 ),
	denom		( 0 ),
	indexD		( 0 ),
	accuD		( 0 ),
	offset		( 0 );
	
accuN = 0;
for indexN = 1 to length+1 begin
	if indexN > length then offset = length else offset = indexN;
	accuN = accuN + (price - price[offset]) / SquareRoot(indexN);
end;
num = accuN;

accuD = 0;
for indexD = 1 to length+1 begin
	accuD = accuD + SquareRoot(indexD);
end;
denom = accuD;
Nicolas

Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #4 (permalink)
 RM99 
Austin, TX
 
Experience: Advanced
Platform: TradeStation
Trading: Futures
Posts: 839 since Mar 2011
Thanks Given: 124
Thanks Received: 704

So what is the output/plot? "denom"?

"A dumb man never learns. A smart man learns from his own failure and success. But a wise man learns from the failure and success of others."
Reply With Quote
  #5 (permalink)
anahat
pinole california
 
Posts: 16 since Jul 2012
Thanks Given: 0
Thanks Received: 1

thanks nicolas i am going to get this into tradestation double check today and you know what i am a even going to post the stats of this indicator here prolly tonight

Reply With Quote
  #6 (permalink)
anahat
pinole california
 
Posts: 16 since Jul 2012
Thanks Given: 0
Thanks Received: 1

oh and output plot = num/denom

Reply With Quote
  #7 (permalink)
anahat
pinole california
 
Posts: 16 since Jul 2012
Thanks Given: 0
Thanks Received: 1

declare lower;

input price = close;
input length = 8;
input bxo = 0.2;
input sxo = -0.04;

def num = fold indexN = 1 to length + 1 with accuN do accuN + (price - getValue(price, indexN, length)) / Sqrt(indexN);
def denom = fold indexD = 1 to length + 1 with accuD do accuD + Sqrt(indexD);

plot PM = num / denom;
plot BuyLevel = bxo;
plot SellLevel = sxo;

PM.SetDefaultColor(GetColor(8));
BuyLevel.SetDefaultColor(GetColor(5));
SellLevel.SetDefaultColor(GetColor(1));


here is the whole script i apologize friends..

Reply With Quote
  #8 (permalink)
anahat
pinole california
 
Posts: 16 since Jul 2012
Thanks Given: 0
Thanks Received: 1

sorry to keep posting but here is the completed code
inputs:
Price( Close ),
Length( 8 ),

GridForegroundColor( Black ) ; { Color to use for numbers in RadarScreen cells
when gradient coloring is enabled, that is, when both UpColor and DnColor are
set to non-negative values. }
{ Set either UpColor and/or DnColor to -1 to disable gradient plot coloring.
When disabled, Plot1 color is determined by settings in indicator properties
dialog box. Plot2 (ZeroLine) color always comes from indicator properties
dialog box. }



Variables:
num ( 0 ),
indexN ( 0 ),
accuN ( 0 ),
denom ( 0 ),
indexD ( 0 ),
accuD ( 0 ),
offset ( 0 ),
Pm ( 0 );
accuN = 0;
for indexN = 1 to length+1 begin
if indexN > length then offset = length else offset = indexN;
accuN = accuN + (price - price[offset]) / SquareRoot(indexN);
end;
num = accuN;

accuD = 0;
for indexD = 1 to length+1 begin
accuD = accuD + SquareRoot(indexD);
end;
denom = accuD;

Plot1( num/Denom, "Momentum" );
plot2(.2,"sxo",Red);
Plot3(-.04,"Bxo",Cyan);

Reply With Quote
  #9 (permalink)
anahat
pinole california
 
Posts: 16 since Jul 2012
Thanks Given: 0
Thanks Received: 1

so these are the results on apple daily charts for 3 years.. i started with an account balance of 50,000 and allowed a max allocation of 10,000 dollars per trade and these are for long entries only not short entries i havent gotten to short entry programming yet

buy at .2 sell at -.04 might need another filter to improve accuracy
TradeStation Performance Summary

All Trades
Long Trades
Short Trades

Total Net Profit $36,187.00 $36,187.00 $0.00
Gross Profit $55,050.00 $55,050.00 $0.00
Gross Loss ($18,863.00) ($18,863.00) $0.00
Profit Factor 2.92 2.92 n/a

Roll Over Credit $0.00 $0.00 $0.00
Open Position P/L $1,865.00 $1,865.00 $0.00

Select Total Net Profit $31,074.00 $31,074.00 $0.00
Select Gross Profit $45,465.00 $45,465.00 $0.00
Select Gross Loss ($14,391.00) ($14,391.00) $0.00
Select Profit Factor 3.16 3.16 n/a

Adjusted Total Net Profit $22,278.12 $22,278.12 $0.00
Adjusted Gross Profit $45,162.73 $45,162.73 $0.00
Adjusted Gross Loss ($22,884.61) ($22,884.61) $0.00
Adjusted Profit Factor 1.97 1.97 n/a

Total Number of Trades 67 67 0
Percent Profitable 46.27% 46.27% 0.00%
Winning Trades 31 31 0
Losing Trades 22 22 0
Even Trades 14 14 0

Avg. Trade Net Profit $540.10 $540.10 $0.00
Avg. Winning Trade $1,775.81 $1,775.81 $0.00
Avg. Losing Trade ($857.41) ($857.41) $0.00
Ratio Avg. Win:Avg. Loss 2.07 2.07 n/a
Largest Winning Trade $9,585.00 $9,585.00 $0.00
Largest Losing Trade ($4,472.00) ($4,472.00) $0.00
Largest Winner as % of Gross Profit 17.41% 17.41% n/a
Largest Loser as % of Gross Loss 23.71% 23.71% n/a

Net Profit as % of Largest Loss 809.19% 809.19% n/a
Select Net Profit as % of Largest Loss 694.86% 694.86% n/a
Adjusted Net Profit as % of Largest Loss 498.17% 498.17% n/a

Max. Consecutive Winning Trades 6 6 0
Max. Consecutive Losing Trades 4 4 0
Avg. Bars in Total Trades 9.31 9.31 0.00
Avg. Bars in Winning Trades 12.42 12.42 0.00
Avg. Bars in Losing Trades 10.23 10.23 0.00
Avg. Bars in Even Trades 1.00 1.00 0.00

Max. Shares/Contracts Held 100 100 0
Total Shares/Contracts Held 6800 6800 0
Account Size Required $5,775.00 $5,775.00 $0.00
Total Slippage $0.00 $0.00 $0.00
Total Commission $0.00 $0.00 $0.00

Return on Initial Capital 36.19%
Annual Rate of Return 11.03%
Buy & Hold Return 223.04%
Return on Account 626.61%
Avg. Monthly Return $1,119.18
Std. Deviation of Monthly Return $2,344.43

Return Retracement Ratio 0.50
RINA Index 32.96
Sharpe Ratio 0.40
K-Ratio 2.49

Trading Period 2 Yrs, 9 Mths, 18 Dys
Percent of Time in the Market 79.67%
Time in the Market 2 Yrs, 2 Mths, 23 Dys
Longest Flat Period 30 Dys

Max. Equity Run-up $40,844.00
Date of Max. Equity Run-up 04/10/12 13:00
Max. Equity Run-up as % of Initial Capital 40.84%

Max. Drawdown (Intra-day Peak to Valley)
Value ($11,534.00) ($11,534.00) $0.00
Date 05/18/12 13:00
as % of Initial Capital 11.53% 11.53% 0.00%
Net Profit as % of Drawdown 313.74% 313.74% n/a
Select Net Profit as % of Drawdown 269.41% 269.41% n/a
Adjusted Net Profit as % of Drawdown 193.15% 193.15% n/a

Max. Drawdown (Trade Close to Trade Close)
Value ($5,775.00) ($5,775.00) $0.00
Date 05/22/12 13:00
as % of Initial Capital 5.78% 5.78% 0.00%
Net Profit as % of Drawdown 626.61% 626.61% n/a
Select Net Profit as % of Drawdown 538.08% 538.08% n/a
Adjusted Net Profit as % of Drawdown 385.77% 385.77% n/a

Max. Trade Drawdown ($8,561.00) ($8,561.00) $0.00



All Trades

Total Net Profit $36,187.00 Profit Factor 2.92
Gross Profit $55,050.00 Gross Loss ($18,863.00)

Roll Over Credit $0.00
Open Position Profit/Loss $1,865.00

Select Total Net Profit $31,074.00 Select Profit Factor 3.16
Select Gross Profit $45,465.00 Select Gross Loss ($14,391.00)

Adjusted Total Net Profit $22,278.12 Adjusted Profit Factor 1.97
Adjusted Gross Profit $45,162.73 Adjusted Gross Loss ($22,884.61)

Total Number of Trades 67 Percent Profitable 46.27%
Winning Trades 31 Losing Trades 22
Even Trades 14

Avg. Trade Net Profit $540.10 Ratio Avg. Win:Avg. Loss 2.07
Avg. Winning Trade $1,775.81 Avg. Losing Trade ($857.41)
Largest Winning Trade $9,585.00 Largest Losing Trade ($4,472.00)
Largest Winner as % of Gross Profit 17.41% Largest Loser as % of Gross Loss 23.71%

Net Profit as % of Largest Loss 809.19%
Slct. Net Profit as % of Largest Loss 694.86% Adj. Net Profit as % of Largest Loss 498.17%

Max. Consecutive Winning Trades 6 Max. Consecutive Losing Trades 4
Avg. Bars in Winning Trades 12.42 Avg. Bars in Losing Trades 10.23
Avg. Bars in Total Trades 9.31

Max. Shares/Contracts Held 100 Account Size Required $5,775.00
Total Commission $0.00 Total Slippage $0.00

Return on Initial Capital 36.19% Annual Rate of Return 11.03%
Buy and Hold Return 223.04% Return on Account 626.61%
Avg. Monthly Return $1,119.18 Std. Deviation of Monthly Return $2,344.43

Return Retracement Ratio 0.50 RINA Index 32.96
Sharpe Ratio 0.40 K-Ratio 2.49

Trading Period 2 Yrs, 9 Mths, 18 Dys Percent of Time in the Market 79.67%
Time in the Market 2 Yrs, 2 Mths, 23 Dys Longest Flat Period 30 Dys

Max. Equity Run-up $40,844.00
Date of Max. E. Run-up 04/10/12 13:00 Max. E. Run-up as % of Initial Capital 40.84%

Max. Drawdown (Intra-day Peak to Valley)
Max. Drawdown (Trade Close to Trade Close)

Value ($11,534.00) Value ($5,775.00)
Date 05/18/12 13:00 Date 05/22/12 13:00
as % of Initial Capital 11.53% as % of Initial Capital 5.78%
Net Profit as % of Drawdown 313.74% Net Profit as % of Drawdown 626.61%
Slct. Net Profit as % of Drawdown 269.41% Slct. Net Profit as % of Drawdown 538.08%
Adj. Net Prof as % of Drawdown 193.15% Adj. Net Profit as % of Drawdown 385.77%

Max. Trade Drawdown ($8,561.00)

Long Trades

Total Net Profit $36,187.00 Profit Factor 2.92
Gross Profit $55,050.00 Gross Loss ($18,863.00)

Roll Over Credit $0.00
Open Position Profit/Loss $1,865.00

Select Total Net Profit $31,074.00 Select Profit Factor 3.16
Select Gross Profit $45,465.00 Select Gross Loss ($14,391.00)

Adjusted Total Net Profit $22,278.12 Adjusted Profit Factor 1.97
Adjusted Gross Profit $45,162.73 Adjusted Gross Loss ($22,884.61)

Total Number of Trades 67 Percent Profitable 46.27%
Winning Trades 31 Losing Trades 22
Even Trades 14

Avg. Trade Net Profit $540.10 Ratio Avg. Win:Avg. Loss 2.07
Avg. Winning Trade $1,775.81 Avg. Losing Trade ($857.41)
Largest Winning Trade $9,585.00 Largest Losing Trade ($4,472.00)
Largest Winner as % of Gross Profit 17.41% Largest Loser as % of Gross Loss 23.71%

Max. Consecutive Winning Trades 6 Max. Consecutive Losing Trades 4
Avg. Bars in Winning Trades 12.42 Avg. Bars in Losing Trades 10.23
Avg. Bars in Total Trades 9.31

Max. Shares/Contracts Held 100 Account Size Required $5,775.00
Total Commission $0.00 Total Slippage $0.00

Net Profit as % of Largest Loss 809.19%
Slct. Net Profit as % of Largest Loss 694.86% Adj. Net Profit as % of Largest Loss 498.17%

Max. Drawdown (Intra-day Peak to Valley)
Max. Drawdown (Trade Close to Trade Close)

Value ($11,534.00) Value ($5,775.00)
as % of Initial Capital 11.53% as % of Initial Capital 5.78%
Net Profit as % of Drawdown 313.74% Net Profit as % of Drawdown 626.61%
Slct. Net Profit as % of Drawdown 269.41% Slct. Net Profit as % of Drawdown 538.08%
Adj. Net Prof as % of Drawdown 193.15% Adj. Net Profit as % of Drawdown 538.08%

Max. Trade Drawdown ($8,561.00)

Short Trades

Total Net Profit $0.00 Profit Factor n/a
Gross Profit $0.00 Gross Loss $0.00

Roll Over Credit $0.00
Open Position Profit/Loss $0.00

Select Total Net Profit $0.00 Select Profit Factor n/a
Select Gross Profit $0.00 Select Gross Loss $0.00

Adjusted Total Net Profit $0.00 Adjusted Profit Factor n/a
Adjusted Gross Profit $0.00 Adjusted Gross Loss $0.00

Total Number of Trades 0 Percent Profitable 0.00%
Winning Trades 0 Losing Trades 0
Even Trades 0

Avg. Trade Net Proft $0.00 Ratio Avg. Win:Avg. Loss n/a
Avg. Winning Trade $0.00 Avg. Losing Trade $0.00
Largest Winning Trade $0.00 Largest Losing Trade $0.00
Largest Winner as % of Gross Profit n/a Largest Loser as % of Gross Loss 23.71%

Max. Consecutive Winning Trades 0 Max. Consecutive Losing Trades 0
Avg. Bars in Winning Trades 0.00 Avg. Bars in Losing Trades 0.00
Avg. Bars in Total Trades 0.00

Max. Shares/Contracts Held 0 Account Size Required $0.00
Total Slippage $0.00 Total Commission $0.00

Net Profit as % of Largest Loss n/a
Slct. Net Profit as % of Largest Loss n/a Adj. Net Profit as % of Largest Loss n/a

Max. Drawdown (Intra-day Peak to Valley)
Max. Drawdown (Trade Close to Trade Close)

Value $0.00 Value $0.00
as % of Initial Capital 0.00% as % of Initial Capital 0.00%
Net Profit as % of Drawdown n/a Net Profit as % of Drawdown n/a
Slct. Net Profit as % of Drawdown n/a Slct. Net Profit as % of Drawdown n/a
Adj. Net Prof as % of Drawdown n/a Adj. Net Prof as % of Drawdown n/a

Max. Trade Drawdown $0.00



of note i wonder if there is a command that lets you buy a certain option at the time of long entry

Reply With Quote
  #10 (permalink)
 
Nicolas11's Avatar
 Nicolas11 
near Paris, France
 
Experience: Beginner
Platform: -
Trading: -
Posts: 1,071 since Aug 2011
Thanks Given: 2,232
Thanks Received: 1,769


When you say "max allocation of 10,000 dollars per trade", what do you mean?
Is it the size of the position? of the margin required? of the stop-loss?

Visit my NexusFi Trade Journal Reply With Quote




Last Updated on February 24, 2018


© 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