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?
Victory Day Delivers: Russia-Ukraine Ceasefire Market Cl …
Prediction Markets & Event Contracts
Warsh Drops Easing Bias, December Hike Now Above 50% -- …
Prediction Markets & Event Contracts
Six Days to Kickoff: World Cup Prediction Markets Hit $1 …
Prediction Markets & Event Contracts
Post-Summit Market Verdict: ES -1%, NQ -1.5%, 10-Year Yi …
Traders Hideout
Fabrication or Framework? Irans Denied MOU Explains the …
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