Martingale money management for forex 0

Posted on 12, March 2014

in Category SID


Description for Martingale SID 124

Martingale money management for forex

A basic Martingale money managment for forex:

Description from:

http://en.wikipedia.org/wiki/Martingale_(betting_system)

A martingale is any of a class of betting strategies that originated from and were popular in 18th century The simplest of these strategies was designed for a game in which the gambler wins his stake if a coin comes up heads and loses it if the coin comes up tails. The strategy had the gambler double his bet after every loss, so that the first win would recover all previous losses plus win a profit equal to the original stake. The martingale strategy has been applied to roulette as well, as the probability of hitting either red or black is close to 50%.Martingale money management for forex/sid The logic for this Position Sizing Strategy:

Martingale money management for forex/sid PositionSize:

my $lastTrade = TradeHistory(1);

$currentUnits = $units if($currentUnits==0);

if($lastTrade){
	my $profit = $lastTrade->NetProfit;

	if($profit<0){
		$currentUnits = $currentUnits*2;
	}else{
		$currentUnits = $units;
	}
}

return RoundToUnitSize(ForexUnitsAvailable($currentUnits));

Martingale money management for forex/sid BuyMarket event logic:

if (ShortPosition) {
  #If we have a short position, close it.
  PlaceBuyOpen('Martingale_Close_Short');
}
else {
  #we have no position, or we are long.
  my $num=PositionSize();
  PlaceBuyOpen('Martingale_Open_Long',$num) if $num;
}

Martingale money management for forex/sid BuyStop event logic:

my $stop=shift;
#Stop trading if we do not have a stop price
die 'No stop price for BuyStop' unless $stop;

if (ShortPosition) {
  #If we have a short position, close it.
  PlaceBuyStop('Martingale_Close_Short',0,$stop);
}
else {
  #we have no position, or we are long.
  my $num=PositionSize();
  PlaceBuyStop('Martingale_Open_Long_Stop',$num,$stop) if $num;
}

Martingale money management for forex/sid BuyLimit event logic:

my $limit=shift;
#Stop trading if we do not have a limit price
die 'No limit price for BuyLimit' unless $limit;

if (ShortPosition) {
  #If we have a short position, close it.
  PlaceBuyLimit('Martingale_Close_Short',0,$limit);
}
else {
  #we have no position, or we are long.
  my $num=PositionSize();
  PlaceBuyLimit('Martingale_Open_Long_Limit',$num,$limit) if $num;
}

Martingale money management for forex/sid BuyStopLimit event logic:

my ($stop,$limit)=@_;
#Stop trading if we do not have a stop and limit price
die 'No limit price for BuyStopLimit' unless $limit;
die 'No stop price for BuyStopLimit' unless $stop;

if (ShortPosition) {
  #If we have a short position, close it.
  PlaceBuyStopLimit('Martingale_Close_Short',0,$stop,$limit);
}
else {
  #we have no position, or we are long.
  my $num=PositionSize();
  PlaceBuyStopLimit('Martingale_Open_Long',$num,$stop,$limit) if $num;
}

Martingale money management for forex/sid SellMarket event logic:

if (LongPosition) {
  #If we have a long position, close it.
  PlaceSellOpen('Martingale_Close_Long');
}
else {
  #If we have no position or we are short, place the order
  my $num=PositionSize();
  PlaceSellOpen('Martingale_Open_Short',$num) if $num;
}

Martingale money management for forex/sid SellStop event logic:

my $stop=shift;
#Stop trading if we do not have a stop price
die 'No stop price for SellStop' unless $stop;

if (LongPosition) {
  #If we have a long position, close it.
  PlaceSellStop('Martingale_Close_Long',0,$stop);
}
else {
  #If we have no position or we are short, place the order
  my $num=PositionSize();
  PlaceSellStop('Martingale_Open_Sell_Stop',$num,$stop) if $num;
}

Martingale money management for forex/sid SellLimit event logic:

my $limit=shift;
#Stop trading if we do not have a limit price
die 'No limit price for SellLimit' unless $limit;

if (LongPosition) {
  #If we have a long position, close it.
  PlaceSellLimit('Martingale_Close_Long',0,$limit);
}
else {
  #If we have no position or we are short, place the order
  my $num=PositionSize();
  PlaceSellLimit('Martingale_Open_Sell_Limit',$num,$limit) if $num;
}

Martingale money management for forex/sid SellStopLimit event logic:

my ($stop,$limit)=@_;
#Stop trading if we do not have a stop and limit price
die 'No limit price for SellStopLimit' unless $limit;
die 'No stop price for SellStopLimit' unless $stop;

if (LongPosition) {
  #If we have a long position, close it.
  PlaceSellStopLimit('Martingale_Close_Long',0,$stop,$limit);
}
else {
  #If we have no position or we are short, place the order
  my $num=PositionSize();
  PlaceSellStopLimit('Martingale_Open_Short',$num,$stop,$limit) if $num;
}

0 Comments

Leave a Message