why?

Questions about MultiCharts and user contributed studies.
RedBerlin
Posts: 81
Joined: 05 Dec 2014

why?

Postby RedBerlin » 09 Jan 2015

sorry
Iused supertrend indicator in chart...
today I was long whit indicator....but now with same setting IT IS SHORT....
How is possible?

RedBerlin
Posts: 81
Joined: 05 Dec 2014

Re: why?

Postby RedBerlin » 09 Jan 2015

sorry
Iused supertrend indicator in chart...
today I was long whit indicator....but now with same setting IT IS SHORT....
How is possible?
I mean.....in real time it was long ,but at end day ,today, in backtest it is short
and now Im in loss!!!
I use SUPERTREND INDICATOR,and with a Italian softwaere with same frame 1 hour,
and same setting parametres it t goes long at price 5.26
indeed in multicharts charts it goes long at 5.18!!!
the signal long of this morbning is mising,,,but I m in loss!!!
bho....

RedBerlin
Posts: 81
Joined: 05 Dec 2014

Re: why?

Postby RedBerlin » 10 Jan 2015

please
I need an answer
maybe problem is REPAINT?
Matricks what tink about?

RedBerlin
Posts: 81
Joined: 05 Dec 2014

Re: why?

Postby RedBerlin » 10 Jan 2015

please
I need an answer
maybe problem is REPAINT?
Matricks what tink about?
-----------------------------
//+------------------------------------------------------------------+
//| SuperTrend.mq4 v1.2 |
//| Copyright © 2008, Jason Robinson (jnrtrading). |
//| http://www.spreadtrade2win.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, Jason Robinson."
#property link "http://www.spreadtrade2win.com"

#property indicator_chart_window
#property indicator_color1 Lime
#property indicator_color2 Red
#property indicator_width1 2
#property indicator_width2 2
#property indicator_buffers 2
double TrendUp[], TrendDown[];
int changeOfTrend;
extern int Nbr_Periods = 10;
extern double Multiplier = 3.0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexBuffer(0, TrendUp);
SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 2);
SetIndexLabel(0, "Trend Up");
SetIndexBuffer(1, TrendDown);
SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 2);
SetIndexLabel(1, "Trend Down");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int limit, i, flag, flagh, trend[5000];
double up[5000], dn[5000], medianPrice, atr;
int counted_bars = IndicatorCounted();
//---- check for possible errors
if(counted_bars < 0) return(-1);
//---- last counted bar will be recounted
if(counted_bars > 0) counted_bars--;
limit=Bars-counted_bars;
//Print(limit);

//----
for (i = Bars; i >= 0; i--) {
TrendUp = EMPTY_VALUE;
TrendDown = EMPTY_VALUE;
atr = iATR(NULL, 0, Nbr_Periods, i);
//Print("atr: "+atr);
medianPrice = (High+Low)/2;
//Print("medianPrice: "+medianPrice);
up=medianPrice+(Multiplier*atr);
//Print("up: "+up);
dn=medianPrice-(Multiplier*atr);
//Print("dn: "+dn);
trend[i]=1;


if (Close[i]>up[i+1]) {
trend[i]=1;
if (trend[i+1] == -1) changeOfTrend = 1;
//Print("trend: "+trend[i]);

}
else if (Close[i]<dn[i+1]) {
trend[i]=-1;
if (trend[i+1] == 1) changeOfTrend = 1;
//Print("trend: "+trend[i]);
}
else if (trend[i+1]==1) {
trend[i]=1;
changeOfTrend = 0;
}
else if (trend[i+1]==-1) {
trend[i]=-1;
changeOfTrend = 0;
}

if (trend[i]<0 && trend[i+1]>0) {
flag=1;
//Print("flag: "+flag);
}
else {
flag=0;
//Print("flagh: "+flag);
}

if (trend[i]>0 && trend[i+1]<0) {
flagh=1;
//Print("flagh: "+flagh);
}
else {
flagh=0;
//Print("flagh: "+flagh);
}

if (trend[i]>0 && dn[i]<dn[i+1])
dn[i]=dn[i+1];

if (trend[i]<0 && up[i]>up[i+1])
up[i]=up[i+1];

if (flag==1)
up[i]=medianPrice+(Multiplier*atr);

if (flagh==1)
dn[i]=medianPrice-(Multiplier*atr);

//-- Draw the indicator
if (trend[i]==1) {
TrendUp[i]=dn[i];
if (changeOfTrend == 1) {
TrendUp[i+1] = TrendDown[i+1];
changeOfTrend = 0;
}
}
else if (trend[i]==-1) {
TrendDown[i]=up[i];
if (changeOfTrend == 1) {
TrendDown[i+1] = TrendUp[i+1];
changeOfTrend = 0;
}
}
}
WindowRedraw();

