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,129 views
    2. thumb_up 0 thanks given
    3. group 2 followers
    1. forum 3 posts
    2. attach_file 0 attachments




 
Search this Thread

how to flat possition at the end of day?

  #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?
ZombieSqueeze
Platforms and Indicators
MC PL editor upgrade
MultiCharts
Trade idea based off three indicators.
Traders Hideout
REcommedations for programming help
Sierra Chart
How to apply profiles
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
31 thanks
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
20 thanks
GFIs1 1 DAX trade per day journal
17 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


© 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