Gamestudio Links
Zorro Links
Newest Posts
retrain - data?
by danatrader. 09/19/20 17:38
New Zorro version 2.30
by danatrader. 09/19/20 08:25
Special Bars Script
by danatrader. 09/19/20 00:41
NeoDumont's open world treadmill project
by NeoDumont. 09/19/20 00:30
Key_Pressed Variable
by Dooley. 09/18/20 22:46
lock profit without trail
by Grat. 09/18/20 14:30
how to use BrokerHistory2
by Grat. 09/18/20 14:29
AUM Magazine
Latest Screens
The Space Between
Pogostuck: Rage With Your Friends
Worst Case Z
AckCon'18 - Lotter vs the World 2 - Preview Release
Who's Online Now
10 registered members (distribution, AndrewAMD, danatrader, Iglarion, painkiller, kvm, NewBorn, Quad, DavidB1969, 1 invisible), 461 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
NewBorn, 3dvg, secretagentman, distribution, EditeY
18515 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Average Position Up #478954
01/25/20 00:23
01/25/20 00:23
Joined: Jan 2020
Posts: 24
L
Leohermoso Offline OP
Newbie
Leohermoso  Offline OP
Newbie
L

Joined: Jan 2020
Posts: 24
Hi, I am trying to achieve the following result: Everything I trail my stop loss I want to increase the size of my positions

I know the following TMF code is wrong, but how is the correct way to achieve this?

Code
int TrailingAndAdding(var lookback)
{

	if (TradeIsOpen && TradeProfit > 0 )
	{
		
		if (TradeIsLong)
		{
			TradeStopLimit = max(TradeStopLimit, LL(lookback, 0));
			//Increase my Position by one unit
			TradeLots++;
		}
		else if (TradeIsShort)
		{
			TradeStopLimit = min(TradeStopLimit, HH(lookback, 0));
			//Increase my Position by one unit
			TradeLots++;
		}

	}

	return 0;
}



Best Regards

Leo Hermoso

Last edited by Leohermoso; 01/25/20 00:24.
Re: Average Position Up [Re: Leohermoso] #478957
01/25/20 17:44
01/25/20 17:44
Joined: Feb 2017
Posts: 1,090
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,090
Chicago
You cannot increase the position of a trade. You can either partially close it or close it entirely.

Suppose your position is 10 lots long, and you want to increase it to 12, you enterLong for 2 lots. Yes, now you have to manage 2 trades.

Alternatively, if you are using the Virtual Hedging feature (Hedge = 5, Zorro S only), you can close the original 10 long trade and place another 12 long. At the end of your run() call, Zorro will place a single +2 lot trade to split the difference. This is a very nice feature.

Re: Average Position Up [Re: AndrewAMD] #478965
01/28/20 22:07
01/28/20 22:07
Joined: Jan 2020
Posts: 24
L
Leohermoso Offline OP
Newbie
Leohermoso  Offline OP
Newbie
L

Joined: Jan 2020
Posts: 24
That's an interesting approach Andrew. Tks for your reply.


Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1