How to close the last trade EXACTLY at the open of the next trade? - page 3

 
marth tanaka:

Correct me if I’m wrong (I’m trying to best understand) but I believe you have the wrong idea.


I do not open an order in the opposite direction if price moves 3 pips against my original sell. Instead, I open a sell if price moves 3 pips against me that has twice the volume of the last sell so that if it retraces 3 pips down to the first sell, it covers the losses of the first trade and profits.

I get it, but why are you closing orders to open more? That doesn't make sense. 

 
marth tanaka:

I do not open an order in the opposite direction if price moves 3 pips against my original sell. Instead, I open a sell if price moves 3 pips against me that has twice the volume of the last sell so that if it retraces 3 pips down to the first sell, it covers the losses of the first trade and profits.

i believe my code doesn't do exactly as you want, but you get the idea.
good luck.

 
nicholi shen: I get it, but why are you closing orders to open more? That doesn't make sense. 

He is trying to apply the "double down" tactic, but in a way that attempts to reduce exposure and the required margin. However, he is trying to do this without actually applying proper mathematical analysis and not taking into consideration other factors, such as Spread, Commission and Slippage, so the end result will still be high loses.

To the OP @marth tanaka: What you are trying to do, has been attempted over and over again, by many, many, many traders before you, and the end result is always the same - on average and in the long run, "doubling down" (even with the technique you are attempting) will always lose more money than a standard stop-loss on single trades accompanied with proper position sizing and good money management.

You are wasting your time and effort (and money) by "doubling down"!

 
Mohamad Zulhairi Baba:

3pips (30point) is too narrow, imho.
anyway, quick code, didn't test.

call it on OnTick() 

ps: edit some code
@Mohamad Zulhairi Baba There is one error I am facing in your tradeCloser function. The line with "if(x) {" throws me the error " 'if' - semicolon expected"


What would be the quick fix for this that Im not seeing so I can run this function and test? Thanks
 
nicholi shen:

I get it, but why are you closing orders to open more? That doesn't make sense. 

As Mr. Carreiro said, it is to reduce exposure and the required margin.


However, contrary to what Mr. Carreiro said, I have applied mathematical analysis before embarking on this and the results showed that this is profitable. I can filter out slippage, commission isnt a problem and I was able to manually open a new order at the close of the last one (no spread) using limit orders but for some reason the same does not work in an EA (the spread between the last close and the next open is there.
 
marth tanaka:
@Mohamad Zulhairi Baba There is one error I am facing in your tradeCloser function. The line with "if(x) {" throws me the error " 'if' - semicolon expected"


What would be the quick fix for this that Im not seeing so I can run this function and test? Thanks
Nevermind, I found the problem--maybe a lack of sleep-- it was the line above it that was missing the semicolon haha.
 
marth tanaka: As Mr. Carreiro said, it is to reduce exposure and the required margin.

However, contrary to what Mr. Carreiro said, I have applied mathematical analysis before embarking on this and the results showed that this is profitable. I can filter out slippage, commission isnt a problem and I was able to manually open a new order at the close of the last one (no spread) using limit orders but for some reason the same does not work in an EA (the spread between the last close and the next open is there.

Your math is faulty and you can never filter out slippage, only manage it!

EDIT: "Doubling down", may seem to be more profitable at first glance but you have to dig in deeper into all the possible exit scenarios, and you will see that just using a single trade with a stop-loss will in the long run be a better solution.

 
marth tanaka:
As Mr. Carreiro said, it is to reduce exposure and the required margin.


However, contrary to what Mr. Carreiro said, I have applied mathematical analysis before embarking on this and the results showed that this is profitable. I can filter out slippage, commission isnt a problem and I was able to manually open a new order at the close of the last one (no spread) using limit orders but for some reason the same does not work in an EA (the spread between the last close and the next open is there.

So perhaps there is a language barrier issue here so please correct me if I am wrong... You intend to open a trade in the same direction with more volume as the price moves against the position. So for example 

1 lot Sell goes 3 pips underwater. 

You open a 2 lot sell and immediately close the one lot sell? By all accounts of your description, that is what you intend to do, correct?

 
Fernando Carreiro:

Your math is faulty and you can never filter out slippage, only manage it!

EDIT: "Doubling down", may seem to be more profitable at first glance but you have to dig in deeper into all the possible exit scenarios, and you will see that just using a single trade with a stop-loss will in the long run be a better solution.

I truly appreciate your thoughts on this as a whole but I am not here to debate if the system as a whole will work or not. I am simply trying to learn and understand how to code this in (since it is possible manually). Thank you.
 
nicholi shen:

So perhaps there is a language barrier issue here so please correct me if I am wrong... You intend to open a trade in the same direction with more volume as the price moves against the position. So for example 

1 lot Sell goes 3 pips underwater. 

You open a 2 lot sell and immediately close the one lot sell? By all accounts of your description, that is what you intend to do, correct?

Correct!