PDA

View Full Version : Drawing from a strategy or from an indicator


grd974
06-30-2007, 01:01 AM
Could anyone explain to me the reason why, when I put this code in a strategy script, it draws Fibonacci retracements over my chart but when I put it in an indicator it does not.

protected override void OnBarUpdate()
{
// Condition set 1
if (High[0] == MAX(High, 34)[0])
{
RemoveDrawObjects();
DrawFibonacciRetracements("My fibonacci retracements" + CurrentBar, 1, MIN(Low, 34)[0], 0, High[0]);
PlaySound("DRUM.wav");
}
// Condition set 2
if (Low[0] == MIN(Low, 34)[0])
{
RemoveDrawObjects();
DrawFibonacciRetracements("My fibonacci retracements" + CurrentBar, 1, MAX(High, 34)[0], 0, Low[0]);
PlaySound("REMD.wav");
}
// Condition set 3
if (CrossAbove(Close, SMA(Close, 100), 1))
{
PlaySound("ringout.wav");
}
// Condition set 4
if (CrossBelow(Close, SMA(Close, 100), 1))
{
PlaySound("online.wav");
}
}

Gérard

NinjaTrader_Dierk
06-30-2007, 04:19 AM
Not sure I follow. Are you saying that putting this strategy on chart will draw the fib retracements and as you then add another indicator like e.g. SMA to the the same chart the fib retracements are gone?

Please clarify. Thanks

grd974
06-30-2007, 05:11 AM
When I use Market Replay for 06/25/07 here is what happens :

- experiment 1
. I attach the strategy : fib retracements immediately appear on the chart which happened to be previously displayed on my screen;
. I start to replay from the very beginning and then :
- on the 15th candle, a swing low happens : I can hear the sound and the fibs are drawn over the current candle
- on the 22th candle, a swing high happens : sound again and the fibs are drawn over the current candle

- experiment 2
. I get rid of any strategy and attach the same code inside an indicator : no fibs appear
. I restart the playing and then
- on the 15th candle, same swing low : no sound, no fibs
- on the 22th candle, same swing high : no sound, no fibs.

I wish I could have my fibs automatically drawn from an indicator which I would attach to my default template and which would allow me to use chart trader

NinjaTrader_Dierk
06-30-2007, 05:20 AM
Then likely the conditions in your indicator which trigger the drawing of the fibs never become true. Please verify by placing Print() statements instead of the drawing statements.

Next steps: Please try to understand why your conditions do not become true by simplifying your indicator until it finally works as expected.