Close Positions Immediately

Created at 18 Jun 2014, 12:13
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
DA

davidp13

Joined 06.05.2014

Close Positions Immediately
18 Jun 2014, 12:13


I need some guidance on how to close position immediately and not on the next open bar. I have tested my code in both OnTick and OnBar, but the effect stays the same. The time frame I use is 1 hour.

Code:

 if (longPosition != null && _cciclose.Result.Last(1) < 0 && valueClose <= valueMa)
            {
                ClosePosition(longPosition);

 

Thanks
           


@davidp13
Replies

breakermind
18 Jun 2014, 12:33

RE:

davidp13 said:

I need some guidance on how to close position immediately and not on the next open bar. I have tested my code in both OnTick and OnBar, but the effect stays the same. The time frame I use is 1 hour.

Code:

 if (longPosition != null && _cciclose.Result.Last(1) < 0 && valueClose <= valueMa)
            {
                ClosePosition(longPosition);

 

Thanks
           

 

Hi,

set OnTick when tick change then close all positions

if the tick does not change it, nothing happens, set yourself on the chart period 1tick and see how it works(in the evening when there is little traffic), everything changes for the tick

tick is the smallest interval - probably

so I explain it myself.

Regards

 


@breakermind