NexusFi: Find Your Edge


Home Menu

 





Questions and discussion for Sierra Chart ACSIL for Beginners


Discussion in Sierra Chart

Updated
      Top Posters
    1. looks_one Trembling Hand with 43 posts (35 thanks)
    2. looks_two mosalem2003 with 40 posts (0 thanks)
    3. looks_3 1m1k3 with 20 posts (0 thanks)
    4. looks_4 bradhouser with 6 posts (9 thanks)
      Best Posters
    1. looks_one bobwest with 3.5 thanks per post
    2. looks_two bradhouser with 1.5 thanks per post
    3. looks_3 TropicalTrader with 1 thanks per post
    4. looks_4 Trembling Hand with 0.8 thanks per post
    1. trending_up 27,842 views
    2. thumb_up 53 thanks given
    3. group 30 followers
    1. forum 119 posts
    2. attach_file 25 attachments




 
Search this Thread

Questions and discussion for Sierra Chart ACSIL for Beginners

  #71 (permalink)
VinceField
Coronel Vivida, Parana/Brazil
 
Posts: 48 since Oct 2020
Thanks Given: 17
Thanks Received: 18

I'm looking for some suggestions or advice for building a divergence indicator for oscillators such as the 3/10 oscillator. The idea is to have two functions. One is to alert a warning signal on every bar when a divergence is forming - so if the oscillator has a lower high, the moment price makes a higher high, the signal begins and prints until either the divergence is gone (the oscillator catches up and also makes a higher high) or the entry signal appears. The entry signal is the slope of the oscillator reversing. Thanks!

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
What broker to use for trading palladium futures
Commodities
REcommedations for programming help
Sierra Chart
How to apply profiles
Traders Hideout
Quant vue
Trading Reviews and Vendors
Cheap historycal L1 data for stocks
Stocks and ETFs
 
  #72 (permalink)
mosalem2003
Toronto
 
Posts: 103 since Apr 2019
Thanks Given: 106
Thanks Received: 23



There are two filled orders in the example shown in image - order 1 is the first filled, and order 2 is the second filled, each has its own attached stop order as shown.

Currently if stop 2 is hit, then order 1 exits and order two remains with the big stop of order 1 --
Is there a way to exit the nearest order 1 when hitting its stop ...?

These orders should be attached orders and not sure they work to stop other orders -- in this case, stop 2 is used to exit order 1 though it is attached to order 2 ?

I need to understand the logic of Sierra handling multi orders with their own attached stop or limits --- simply is there a way to exit the nearest if any stop is filled ?

Attached Thumbnails
Click image for larger version

Name:	image_45.png
Views:	40
Size:	28.0 KB
ID:	327007  
Reply With Quote
  #73 (permalink)
mosalem2003
Toronto
 
Posts: 103 since Apr 2019
Thanks Given: 106
Thanks Received: 23


What is the best code practice for the following scenario:

1- The white line is used as a trigger for switch long or short in this case.
2- If closed above the line , then we are long
3- We save the price level corresponding to the white line while the break point ..
4- If price closed below that level, then it is switching to short...

Since we will save versus each call of the trading system, I think persistent variables can be used.
What can be the best code practice in this case ? I am not an expert with persistent variables and tried several times but with no luck -- can u provide a code snippet that I can use an example to code the above scenario ?

Reply With Quote
  #74 (permalink)
 Trembling Hand 
Melbourne, Land of Oz
 
Experience: Advanced
Platform: Sierra Chart, CQG
Broker: CQG
Trading: HSI
Posts: 246 since Jun 2011
Thanks Given: 28
Thanks Received: 360


mosalem2003 View Post
- can u provide a code snippet that I can use an example to code the above scenario ?

Far quicker to supply what you have already coded to see where you went wrong than a dump of 1 to 2 lines of code. Which will start multiple back and forth questions.

Follow me on Twitter Started this thread Reply With Quote
  #75 (permalink)
mosalem2003
Toronto
 
Posts: 103 since Apr 2019
Thanks Given: 106
Thanks Received: 23

