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 Quick Summary with 1 posts (0 thanks)
    2. looks_two mkata with 1 posts (0 thanks)
    3. looks_3 ludvig with 1 posts (0 thanks)
    4. looks_4 nirvikalpasamadhi with 1 posts (0 thanks)
    1. trending_up 1,849 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?
Kharg Island at 6%, Regime Fall at 1.5% -- The Black Swa …
Prediction Markets & Event Contracts
Trump Truth Social Fires Hormuz From 10% to 59% -- Arsen …
Prediction Markets & Event Contracts
One Wallet Made $200K in Hours: AP Probes Polymarket Cea …
Prediction Markets & Event Contracts
Iran Lebanon Problem Kills Switzerland Talks, Brent at $ …
Prediction Markets & Event Contracts
CFTC Opens First COT Report Review in 20 Years -- Asks W …
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Big Mike in Ecuador
205 thanks
Sober Journey With S&P
21 thanks
30 Sessions
20 thanks
Volume Indicators
8 thanks
Thanks Mike. Godspeed.
7 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