Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
First of all HELLO TO EVERYONE, this is my first post here :-D
I'm Looking for a Linear Regression Indicator code that display up and down trend with two different colors to use in multichart to test a strategy based on entries made where the color is changing (means the trend is supposed to invert) and in different time frame of the day.
I'm very new to easy language programming so any suggestion are appreciated.
Thanks in advance.
REgards,
David
Can you help answer these questions from other members on NexusFi?
I tried to modify the standar LINEAR REGRESSION CURVE provided by multichart in order to use 2 different colors in order to show the UP and DOWN trends... here's what I've done:
Actually it seems to work ...
But I'm not sure if it is working ALWAYS CORRECLTY. By setting the Chart with 100 ticks and 131 value for the linear regression I can see the most of the trends... but Sometimes it doesn't change color where it is supposed to do that..
Can you see in the image that almost in the middle of the graphic there's a big UPtrend STILL in BLUE?? it shouls be white!
Anyone can try it? Maybe with the FDAX so we can compare it?
your conditions for setting the color are very restrictive i.e. if the price doesn't match your Price > var0 or Price < var0 condition on the exact bar where the slope of the regression changes, the color wouldn't be changed.
Apart from that you might want to set the color before you plot the value, so the new color can be used right away.
HIT ABCTG thanks for the answer. As I said I'm very new to strategies programming. My code was a simple modifications of the Linear Reg Curve indicator included in the power language editor.. I saw the row with the Alert ("trend is turning Up") and I simply changed it into the color modifications (same thing for the Dw trend alert).
So How would you modify this code in order to make it function correctly?
Thanks again :-D
it would depend a bit on your exact condition for the color change. You can for example use the reserved words "crosses over" and "crosses under" to check for a change in the slope of the linear regression.
This check should be performed before (i.e. above in the code) your call "Plot1", so it can use this changed color already. Otherwise you might have a delay of one bar.
If you want to make your programming life easier in the long run, I would suggest to start using meaningful variable names and not generic ones (like var0 or Condition1). This will make your code easier to read and in turn save you time.
Hi ABCTG and thanks again for your suggestion.
As suggested from a friend I was able to obtain the correct linear reg curve with the up and down trend simply removing some restrictions from the conditions... It seems to work correctly.
Now I'm doing some test to better understand how the entries work in MC. I'm trying to buy when the indicator is supposed to turning up and I was tryng to create an OCO order that, If I'm not wrong, here at MC it should be coded by this way:
actually I'm totally confused because when I applied this signal to the FDAX 03 ( I only have something like 4 or 5 tick days of quotation (webank with t3 open give you only 1 day tick data.... ) at the first run it said that the MaxBarBack was to low(50) to calculate strategy.. then I went to the property strategy and changed it to 100.. nothing.. then 10000..nothing... then with 1000 I was able to see a lot (a hundred in 2 days) of "wrong operations"... with 2000 I can only see 1 Operation...
so what is the correct value for MaxBarsBack? what does it really mean? I (of course) checked documentation but it cannot explain to me the difference in the result....
Let me explane better: If I wanto to back test a strategy over 1 YEAR of Future tick by tick, what kind of value shall I set? I don't think that the system is requiring the total number of hystoric bars to analyze....
the Maximum Number of bars a study will reference are the number of bars that your studies require to be computed.
Assuming you have an average with the length of 100, this would require 100 bars to be on the chart. Consequently a strategy with an average with the length of 100 will raise the error message when you set Max Bars back lower than 100. In your case the regression requires at least "Length" number of bars before it will be computed.
It's best to use SetStopLoss and SetProfitTarget unconditionally. In your code they actually wouldn't be placed when you are in a position, because at that moment MarketPosition is different than zero.
Regards,
ABCTG
P.S.: By the way, you can use the "Thanks" button next to a post on futures.io to show your appreciation for a post.
the only thing to keep in mind that unless you are working with intra bar order generation, your stop and target won't be placed during the entry bar with the code you posted.