Thanks a lot for your response.
I have added the persistent variables to hold the price level at a break of the high or the low to retain their values between function calls with each new bar
 
Code
float & DCHB = sc.GetPersistentFloat(1);
	float & DCLB = sc.GetPersistentFloat(2);
Then I have added this main code to decide long or short and it seems to be working for now
 
Code
//close above DC high 
	if ( sc.Close[sc.Index - 1] > DC_High[sc.Index - 2] && sc.Close[sc.Index - 2] <= DC_High[sc.Index - 3] && S.GetYesNo() && !L.GetYesNo() )
		
	{
		
		DCHB = DC_High[sc.Index - 2];
		L.SetYesNo(1);
		x.SetYesNo(1);
		S.SetYesNo(0);
		sc.FlattenAndCancelAllOrders();
		LogString.Format("DC high break & Long: %d & Short: %d & DCHB: %f ", L.GetYesNo(), S.GetYesNo(), DCHB);
		sc.AddMessageToLog (LogString, 0);
		
	}
	
		if ( L.GetYesNo() && sc.Close[sc.Index-1] < DCHB  && x.GetYesNo() )
	{ 
       S.SetYesNo(1);
	   L.SetYesNo(0);
	   x.SetYesNo(0);
	   sc.FlattenAndCancelAllOrders();
	   LogString.Format("back inside value return to short & Long: %d & Short: %d & DCHB: %f ", L.GetYesNo(), S.GetYesNo(), DCHB);
	   sc.AddMessageToLog (LogString, 0);
	}
	
		//close below DC low 
	if ( sc.Close[sc.Index - 1] < DC_Low[sc.Index - 2] && sc.Close[sc.Index - 2] <= DC_Low[sc.Index - 3] && L.GetYesNo() && !S.GetYesNo() )
		
	{	 
		DCLB = DC_Low[sc.Index - 2];
		S.SetYesNo(1);
		L.SetYesNo(0);
		y.SetYesNo(1);
		sc.FlattenAndCancelAllOrders();
		
		LogString.Format("DC Low break & Long: %d & Short: %d & DCHB: %f ", L.GetYesNo(), S.GetYesNo(), DCLB);
		sc.AddMessageToLog (LogString, 0);
		
	}
	
	
	if (S.GetYesNo() && sc.Close[sc.Index-1] > DCLB && y.GetYesNo() ) 
	{
		L.SetYesNo(1);
		S.SetYesNo(0);
		y.SetYesNo(0);
		sc.FlattenAndCancelAllOrders();
		LogString.Format("back inside value return to long & Long: %d & Short: %d & DCHB: %f ", L.GetYesNo(), S.GetYesNo(), DCLB);
		sc.AddMessageToLog (LogString, 0);
	}
The new issue might be related to the floating point imprecision as when there is a bar that has <close =low > or <close ==high> the code doesn't recognize the event like in the bar circled in the image ..

Also how to let the code know the initial condition long or short , once we activate the trading system on the chart -- does it make backward calculations on all the bars in the chart to determine the initial condition ? or we need to add an input and the user can define the initial long or short status ?
Long or short here is a status that is then used to let the algo enters orders ..

Thanks for ur help and support


Reply With Quote
  #76 (permalink)
 Trembling Hand 
Melbourne, Land of Oz
 
Experience: Advanced
Platform: Sierra Chart, CQG
Broker: CQG
Trading: HSI
Posts: 246 since Jun 2011
Thanks Given: 28
Thanks Received: 360

What are all these? And what are you trying to achieve with them?

 
Code
L.SetYesNo(1);
x.SetYesNo(1);
S.SetYesNo(0);
Also are you sure they are doing what you expect? I'm guessing they are SCInputRef variables and you want them to act as persistent bool variables? If they are I've never seen SCInputRef used like that.... not to say they don't work but,

You should use PersistentInt and set them to 0 or 1

Follow me on Twitter Started this thread Reply With Quote
Thanked by:
  #77 (permalink)
mosalem2003
Toronto
 
Posts: 103 since Apr 2019
Thanks Given: 106
Thanks Received: 23


