NexusFi: Find Your Edge


Home Menu

 





how to flat possition at the end of day?


Discussion in Sierra Chart

Updated
      Top Posters
    1. looks_one ludvig with 1 posts (0 thanks)
    2. looks_two nirvikalpasamadhi with 1 posts (0 thanks)
    3. looks_3 Quick Summary with 1 posts (0 thanks)
    4. looks_4 mkata with 1 posts (0 thanks)
    1. trending_up 1,911 views
    2. thumb_up 0 thanks given
    3. group 2 followers
    1. forum 3 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
nirvikalpasamadhi
prague
 
Posts: 167 since Jan 2017
Thanks Given: 2
Thanks Received: 47

i have written a trading system for bectesting, the only thing that doesnt work is closing the possition at the end of the day (or at a particular time specified in my input)

the code that i use for flat is this

 
Code
		s_SCPositionData pozice;
		sc.GetTradePosition(pozice);

		if (pozice.PositionQuantity != 0) {
			if (sc.BaseDateTimeIn[sc.Index].GetTime() >= konec_rth.GetTime()) {
				sc.FlattenAndCancelAllOrders();
			}
very sipmle and clead, but it doesnt work and the possitiong is still open even after the specified time "konec-rth" is my variable input where i specify the time

does anyone can give me a hint how to make it work?

otherwise all the bectest are useless


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Trump Media to sell instant access to market-moving soci …
Traders Hideout
After $87M Settles NO: Irans Nuclear Redline Sets Up the …
Prediction Markets & Event Contracts
CFTC Rewrites the Rulebook -- Kalshi Cracks $1B Non-Spor …
Prediction Markets & Event Contracts
The June 15 Resolution Trap: Irans Agreed Text Still Pri …
Prediction Markets & Event Contracts
$500M Riding on World Cup 2026: France/Spain Co-Favored …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
NexusFi site changelog and issues/problem reporting
13 thanks
Darmok and Jalad at Tanagra
3 thanks
Big Mike in Ecuador
1 thanks
30 Sessions
1 thanks
  #3 (permalink)
 mkata 
Columbus, OH
 
Experience: Intermediate
Platform: SierraChart
Trading: CL
Posts: 35 since May 2013
Thanks Given: 153
Thanks Received: 24


sc.BaseDateTimeIn[sc.Index] is equal to the starting time of a bar.

I believe if you remove the .GetTime() from this member it should work.


Reply With Quote
  #4 (permalink)
ludvig
russia kaliningrad
 
Posts: 19 since Jan 2011
Thanks Given: 0
Thanks Received: 21

Recommend under such circumstances use IDE: https://www.sierrachart.com/index.php?page=doc/UsingVisualCPlusPlus.php
and DEBUG mode.

Simply create a breakpoint and look to which values your variables are equal.
https://www.sierrachart.com/index.php?page=doc/StepByStepACSILDebugging.php


Reply With Quote




Last Updated on November 24, 2017


© 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