Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (VoroneTZ, 7th_zorro), 1,071 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
What if this happens when trading?🥶 #480980
07/29/20 02:59
07/29/20 02:59
Joined: May 2020
Posts: 45
A
AdamWu Offline OP
Newbie
AdamWu  Offline OP
Newbie
A

Joined: May 2020
Posts: 45
I have my startegy ready. But onece I start tarding, I must know what will happen and how to hanle them. To make things clear, I made a flow chart:
[Linked Image]

And there are two questions inside:
Question1: If manually changed the balance, should the “Balance” value in the code be changed accordingly?
Question2: Will close some trades by hand harm the startegy? What is the correct way to handle this?

Attached Files when trade.jpg
Last edited by AdamWu; 07/29/20 03:01.
Re: What if this happens when trading?🥶 [Re: AdamWu] #480981
07/29/20 03:28
07/29/20 03:28
Joined: Feb 2017
Posts: 1,729
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,729
Chicago
Easy:
Margin call, add money, margin call, add money... tongue

Re: What if this happens when trading?🥶 [Re: AndrewAMD] #480982
07/29/20 04:52
07/29/20 04:52
Joined: May 2020
Posts: 45
A
AdamWu Offline OP
Newbie
AdamWu  Offline OP
Newbie
A

Joined: May 2020
Posts: 45
How about the "Balance" value? Should I make a bar to refelct how much I add or draw out?

Re: What if this happens when trading?🥶 [Re: AdamWu] #480990
07/29/20 20:13
07/29/20 20:13
Joined: Feb 2017
Posts: 1,729
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,729
Chicago
During live trading, yes, your broker plugin will update the Balance and Equity values. (Unless you override this behavior using the SET_PATCH broker command.)

Now, if you want to simulate it in a backtest instead, manually changing the Balance value does not work. Instead, consider applying credits and debits to your account using enterTrade(). I explain how to do this on my blog:
https://www.vitaltrades.com/2020/07/14/adding-exact-fee-and-credit-calculations-to-zorro/

Re: What if this happens when trading?🥶 [Re: AndrewAMD] #480991
07/29/20 22:33
07/29/20 22:33
Joined: May 2020
Posts: 45
A
AdamWu Offline OP
Newbie
AdamWu  Offline OP
Newbie
A

Joined: May 2020
Posts: 45
Thanks a lot. It is much more clear now. 👍

Re: What if this happens when trading?🥶 [Re: AdamWu] #480992
07/29/20 22:43
07/29/20 22:43
Joined: Aug 2017
Posts: 294
Netherlands
G
Grant Offline
Member
Grant  Offline
Member
G

Joined: Aug 2017
Posts: 294
Netherlands
I believe it's best to limit the risk of a margin call to a minimum by implementing this into your strategy. For example with proper money management and with a diversified portfolio.

To make sure my strategy is prone to margin calls, I've included this into my code:

Code
if(Equity - MarginVal < 0)
    {
    printf("\n***CRITICAL***");
    printf("\nMargin Call: Margin (%.2f) >= Equity (%.2f)", MarginVal, Equity);
    printf("\nTheoretical Equity should be: 'Balance(%.2f) + WinValTotal(%.2f) - LossValTotal(%.2f)'", Balance, WinValTotal, LossValTotal);
    quit()//(Optional);	
    }

Re: What if this happens when trading?🥶 [Re: Grant] #480994
07/30/20 07:59
07/30/20 07:59
Joined: May 2020
Posts: 45
A
AdamWu Offline OP
Newbie
AdamWu  Offline OP
Newbie
A

Joined: May 2020
Posts: 45
Hi Grant, good points. So your strategy just stop there and manually deal with margin call and open positions? If there are 30 open positions, it is not easy to handle by hand.
How about red alert earlier but don't quit the strategy. Add some money and let stragtegy go on?

Re: What if this happens when trading?🥶 [Re: AdamWu] #480996
07/30/20 09:45
07/30/20 09:45
Joined: Aug 2017
Posts: 294
Netherlands
G
Grant Offline
Member
Grant  Offline
Member
G

Joined: Aug 2017
Posts: 294
Netherlands
Hi Adam,

I only use this rule in my test strategy, not the production version.
In case you receive a margin call, it's too late to fund your account anyway.

By using a brokerCommand -> GET_POSITION (see https://zorro-project.com/manual/en/brokercommand.htm), you can validate which positions are still active.

Yeah, you can add an alert warning. For example when your margin reaches 80% of your available funds:

Code
if(MarginVal / Equity > 0.8)

Last edited by Grant; 07/30/20 09:46.
Re: What if this happens when trading?🥶 [Re: Grant] #480999
07/30/20 23:13
07/30/20 23:13
Joined: May 2020
Posts: 45
A
AdamWu Offline OP
Newbie
AdamWu  Offline OP
Newbie
A

Joined: May 2020
Posts: 45
Thanks, I will implement this feature into my strategy. 👍👍👍


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1