//----
return(0);
}
//+------------------------------------------------------------------+
someone could please this code in EL write?
to me is impssible to do

RedBerlin
Posts: 81
Joined: 05 Dec 2014

Re: why?

Postby RedBerlin » 10 Jan 2015

I live in italy...
which hours I have to set?
italianns stock start 9.00 and end 17.25
which time I have to set please....maybe problems indicator come from hour?

hughesfleming
Posts: 275
Joined: 22 Apr 2014
Has thanked: 70 times
Been thanked: 72 times

Re: why?

Postby hughesfleming » 11 Jan 2015

RedBerlin,

Your local and exchange time should be the same in this case. That is not your problem. If I am not mistaken, there is a Supertrend indicator for Multicharts coded and available in the multicharts download section on the bigmiketrading forum. Keep in mind that there is a one time fee to access the site.

RedBerlin
Posts: 81
Joined: 05 Dec 2014

Re: why?

Postby RedBerlin » 11 Jan 2015

RedBerlin,

Your local and exchange time should be the same in this case. That is not your problem. If I am not mistaken, there is a Supertrend indicator for Multicharts coded and available in the multicharts download section on the bigmiketrading forum. Keep in mind that there is a one time fee to access the site.
hi
could the reason be that I ve used "buy this bar on close"?

User avatar
Andrew MultiCharts
Posts: 1587
Joined: 11 Oct 2011
Has thanked: 931 times
Been thanked: 559 times

Re: why?

Postby Andrew MultiCharts » 12 Jan 2015

sorry
Iused supertrend indicator in chart...
today I was long whit indicator....but now with same setting IT IS SHORT....
How is possible?
I mean.....in real time it was long ,but at end day ,today, in backtest it is short
and now Im in loss!!!
I use SUPERTREND INDICATOR,and with a Italian softwaere with same frame 1 hour,
and same setting parametres it t goes long at price 5.26
indeed in multicharts charts it goes long at 5.18!!!
the signal long of this morbning is mising,,,but I m in loss!!!
bho....
Hello RedBerlin,

Please print the values calculated in the indicator to see why it shows short. You can find an example of print code here to integrate your own print statements.

RedBerlin
Posts: 81
Joined: 05 Dec 2014

Re: why?

Postby RedBerlin » 12 Jan 2015

Hello RedBerlin,

Please print the values calculated in the indicator to see why it shows short. You can find an example of print code here to integrate your own print statements.[/quote]
-----------------
hi Andrew
I noticed a thing very strange...
for example in italian software with same frame and same stock, the Supertrend
every hour is update and never,,,REPEAT never move during hour frame!!!
on the contrary same frame supertrend in Multicharts update price at end hours but during
hours session trading move continually ...it doesnt stop price but move up and down
!!!
I think this is not correct way and maybe this is the true problem!!!

User avatar
Andrew MultiCharts
Posts: 1587
Joined: 11 Oct 2011
Has thanked: 931 times
Been thanked: 559 times

Re: why?

Postby Andrew MultiCharts » 12 Jan 2015

hi Andrew
I noticed a thing very strange...
for example in italian software with same frame and same stock, the Supertrend
every hour is update and never,,,REPEAT never move during hour frame!!!
on the contrary same frame supertrend in Multicharts update price at end hours but during
hours session trading move continually ...it doesnt stop price but move up and down
!!!
I think this is not correct way and maybe this is the true problem!!!
To calculate on every tick in real-time:
If this is an indicator, please make sure the "Update on every tick" box is checked in the settings.
If this is a signal, please make sure IOG is enabled in settings.

RedBerlin
Posts: 81
Joined: 05 Dec 2014

Re: why?

Postby RedBerlin » 12 Jan 2015

