daily open close customization
daily open close customization
27 Sep 2016, 13:31
hello, i m new in programming calgo, so i try to ask help.
i used to trade on mt4, and there, i had a daily open line indicator that was showing me the open daily candle.
i d like to add the possibility to modify the plot of the line on the chart....so that i can choose the kind of line, if dots and how thin the line should be.
is this possible??
thanks in advance.
mat
Replies
... Deleted by UFO ...
forextik
03 Oct 2016, 09:46
RE: indicators using cAlgo
harry said:
[Output("Main", Color = Colors.Turquoise)]
public IndicatorDataSeries Result { get; set; }
hi Harry.
yes i saw, and can understand the meaning, but what i am looking into is a line that is not a continuos one, i want ,when the day finish , the line too finish and the day after i have another line..... it is like if i need of a new property for drowing the line...??? couse it seems i havent found that one!!
this is what i am looking at for now.
then i have another question, about another free indicator, called woodiepivotpoints. this indicator has a problem: when i add it to a chart, the chart will be zoomed out, so that all the support and resistance are shown. but this is very annoying couse even if my chart zoom is at max, i cannot view the candle zoomed!!!!
if someone can help undestanding this behaviour i would be very pleased!;)
thanks in advance!
mat
@forextik
forextik
04 Oct 2016, 23:25
i check the open daily candle under mt4, and the calgo indicator, i daresay is not working correctly....
so day after day i start thinking that ctrader is'nt a good trading platform.
there are plenty of problem, i cannot link my ctrader ID to myfxbook and nobody listen to me....i wrote so many time to have a solution for this....and i can just say that all this problem make me trade like a unable trader....couse i m not quiet....
can you tell me hat do you think about ctrader and with which broker are you using it? couse i start thinking that problems are connected with the broker not only with spotware....
but why should i try using a not well working platform when we have mt4 very quick doing all via mobile and via pc.....boh
mat
@forextik
forextik
04 Oct 2016, 23:43
this is the mt4 daily open candle working as it should be.
the other one is not like this, the open is not correct in the calgo indicator,
i tried the mql calgo converter....i can say it is notihng at all working,
//*
//* my_DailyOpen_indicator
//*
//* Revision 1.1 2005/11/13 Midnite
//* Initial DailyOpen indicator
//* based pm
//*
#property copyright "Midnite"
#property link "me@home.net"
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 DodgerBlue
#property indicator_style1 2
#property indicator_width1 1
double TodayOpenBuffer[];
extern int TimeZoneOfData= 0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,TodayOpenBuffer);
SetIndexLabel(0,"Open");
SetIndexEmptyValue(0,0.0);
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int lastbar;
int counted_bars= IndicatorCounted();
if (counted_bars>0) counted_bars--;
lastbar = Bars-counted_bars;
DailyOpen(0,lastbar);
return (0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int DailyOpen(int offset, int lastbar)
{
int shift;
int tzdiffsec= TimeZoneOfData * 3600;
double barsper30= 1.0*PERIOD_M30/Period();
bool ShowDailyOpenLevel= True;
// lastbar+= barsperday+2; // make sure we catch the daily open
lastbar= MathMin(Bars-20*barsper30-1, lastbar);
for(shift=lastbar;shift>=offset;shift--){
TodayOpenBuffer[shift]= 0;
if (ShowDailyOpenLevel){
if(TimeDay(Time[shift]-tzdiffsec) != TimeDay(Time[shift+1]-tzdiffsec)){ // day change
TodayOpenBuffer[shift]= Open[shift];
TodayOpenBuffer[shift+1]= 0; // avoid stairs in the line
}
else{
TodayOpenBuffer[shift]= TodayOpenBuffer[shift+1];
}
}
}
return(0);
}
@forextik
forextik
10 Oct 2016, 14:32
ok i think i have understand something.....
about the logic behind this mql indicator.....but i d like to talk abotu with someone that know mql and algo.
int shift;
int tzdiffsec= TimeZoneOfData * 3600;
double barsper30= 1.0*PERIOD_M30/Period();
bool ShowDailyOpenLevel= True;
// lastbar+= barsperday+2; // make sure we catch the daily open
lastbar= MathMin(Bars-20*barsper30-1, lastbar);
this line should be usefull just to draw the open candle line just as a line and not a continuos line that draw diagonal line to unify all the segments....
does this sound correct? is calculating a sort of shift and point when the line shoould not be present.....
let me know!;)
@forextik
forextik
10 Nov 2016, 18:42
RE:
lucian said:
You can try Today Open Line .
hi lucian, i have been studying very long only this indicator....the daily open line....
all those indi for ctrader, but your, are shit!!!!!
this happen couse threre is an errorin the code, couse your is working quiet fine.never move changin time frame....but is diplaying only one line, the last day, while the other are showing even the other days, and all those are very important level i take care.
even the one i converted from mql, that is working perfecly in mt4 , here works like the one developed, not by you.
what is wrong in that indi, that is modifying the price , changing timeframe....
i m not yet a very rich trader....but i mworking hard on it....and doing fine, otherwise i would direcly call you or a calgo trader...
but the forum should be here to help learning....even if i think spotwere should put someone to help ppl....
let me know if oyu can help me!:)
mat
@forextik
... Deleted by UFO ...
forextik
24 Nov 2016, 11:01
RE:
lucian said:
Hi Mat,
Try Daily Close
hi lucien, your indi is the only one that seems to be working as it should be, but i really do not like the loook it has.....it t possible to modify it adding just some modification?
ie i d like to have it even for the previous day...not only the last day....
couse those zone...the open are very important and they should be in the right place....price bounce between them.....
let me know|;(
mat
@forextik
... Deleted by UFO ...
matfx
25 Nov 2016, 01:18
( Updated at: 21 Dec 2023, 09:20 )
Daily Open Line
Hi mat,
I'm also new to CAlgo and also at the same time trying to convert the mql4 version of daily open line for Ctrader.
But in return same as you, can't get the actual working version for Ctrader. Nontheless i won't give up and so i would like to share here another code which is convert to mql5 code.
The mql5 version below :
#property indicator_chart_window #property indicator_buffers 1 #property indicator_plots 1 #property indicator_label1 "Daily open line" #property indicator_type1 DRAW_ARROW #property indicator_style1 STYLE_DOT #property indicator_color1 clrGray input int TimeShift = 0; // Time shift (in hours) double openLine[]; // // // // // int OnInit() { SetIndexBuffer(0,openLine,INDICATOR_DATA); return(0); } int OnCalculate(const int rates_total, const int prev_calculated, const datetime& time[], const double& open[], const double& high[], const double& low[], const double& close[], const long& tick_volume[], const long& volume[], const int& spread[]) { if (Bars(_Symbol,_Period)<rates_total) return(-1); for (int i=(int)MathMax(prev_calculated-1,0); i<rates_total && !IsStopped(); i++) { string stime = TimeToString(time[i]+TimeShift*3600,TIME_DATE); openLine[i] = (i>0) ? (TimeToString(time[i-1]+TimeShift*3600,TIME_DATE)==stime) ? openLine[i-1] : open[i] : open[i]; } return(rates_total); }
The mql5 version of Daily Open Line work as the same as the old MT4 version.
So i'm very hopeful someone can help how to convert it to C# language.
Thanks.
matfx
@matfx
forextik
12 Dec 2016, 10:26
( Updated at: 21 Dec 2023, 09:20 )
RE: Daily Open Line
matfx said:
Hi mat,
I'm also new to CAlgo and also at the same time trying to convert the mql4 version of daily open line for Ctrader.
But in return same as you, can't get the actual working version for Ctrader. Nontheless i won't give up and so i would like to share here another code which is convert to mql5 code.
The mql5 version below :
#property indicator_chart_window #property indicator_buffers 1 #property indicator_plots 1 #property indicator_label1 "Daily open line" #property indicator_type1 DRAW_ARROW #property indicator_style1 STYLE_DOT #property indicator_color1 clrGray input int TimeShift = 0; // Time shift (in hours) double openLine[]; // // // // // int OnInit() { SetIndexBuffer(0,openLine,INDICATOR_DATA); return(0); } int OnCalculate(const int rates_total, const int prev_calculated, const datetime& time[], const double& open[], const double& high[], const double& low[], const double& close[], const long& tick_volume[], const long& volume[], const int& spread[]) { if (Bars(_Symbol,_Period)<rates_total) return(-1); for (int i=(int)MathMax(prev_calculated-1,0); i<rates_total && !IsStopped(); i++) { string stime = TimeToString(time[i]+TimeShift*3600,TIME_DATE); openLine[i] = (i>0) ? (TimeToString(time[i-1]+TimeShift*3600,TIME_DATE)==stime) ? openLine[i-1] : open[i] : open[i]; } return(rates_total); }The mql5 version of Daily Open Line work as the same as the old MT4 version.
So i'm very hopeful someone can help how to convert it to C# language.
Thanks.
matfx
hi matfx, sorry for the late answer. very busy with the "let me eat " job;)
i converted old mt4 open candle very easily....i took the mql script, put it into the converter, and then i took what was the returned code, even if it had weird symbols , i pasterd it in calgo....and calgo compiled it....
but the problem is that those mql stuff is not precise....at least it is on mt4 or mt5 but not here....in ctrader i have the indi price moving on different timeframe. the only one working is the lucient today open line.
@forextik
harry
27 Sep 2016, 15:24
indicators using cAlgo
Hi Matt, am also new to cAlgo.
You can create indicators using cAlgo.
I have looked on some samples, you can just modify some samples using the data you want to output.
I took the code below from sample SMA cAlgo, just notice the Output below is to show the plot on the chart
Run an instance using the indicators on cAlgo to better understand what am saying
// -------------------------------------------------------------------------------------------------
//
// This code is a cAlgo API example.
//
// All changes to this file will be lost on next application start.
// If you are going to modify this file please make a copy using the "Duplicate" command.
//
// -------------------------------------------------------------------------------------------------
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
namespace cAlgo
{
[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AutoRescale = false, AccessRights = AccessRights.None)]
public class SampleSMA : Indicator
{
[Parameter("Source")]
public DataSeries Source { get; set; }
[Parameter(DefaultValue = 14)]
public int Periods { get; set; }
[Output("Main", Color = Colors.Turquoise)]
public IndicatorDataSeries Result { get; set; }
public override void Calculate(int index)
{
double sum = 0.0;
for (int i = index - Periods + 1; i <= index; i++)
{
sum += Source[i];
}
Result[index] = sum / Periods;
}
}
}
@harry