NexusFi: Find Your Edge


Home Menu

 





StopLoss order canceled on every bar open


Discussion in MultiCharts

Updated
    1. trending_up 3,155 views
    2. thumb_up 0 thanks given
    3. group 1 followers
    1. forum 3 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
Dvdkite
Trieste Italy
 
Posts: 162 since Feb 2018
Thanks Given: 131
Thanks Received: 25

Hello,

Inside my strategy I need to set an OCO order with Stoploss and Target immediately after the system has opened a position.
I NEED to set the Stoploss only at the close of the candle where the entry order has been filled, because i need some time for the exact calculation of the stop loss value (in my case the TRADEstopLoss value ).
So I thought to simply put the condition " if barstatus = 2 " before the stop order and this worked just fine in the backtest, but TODAY in realtime (with real money) testing when the system entered a position it was able to set up the target easily but the STOP loss order keeping to be set and then rejected/canceled at the end of every bar.
The system is running over a 100tick chart and really at the end of every bar , when market position is 1 or -1, it continued to set the stop loss and cancel it the second later.
So basically I only had a target on the chart, the stop loss appear for a millisecond and then disappear the second after and by this way I cannot protect myself from sudden movement.

This is the code I'm using ( short position example ):

 
Code
if marketposition = -1 then 
    begin
	if currentcontracts = 1 then 
		begin
			buytocover ( " Target SE ")1 contract next bar at entryprice - (TargetPoints * TickSize ) limit;
			if  barstatus = 2 then buytocover ( " Stop SE ")1 contract next bar at TRADEstopLoss + StopOffSet stop;
			if time >= Time_CLOSE_SESSION - 10 and time  < Time_CLOSE_SESSION - 1 then buytocover("SE CLOSE SESSION") 1 ontract next bar at market;

		end; 
								
......................................
...............................
.............
Do you have any suggestion about how can I make it work? I just need to send the stoploss order at the end of the bar (that's why I used barstatus = 2)....
Thanks

David


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Day 96 Missiles Hit Kuwait and Bahrain: June 15 Peace at …
Prediction Markets & Event Contracts
April 2026 Jobs Report: +115k vs +65k Expected
Traders Hideout
Thanks Mike. Godspeed.
The Elite Circle
CFTC Opens First COT Report Review in 20 Years -- Asks W …
Traders Hideout
Trump Truth Social Fires Hormuz From 10% to 59% -- Arsen …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
NexusFi site changelog and issues/problem reporting
16 thanks
Darmok and Jalad at Tanagra
3 thanks
CME Expands 24/7 Trading to WTI Crude Oil and Gold -- We …
1 thanks
Big Mike in Ecuador
1 thanks
30 Sessions
1 thanks
  #2 (permalink)
Dvdkite
Trieste Italy
 
Posts: 162 since Feb 2018
Thanks Given: 131
Thanks Received: 25

Hello guys,

waiting for a reply I made some tests .... I think I could solve by usind "barssinceentry > 0" instead of "barstatus = 2".... Anyway as this should affect just the timing to set the stop loss over a very fast chart (100tick) I was wondering why the backtest shows a little difference in results by using one condition rather than the other.

Thanks,

David


Reply With Quote
  #3 (permalink)
Dvdkite
Trieste Italy
 
Posts: 162 since Feb 2018
Thanks Given: 131
Thanks Received: 25


I confirm that the solution proposed above is actually working in real money test.

However it is so strange that Multicharts is one of the most used platform for sistemac trading and there only a few person here to discuss about technical details...just my thought of the morning.

Have a nice day everyone.


Reply With Quote
  #4 (permalink)
Dvdkite
Trieste Italy
 
Posts: 162 since Feb 2018
Thanks Given: 131
Thanks Received: 25


Dvdkite View Post
Hello,

Inside my strategy I need to set an OCO order with Stoploss and Target immediately after the system has opened a position.
I NEED to set the Stoploss only at the close of the candle where the entry order has been filled, because i need some time for the exact calculation of the stop loss value (in my case the TRADEstopLoss value ).
So I thought to simply put the condition " if barstatus = 2 " before the stop order and this worked just fine in the backtest, but TODAY in realtime (with real money) testing when the system entered a position it was able to set up the target easily but the STOP loss order keeping to be set and then rejected/canceled at the end of every bar.
The system is running over a 100tick chart and really at the end of every bar , when market position is 1 or -1, it continued to set the stop loss and cancel it the second later.
So basically I only had a target on the chart, the stop loss appear for a millisecond and then disappear the second after and by this way I cannot protect myself from sudden movement.

This is the code I'm using ( short position example ):

 
Code
if marketposition = -1 then 
    begin
	if currentcontracts = 1 then 
		begin
			buytocover ( " Target SE ")1 contract next bar at entryprice - (TargetPoints * TickSize ) limit;
			if  barstatus = 2 then buytocover ( " Stop SE ")1 contract next bar at TRADEstopLoss + StopOffSet stop;
			if time >= Time_CLOSE_SESSION - 10 and time  < Time_CLOSE_SESSION - 1 then buytocover("SE CLOSE SESSION") 1 ontract next bar at market;

		end; 
								
......................................
...............................
.............
Do you have any suggestion about how can I make it work? I just need to send the stoploss order at the end of the bar (that's why I used barstatus = 2)....
Thanks

David

I almost solved the problem using " barssinceentry > 0" instead of " barstatus = 2 "... it is actually waiting for the close of the candle to put the stop loss... it is actually acceptable for me ( it is on 100 tick bar so fast enough to be placed in time ).

Anyway the MC section of this forum is so empty..... Don't know why. Mc is still one of the most used platform for sistematic trading....


Reply With Quote




Last Updated on July 24, 2020


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts