PDA

View Full Version : CalculationMode.Dollar?


whitmark
07-06-2007, 06:17 PM
I would like to suggest that a CalculationMode.Dollar be developed for the SetStopLoss(), SetTrailStop(), and SetProfitTarget() built-in functions for use in the the fully disclosured overide signiture. In my attempt to get CalculationMode.Ticks to work as a substitute by using:

StopLossTicks = StopLossDollar / (Instrument.MasterInstrument.PointValue * Ticksize);
SetStopLoss("BuyEntry", CalculationMode.Ticks, StopLossTicks, false);

I would get an error when I execute this in the Initialize() method but not in the OnBarUpdate() method. I realize other override signitures can accommodate Dollar amounts as a value, but then I loose the ability to address a specific fromEntrySignal reference. Is this currently a limitation or am I overlooking something? Any thoughts on workarounds would be appreciated. Thanks!

Regards,

Whitmark

NinjaTrader_Dierk
07-07-2007, 12:00 AM
Not sure I follow. Doesn't signature below (and related) do what you are looking for?

protected void SetStopLoss(double currency)

whitmark
07-07-2007, 01:57 AM
True, but let's say I want to use different dollar based stop loss amounts for "BuyEntry" vs "SellEntry" entry signals . . . how would I go about doing that for both the call in the Initialize() method and subsequent dynamic modifications in OnBarUpdate()? Thanks.

Regards,

Whitmark

NinjaTrader_Ray
07-07-2007, 09:02 AM
Call it twice passing in the different entry signal names with the different stop values. Same in OnBarUpdate().

whitmark
07-07-2007, 01:46 PM
Please allow me to clarify. If I use the following signiture, I can do dollar values but I can't reference a specific fromEntrySignal . . .

SetStopLoss(double currency)

and if I try to convert it to CalculationMode.Ticks with the following code, it appears that the call to the Instrument object fails in the Initialize() method. Any particular reason for this?


BuyStopLossTicks = 150 / (Instrument.MasterInstrument.PointValue * Ticksize);
SetStopLoss("BuyEntry", CalculationMode.Ticks, BuyStopLossTicks, false);

SellStopLossTicks = 250 / (Instrument.MasterInstrument.PointValue * Ticksize);
SetStopLoss("SellEntry", CalculationMode.Ticks, SellStopLossTicks, false);


As you suggest Ray, I could just set a first run switch in OnBarUpdate() and call this code there if there is no need for an initial reference in the Initialize() method.

Hence my suggestion for a CalculationMode.Dollar and a signiture profile that can be used in the Initialze() method and includes a reference to a specific fromEntrySignal to enable differential long vs short dollar based stops.

Thanks,

Whitmark

NinjaTrader_Ray
07-07-2007, 05:49 PM
Instrument may be null in Initialize() therefore we prevent calling it.