Login Page - Create Account

Support Board


Date/Time: Tue, 16 Apr 2024 19:35:10 +0000



Trade Entry/Exit Markers Move with Each New Bar

View Count: 507

[2020-09-09 09:07:41]
BlakJak - Posts: 108
Perhaps someone has come across this problem before. I have a study which I am testing in replay and backtest (same result) that opens a trade as a Market Order then closes later based on some criteria. The problem I am facing is that the trade markers are moving with each bar update so that at the end of the replay, all the trade markers are squashed up against the right hand side of the chart.

I am reusing a lot of code that I know works in other studies, but I guess I have something wrong somewhere.

I know the SCE team doesn't help with debugging users' code but in case anyone came across this strange issue before I would appreciate a pointer in the right direction.
[2020-09-09 13:29:08]
Sierra Chart Engineering - Posts: 104368
We do not see how this is a problem in your own code. This looks like a problem with the timestamp of the fill.

There was a recent issue like this but it has been resolved.

Not sure why you would still have an issue. Do you notice the same issue when doing manual trading?
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
Date Time Of Last Edit: 2020-09-09 13:29:36
[2020-09-09 16:04:54]
BlakJak - Posts: 108
I think it is the study but I cannot figure out why.

If I load the study and manually enter a trade then the markers moves just like the study opened trades. The markers move to the sc.Index - 1 bar with each new bar. As soon as I remove the study the markers start to scroll backwards with every new bar as they should.


My study is using 8 subgraphs. On some of them I am using multiple Arrays[] as well.

I have checked for memory problems but do not find any (although I know I could have missed something).

Here are my SetDefaults:

  sc.MaintainVolumeAtPriceData = true;
  sc.UpdateAlways = false; // Default but let's make sure.

  // Trading Defaults
  sc.AllowMultipleEntriesInSameDirection = false;
  sc.SupportReversals = false;
  sc.AllowOppositeEntryWithOpposingPositionOrOrders = false;
  sc.SupportAttachedOrdersForTrading = false;
  sc.CancelAllOrdersOnEntriesAndReversals = true;
  sc.AllowEntryWithWorkingOrders = false;
  sc.CancelAllWorkingOrdersOnExit = false;
  sc.AllowOnlyOneTradePerBar = true;
  sc.MaintainTradeStatisticsAndTradesData = true;
  sc.SupportAttachedOrdersForTrading = true;
  sc.UseGUIAttachedOrderSetting = true;
  sc.MaximumPositionAllowed = 10;
  sc.AlertOnlyOncePerBar = true;
  sc.ResetAlertOnNewBar = true;
  sc.TransparencyLevel = 50;

Running 2162.

Any other ideas?
[2020-09-09 16:35:05]
BlakJak - Posts: 108
Can the Subgraph Arrays be referenced for the first time in a function that is called by the study during each call or must I reference the Arrays for the first time in SetDefaults for the memory to be properly allocated?
[2020-09-09 18:32:46]
BlakJak - Posts: 108
I have traced the problem to this function. Could it be the

inline void GSBSignal::CloseLessPrevLowD(const SCStudyInterfaceRef sc, const int& daysBack, SCSubgraphRef sg, const int& idx) const
{
  float o, h, l, c;

  sc.GetOHLCForDate((sc.BaseDateTimeIn[idx]).SubtractDays(daysBack), o, h, l, c);
  sg.Data[idx] = sc.Close[idx] - l;
}


I commented out the sc.GetOHLCForDate() function and the code starting working fine without the markers moving forward.

Can you please check that function for a bug?
[2020-09-09 18:49:14]
BlakJak - Posts: 108
I further traced the problem to the call to .SubtractDays()

When I changed

(sc.BaseDateTimeIn[idx]).SubtractDays(daysBack)

to

(sc.BaseDateTimeIn[idx])


the problem stopped.

Am I using that incorrectly?
[2020-09-09 18:53:45]
BlakJak - Posts: 108
Changing the code to this:

sc.GetOHLCForDate(sc.BaseDateTimeIn[idx] - SCDateTime::DAYS(1), o, h, l, c);


appears to have resolved the problem.

Please advise why the '.SubtractDays()' function did not work.
[2020-09-09 20:41:22]
Sierra Chart Engineering - Posts: 104368
Yes this is definitely not correct:

(sc.BaseDateTimeIn[idx]).SubtractDays(daysBack)

You are altering the chart bar Date-Times.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
[2020-09-10 09:15:15]
BlakJak - Posts: 108
OK - noted and thanks for the feedback. I thought the data in the SC arrays would be const so it would not have been possible to modify such critical data.

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account