Hedge

Posted By: MatPed

Hedge - 07/05/17 10:36

Hi,
with Hedge >= 4 I want to be sure that the virtual trade is opened if and only if the real trade have been opened. The only exception should be that Lot have been set to -1.
Trading with CFD it may happen that the asset is not available and the real trade is refused, but the virtual one, opened.

Thank you for the hint
Posted By: DdlV

Re: Hedge - 07/05/17 17:14

Hi MatPed,

My 2 cents/pesos/shillings/lire/whatever laugh :

When using Virtual Hedging it's the "Boss". The virtual trade will always be opened. That's how Virtual Hedging works. A real trade isn't attempted unless Virtual Hedging decides it's needed.

If you're talking the Z systems, I started a similar thread re. Hedge=5 and Margin=0. The result there was that Virtual Hedging takes precedence and real positions will be adjusted to match as time goes by, even if it means opening a new real trade even though Margin=0. So, if a real trade can't be entered, Virtual Hedging will still know that it's needed and attempt to fix it (on the real side) at a future bar.

If you're talking your own strategy, presumably via receiving the error message from the real side, or by a for(open_trades) loop, you can determine if virtual & real are out of sync, and then decide what to do. One of the choices would be to manually close virtual trade(s) as needed. But jcl will have to comment if there are any gotchas in manually closing virtual trades outside of Virtual Hedging's processes...

Regards.
Posted By: MatPed

Re: Hedge - 07/05/17 19:38

Hi DLV,
what you say makes sense and is stated in the manual.
Trading my own cfd strategy I'd like to know if there is a way to override this behavior. It will save a lot of headache in developing.

Closing the virtual trade after an error will work, but will produce an altered equity line of the Asset/Algo so equity line control will be less accurate.

I hope that JCL will find a way...
Posted By: jcl

Re: Hedge - 07/06/17 09:02

If a real trade was rejected or was externally closed, Zorro will attempt to open it again at the next trade with that asset. If you want to close the virtual trade instead, let your script compare LotsPool and LotsPhantom, and cancel the virtual trade accordingly. I do not think that this has an effect on the accuracy of the equity.
Posted By: MatPed

Re: Hedge - 07/06/17 19:42

Originally Posted By: jcl
If a real trade was rejected or was externally closed, Zorro will attempt to open it again at the next trade with that asset.


I guess you mean ...at the next bar... yes, and this is great

Originally Posted By: jcl
If you want to close the virtual trade instead, let your script compare LotsPool and LotsPhantom, and cancel the virtual trade accordingly. I do not think that this has an effect on the accuracy of the equity.


yes it will affect the equity: you will have a +1 number of trades with a small loss or profit. The virtual trade will be always open regardless the real asset availability. This is why a was asking a previous check. If you have any hint on this it will be great.

just immagine a psudo-code like:

tradeIsGood = enterLong();
If (tradeIsGood ) enterVirtual(tradeIsGood);

In this case any wrong virtual opening will be avoided. I understand this will limit the Hedge = 5 setting. This is the reason because I was asking for something that will simplify "is the asset available" topic.

Thank you in advance
Posted By: jcl

Re: Hedge - 07/07/17 06:41

A cancelled trade has no loss or profit, so I would see no problem with that solution.
Posted By: MatPed

Re: Hedge - 07/07/17 09:06

I did not get it.
If I exit an open trade (exitLong) right after having opened it a loss is generated anyway: the spread.

Am I wrong?
Posted By: DdlV

Re: Hedge - 07/07/17 12:46

Hi jcl. I think I see what MatPed is asking:

Does "canceled" mean the Virtual trade is undone as if it had never been attempted, and so it becomes a non-entity and doesn't affect anything else?

Or does "canceled" mean the Virtual trade is closed normally (f.i. via exitTrade), and therefore it has some result (likely negative due to Spread at least), and therefore affects Equity, etc.?

Thanks.
Posted By: jcl

Re: Hedge - 07/10/17 16:17

It is the former.
Posted By: MatPed

Re: Hedge - 07/11/17 07:23

ok, there is particular way to cancel a virtual trade or a standard exitLong/Short will make the trick?

Thank you
Posted By: jcl

Re: Hedge - 07/11/17 11:06

No, with "cancel" I mean the command, which is different to "exit".

http://manual.zorro-project.com/sellong.htm
Posted By: MatPed

Re: Hedge - 07/11/17 12:18

Thank you Jcl I missed that function, but still I do not get it.

In Trade mode and Hedge = 5
If I enterLong() a trade while the asset is not available from the broker, should I treat this case specifically or is already handled by Zorro i.e. Zorro will repeat try to open the trade or adjust the pool accordingly?

If is not the former can you suggest me the proper way to handle it?

Thank you for your patience
Posted By: jcl

Re: Hedge - 07/11/17 12:35

Do you mean an asset that is generally not available, or just temporarily?

If only temporarily, I see not what you needed to do. Just wait until the positions are in sync again when a trade with that asset is opened the next time.
Posted By: MatPed

Re: Hedge - 07/11/17 13:19

yes only temporarily. Ok Thank you
© 2024 lite-C Forums