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 2,001 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?
requesting .nrd replay files from 2026 spy and qqq
The Elite Circle
RTH vs ETH: when your chart and Volume Profile trading h …
NinjaTrader
No book, only a stair: journaling fills where price move …
Cryptocurrency
Trump Media to sell instant access to market-moving soci …
Traders Hideout
EA
Platforms and Indicators
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Mes vs MNQ
6 thanks
NexusFi site changelog and issues/problem reporting
5 thanks
BERN ALGOS algo trading journal
3 thanks
TopStep Trader disappointment
2 thanks
Running trading strategies on a VPS
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