NexusFi: Find Your Edge


Home Menu

 





StopLoss order canceled on every bar open


Discussion in MultiCharts

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




 
Search this Thread

StopLoss order canceled on every bar open

  #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?
Cheap historycal L1 data for stocks
Stocks and ETFs
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
MC PL editor upgrade
MultiCharts
How to apply profiles
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
What is Markets Chat (markets.chat) real-time trading ro …
72 thanks
Spoo-nalysis ES e-mini futures S&P 500
55 thanks
Just another trading journal: PA, Wyckoff & Trends
28 thanks
Bigger Wins or Fewer Losses?
24 thanks
The Program
16 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


© 2024 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 - Privacy Policy - Downloads - Top
no new posts