TSM5 Regression with bands code conversion request.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #126538 quote
    tapetkabinett
    Participant
    New
    { TSM5 Regression with bands
    	Copyright 2011, P.J.Kaufman. All rights reserved. }
    	
    	inputs: 	period(20), bandwidth(2.0);
    	vars:		slope(0), lrvalue(0), resid(0), sdresid(0), angle(0),
    				intercept(0), upperband(0), lowerband(0), size(0), investment(25000);
    	
    	Value1 = LinearReg( close, period, currentbar, slope, angle, intercept, 
     				lrvalue ) ;
    {	slope = LinearRegSlope(close,period);
    	lrvalue = linearRegValue(close,period,currentbar);}
    	resid = Close - lrvalue;
    	
    	If Currentbar > period then begin
    { position size }
    		size = investment / (avgtruerange(30)*bigpointvalue);
    		size = maxlist(size,1);
    		sdresid = stddev(close,period);
    		Upperband = lrvalue + slope + bandwidth*sdresid;
    		Lowerband = lrvalue + slope - bandwidth*sdresid;
    {		plot1(upperband,"UB");
    		Plot2(lowerband,"LB");
    }		plot3(lrvalue,"LR");
    		
    {		If Close > upperband[1] then buy size contracts this bar on close
    			Else if Close < lowerband[1] then sell short size contracts this bar on close; }
    		end;

    Hello

    #126554 quote
    Vonasi
    Moderator
    Master

    There are some simple rules that everyone using the forums is expected to follow. Your post has broken one or more of these rules.

    The forum rules are as follows. I have highlighted in bold the rule/rules that you have not followed:

    Post your topic in the correct forum.

    ProRealTime Platform Support          only platform related issues.
    ProOrder                                                only strategy topics.
    ProBuilder                                              only indicator topics.
    ProScreener                                           only screener topics
    General Discussion                               any other topics.
    Welcome New Members                      for new forum members to introduce themselves.

    Only post in the language of the forum that you are posting in. For example English only in the English speaking forums and French only in the French speaking forums.
    Always use the ‘Insert PRT Code’ button when putting code in your posts to make it easier for others to read.
    Do not double post. Ask your question only once and only in one forum. All double posts will be deleted anyway so posting the same question multiple times will just be wasting your own time and will not get you an answer any quicker. Double posting just creates confusion in the forums.
    Be careful when quoting others in your posts. Only use the quote option when you need to highlight a particular bit of text that you are referring to or to highlight that you are replying to a particular member if there are several involved in a conversation. Do not include large amounts of code in your quotes. Just highlight the text you want to quote and then click on ‘Quote’.
    Give your topic a meaningful title. Describe your question or your subject in your title. Do not use meaningless titles such as ‘Coding Help Needed’.
    Do not include personal information such as email addresses or telephone numbers in your posts. If you would like to contact another forum member directly outside of the forums then contact the forums administrator via ‘Contact Us’ and they will pass your details on to the member that you wish to contact.
    Always be polite and courteous to others.
    Have fun.

    I have edited your post where required. Please ensure that your future posts meet these few simple forum rules. 🙂

    #126556 quote
    Vonasi
    Moderator
    Master

    Roberto already told you in your first ever topic how to request a free code conversion from here:

    Ask for a Free Code Conversion

    Why did you completely ignore him?

    Please add the missing information to this topic.

    #126577 quote
    Nicolas
    Keymaster
    Master

    Hello! PLEASE CODE. GoodBye! 😆

    #127026 quote
    tapetkabinett
    Participant
    New

    Hello! I am having trouble converting various metastock indicators into PRT. If possible, I would love some help with the following code, to use as a guideline for future conversions 🙂

    { TSM5 Regression with bands
    	Copyright 2011, P.J.Kaufman. All rights reserved. }
    	
    	inputs: 	period(20), bandwidth(2.0);
    	vars:		slope(0), lrvalue(0), resid(0), sdresid(0), angle(0),
    				intercept(0), upperband(0), lowerband(0), size(0), investment(25000);
    	
    	Value1 = LinearReg( close, period, currentbar, slope, angle, intercept, 
     				lrvalue ) ;
    {	slope = LinearRegSlope(close,period);
    	lrvalue = linearRegValue(close,period,currentbar);}
    	resid = Close - lrvalue;
    	
    	If Currentbar > period then begin
    { position size }
    		size = investment / (avgtruerange(30)*bigpointvalue);
    		size = maxlist(size,1);
    		sdresid = stddev(close,period);
    		Upperband = lrvalue + slope + bandwidth*sdresid;
    		Lowerband = lrvalue + slope - bandwidth*sdresid;
    {		plot1(upperband,"UB");
    		Plot2(lowerband,"LB");
    }		plot3(lrvalue,"LR");
    		
    {		If Close > upperband[1] then buy size contracts this bar on close
    			Else if Close < lowerband[1] then sell short size contracts this bar on close; }
    		end;

    Also, I would like to apologise to Nicolas aswell as Vonasi for being a nuisance last week – I theorize I pressed “submit” just before clocking out, without checking the posted content.  Sorry about that mishap.

    #127047 quote
    Vonasi
    Moderator
    Master

    tapetkabinett – You seem to be having some issues with reading the rules and sticking to them.

    Do not double post! I will merge this topic with your last one on exactly the same subject!

    #127077 quote
    Nicolas
    Keymaster
    Master

    Please find below the code conversion from Metastock to ProRealTime about your strategy. It also plots on the chart the TSM regression bands.

    period=20
    bandwidth=2.0
    investment=10
    
    slope = LinearRegressionSlope[period](close)
    lrvalue = linearRegression[period](close)
    resid = Close - lrvalue
     
    If barindex > period then 
    size = investment / (averagetruerange[30]*pointvalue)
    size = max(size,1)
    sdresid = std[period](close)
    Upperband = lrvalue + slope + bandwidth*sdresid
    Lowerband = lrvalue + slope - bandwidth*sdresid
    graphonprice upperband
    graphonprice lowerband
    graphonprice lrvalue
      
    If Close > upperband[1] then 
    buy size contracts at market 
    Elsif Close < lowerband[1] then 
    sellshort size contracts at market 
    endif
    endif
    
    
    TSM-5-Regression-with-bands-strategy.png TSM-5-Regression-with-bands-strategy.png
Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.

TSM5 Regression with bands code conversion request.


ProBuilder: Indicators & Custom Tools

New Reply
Author
Summary

This topic contains 6 replies,
has 3 voices, and was last updated by Nicolas
5 years, 9 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 04/17/2020
Status: Active
Attachments: 1 files
Logo Logo
Loading...