spread indicator
Replies
rkokerti
08 Feb 2013, 12:09
RE: RE: spread indicator
MaXeY said:Hello
anyone have spread indicator for Ctrader ?
I use this one at the momment it almost in sink with the actual spread Tick Chart /algos/show/207
or you could use Lables for Charts /algos/show/195 just remove the infomation you dont want and set the indicator to false so that its not on your chart and in your way, I triying to work out how to calculate the pip differance between moving averages that will be printed using Lables. But I can think of a few good thing that could also be added such as RSI.
Hi Scott,
Try this...
using System;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
namespace cAlgo.Indicators
{
[Indicator(IsOverlay = true)]
public class _RI_WriteToChart_v2 : Indicator
{
//-----------------------------------------------------------------
[Parameter]
public DataSeries Source { get; set; }
[Parameter(DefaultValue = 14)]
public int PeriodMA1 { get; set; }
[Parameter(DefaultValue = 7)]
public int PeriodMA2 { get; set; }
//-----------------------------------------------------------------
private Position position;
private SimpleMovingAverage sma1;
private SimpleMovingAverage sma2;
private double Dist;
//-----------------------------------------------------------------
protected override void Initialize()
{
sma1 = Indicators.SimpleMovingAverage(Source,PeriodMA1);
sma2 = Indicators.SimpleMovingAverage(Source,PeriodMA2);
}
//-----------------------------------------------------------------
public override void Calculate(int index)
{
string Dist = " " + Math.Round((sma1.Result[index] - sma2.Result[index]) / Symbol.PipSize,0);
ChartObjects.DrawText("Labels",
"Dist:" + "\n"
, StaticPosition.TopLeft, Colors.Yellow);
ChartObjects.DrawText("Dist", Dist, StaticPosition.TopLeft, Colors.LightBlue);
}
}
}
@rkokerti
Scott
10 Feb 2013, 21:23
RE:
Hi,
You need to press space button several times between " ", or press tab button once in this row : string Dist = " " + Math.Round((sma1.Result[index] - sma2.Result[index]) / Symbol.PipSize,0);
I hope it helps.
Thanks rkokerti, got it working now, I put in 10 spaces in : string Dist = " " , the tab would move the pipsize to far away.
@Scott
Scott
07 Feb 2013, 20:20
RE: spread indicator
I use this one at the momment it almost in sink with the actual spread Tick Chart /algos/show/207
or you could use Lables for Charts /algos/show/195 just remove the infomation you dont want and set the indicator to false so that its not on your chart and in your way, I triying to work out how to calculate the pip differance between moving averages that will be printed using Lables. But I can think of a few good thing that could also be added such as RSI.
@Scott