Sao Paulo, Brazil
Posts: 3 since Aug 2014
Thanks Given: 0
Thanks Received: 0
|
Hello everyone, first time on this forum. Need some help....Coming from Amibroker I'm trying to rewrite an indicator wich is very simple: start , target and stop values, and a line drawn at the exact point (value) on the chart. (sorry, forum doesn't allow me to post pics in the first 5 posts)
So what I'm trying to do, is to have the indicator to be in "real time mode", and by that I mean , for example, if I have the signal when a doji forms (Close[0]==Open[0]), I want to see a triangle below the bar while the bar is forming and if the bar changes I want to see the triangle desappear . I want to see it blinking...
So if I choose "Calculate on bar close - FALSE), as soon as the bar opens, wich always opens as a doji( first tick has always OPEN==CLOSE), the triangle shows and stays there forever even if the bar changes to a hammer or anyother candle than a doji.
So I checked the RemoveDrawObjects and using that it simply removes all the past signals, wich I want to have in the chart.
I tried to find a solution and the only one I found was to have two indicators to achieve that, one with a +CurrentBar and "calculate on bar close_TRUE" and another without +CurrentBar but "calculate on bar close_FALSE" , but I'm wondering if there is a better and easy way to do it.
Below I'll post the two formulas
Thank you
---------------------------------------------
This is the one that removes all the past signals, and I use Calculate on bar close - FALSE:
---------------------------------------------
#region Variables
//tentando colocar triangulo abaixo do doji
private bool drawTriangleUp = true;
private int TriangleOffset = 5;
private Color TriangleColor = Color.Gray;
#endregion
/// <summary>
/// This method is used to configure the indicator and is called once before any bar data is loaded.
/// </summary>
protected override void Initialize()
{
CalculateOnBarClose = false;
Overlay = true;
AutoScale = true;
PriceTypeSupported = false;
DisplayInDataBox = false;
PaintPriceMarkers = false;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
if (CurrentBar == 0)
{
return;
}
if (Close[0]==Open[0])
{
DrawTriangleUp("TriangleUp",false,0,Low[0]-(TriangleOffset * TickSize),TriangleColor);
//DrawTriangleUp("TriangleUp"+CurrentBar,false,0,Low[0]-(TriangleOffset * TickSize),TriangleColor);
}
else
{
RemoveDrawObject("TriangleUp");
}
}
------------------------------------------------------------------------------------------
and this is the one to have the past signals ploted with Calculate on bar close - TRUE
------------------------------------------------------------------------------------------
#region Variables
//tentando colocar triangulo abaixo do doji
private bool drawTriangleUp = true;
private int TriangleOffset = 5;
private Color TriangleColor = Color.Gray;
#endregion
/// <summary>
/// This method is used to configure the indicator and is called once before any bar data is loaded.
/// </summary>
protected override void Initialize()
{
CalculateOnBarClose = false;
Overlay = true;
AutoScale = true;
PriceTypeSupported = false;
DisplayInDataBox = false;
PaintPriceMarkers = false;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
if (CurrentBar == 0)
{
return;
}
if (Close[0]==Open[0])
{
DrawTriangleUp("TriangleUp"+CurrentBar,false,0,Low[0]-(TriangleOffset * TickSize),TriangleColor);
}
else
{
RemoveDrawObject("TriangleUp");
}
}
|