hi Andrew
I noticed a thing very strange...
for example in italian software with same frame and same stock, the Supertrend
every hour is update and never,,,REPEAT never move during hour frame!!!
on the contrary same frame supertrend in Multicharts update price at end hours but during
hours session trading move continually ...it doesnt stop price but move up and down
!!!
I think this is not correct way and maybe this is the true problem!!!
To calculate on every tick in real-time:
If this is an indicator, please make sure the "Update on every tick" box is checked in the settings.
If this is a signal, please make sure IOG is enabled in settings.
yes Andrew,"update on every tick is checked in the settings og indicator!!
but signal ?where I have to see?
however I think is better indicator check when bar is end and not every tick!!
maybe problem is this one!!!

RedBerlin
Posts: 81
Joined: 05 Dec 2014

Re: why?

Postby RedBerlin » 12 Jan 2015

Code: Select all

// SuperTrend indicator

inputs:
ATRLength(1.5), ATRMult(4.9), UpColor(green), DnColor(red);

vars:
ATR(0),
avg(0),
dn(0),
up(0),
trend(1),
flag(0),
flagh(0),
SuperTrend(0);



ATR = AvgTrueRange(ATRLength) * ATRMult;
avg = (high + low)/2;
up = avg + ATR;
dn = avg - ATR;

if close > up[1] then
trend = 1
else if close < dn[1] then
trend = -1;

if trend < 0 and trend[1] > 0 then flag=1 else flag=0;
if trend > 0 and trend[1] < 0 then flagh = 1 else flagh = 0;

if trend > 0 and dn < dn[1] then dn=dn[1];
if trend < 0 and up > up[1] then up=up[1];

if flag = 1 then up = avg + ATR;
if flagh = 1 then dn = avg - ATR;

if trend = 1 then SuperTrend = dn else SuperTrend = up;
Plot3(SuperTrend,"SuperTrend",iff(trend = 1, green, red));
thi is indicator code
--------------------------------------------
----------------------------------------------

Code: Select all

[LegacyColorValue = TRUE];

inputs:
ATRLength(1.5), ATRMult(4.9), UpColor(cyan), DnColor(magenta);

vars:
ATR(0),
avg(0),
dn(0),
up(0),
trend(1),
flag(0),
flagh(0),
SuperTrend(0);



ATR = AvgTrueRange(ATRLength) * ATRMult;
avg = (high + low)/2;
up = avg + ATR;
dn = avg - ATR;

if close > up[1] then
trend = 1
else if close < dn[1] then
trend = -1;

if trend < 0 and trend[1] > 0 then flag=1 else flag=0;
if trend > 0 and trend[1] < 0 then flagh = 1 else flagh = 0;

if trend > 0 and dn < dn[1] then dn=dn[1];
if trend < 0 and up > up[1] then up=up[1];

if flag = 1 then up = avg + ATR;
if flagh = 1 then dn = avg - ATR;



if trend = 1 and trend[1]< 0 Then Buy next bar at open;
if trend = -1 and trend[1]> 0 then sellshort next bar at open;
and this is signal.

RedBerlin
Posts: 81
Joined: 05 Dec 2014

Re: why?

Postby RedBerlin » 12 Jan 2015

this morning with italian futures indicator has gone long...
but a few minutes ago that trading session is end ,I have turn off computer and then I
switch on computer,I have seen that the indicator is short!!!

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: why?

Postby JoshM » 13 Jan 2015

yes Andrew,"update on every tick is checked in the settings og indicator!!
but signal ?where I have to see?
however I think is better indicator check when bar is end and not every tick!!
maybe problem is this one!!!
IOG for signals can be enabled with a setting (see here) or by enabling the `IntraBarOrderGeneration` attribute (see here).
I noticed a thing very strange...
for example in italian software with same frame and same stock, the Supertrend
every hour is update and never,,,REPEAT never move during hour frame!!!
on the contrary same frame supertrend in Multicharts update price at end hours but during
hours session trading move continually ...it doesnt stop price but move up and down
!!!
I think this is not correct way and maybe this is the true problem!!!
There may be dozen of reasons why an indicator in MultiCharts performs differently than the indicator in another software program. Even if both platforms have their settings set to the same, there might still be differences in how ticks are processed and (the order of) script calculation. There might also be subtle code differences between PowerLanguage and the other platform's language that can lead to different values.

And if that Italian platform uses a different data feed, that can also account for differences.


Return to “MultiCharts”