Trembling Hand View Post
What are all these? And what are you trying to achieve with them?

 
Code
L.SetYesNo(1);
x.SetYesNo(1);
S.SetYesNo(0);
Also are you sure they are doing what you expect? I'm guessing they are SCInputRef variables and you want them to act as persistent bool variables? If they are I've never seen SCInputRef used like that.... not to say they don't work but,

You should use PersistentInt and set them to 0 or 1




The code is working using the persistent float that successfully retain the price level at the break.
 
Code
float & DCHB = sc.GetPersistentFloat(1);
	float & DCLB = sc.GetPersistentFloat(2);
L, S, x, y are boolean inputref that are used to make transitions between long and short based on the <if> conditions.

 
Code
       SCInputRef L = sc.Input[12];
	SCInputRef S = sc.Input[13];
	SCInputRef x = sc.Input[14];
	SCInputRef y = sc.Input[15];
I am noting a new issue that is non-related to persistent variables --It is as explained in the chart image and it is related to floating point imprecision. This is handled in Spreadsheet by rounding to the ticksize -- simply if there is a bar that has the low equals the close or the high equals to the close, the code starts not to work for the break condition.
 
Code
if ( sc.Close[sc.Index - 1] > DC_High[sc.Index - 2] && sc.Close[sc.Index - 2] <= DC_High[sc.Index - 3] && S.GetYesNo() && !L.GetYesNo() )

Reply With Quote
  #78 (permalink)
bradhouser
Northern California where the girls are warm
 
Posts: 122 since Nov 2010
Thanks Given: 15
Thanks Received: 72


mosalem2003 View Post

The new issue might be related to the floating point imprecision as when there is a bar that has <close =low > or <close ==high> the code doesn't recognize the event like in the bar circled in the image ..

You can use the sc.FormattedEvaluate() function to do the comparisons without floating point imprecision.

Reply With Quote
Thanked by:
  #79 (permalink)
mosalem2003
Toronto
 
Posts: 103 since Apr 2019
Thanks Given: 106
Thanks Received: 23

Is there any setup for the entire code to avoid this problem - The issue should be well known - or this will need to change every comparison of the price crossing or breaking a line using that complex function ?

Reply With Quote
  #80 (permalink)
 Trembling Hand 
Melbourne, Land of Oz
 
Experience: Advanced
Platform: Sierra Chart, CQG
Broker: CQG
Trading: HSI
Posts: 246 since Jun 2011
Thanks Given: 28
Thanks Received: 360



mosalem2003 View Post
L, S, x, y are boolean inputref that are used to make transitions between long and short based on the <if> conditions.
 
Code
       SCInputRef L = sc.Input[12];
	SCInputRef S = sc.Input[13];
	SCInputRef x = sc.Input[14];
	SCInputRef y = sc.Input[15];

They are not meant to be used like that. In the thousands of lines of code by SC I've never seen them use the SCInputRef as a variable. You should be using persistent int.



mosalem2003 View Post
Is there any setup for the entire code to avoid this problem - The issue should be well known - or this will need to change every comparison of the price crossing or breaking a line using that complex function ?

The issue is well known that's why there is this solution.
This,
 
Code
if ( sc.Close[sc.Index - 1] > DC_High[sc.Index - 2] && sc.Close[sc.Index - 2] <= DC_High[sc.Index - 3] && S.GetYesNo() && !L.GetYesNo() )
becomes this,
 
Code
if ( sc.FormattedEvaluate(sc.Close[sc.Index - 1], sc.BaseGraphValueFormat, GREATER_OPERATOR, DC_High[sc.Index - 2], sc.BaseGraphValueFormat) == 1 
&& sc.FormattedEvaluate(sc.Close[sc.Index - 2], sc.BaseGraphValueFormat, LESS_EQUAL_OPERATOR, DC_High[sc.Index - 3], sc.BaseGraphValueFormat) == 1
&& S.GetYesNo() 
&& !L.GetYesNo() )
Though I really wouldn't use S.GetYesNo() etc

Follow me on Twitter Started this thread Reply With Quote
Thanked by:




Last Updated on April 23, 2024


© 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