Thursday, August 18, 2011

First Results with cross platform functions TradeStation and Metatrader

A quite powerful and simple function in TradeStation is SetStopLoss().


in MT4 one has to write up order manipulation explicit. Find the orders, change stops, calculate dollar value and modify orders. and that on a regular basis.



in TradeStation and even NinjaTrader the Statement is:
Inputs: StopLoss(2300); 
SetStopLoss(StopLoss);

and the platform is taking care of a general money stop so that you dont loose more than that amount of money.

I added now the same function to MT4 by the library, and the cose regaring this feature looks now identical on all 3 platforms, a single line of code, not more.

extern double   StopLoss      =  2300;   // strategy parameter for user
SetStopLoss (StopLoss);

once the losses are exceeding this value, all positions are closed. As TradeStation allows to base this stop on a per-contract basis or on positions, etc it provides following functions to set this:

SetStopContract()
SetStopShare()
SetStopPosition()

These exact functions are missing in ninjatrader too, so also the NT7 class I am using implements the same functionality and behaves identical. hm almost. even so, Ninja emulated the SetStopLoss function it behaves different from the TS equivalent. i.e. you cannot use a trailstop together with this function. what a shit.
it means I have to overload the Ninja Function too in order to get the functionality more close to TradeStation.

NinjaTrader code looks then:


EasyInitialize()
{
          SetStopLoss (StopLoss);
}


on the other side, Ninja allows to set the stoploss on a contract basis with 3 different modes:


CalculationMode.Percent
CalculationMode.Price
CalculationMode.Ticks

MT4 had nothing like this, so it is added simply.

the common denominator is, my library will override the original function and provide a similar functionality on all platforms.

No comments:

Post a Comment