NexusFi: Find Your Edge


Home Menu

 





ACSIL_checking condition fulfillments in last 15 bars


Discussion in Sierra Chart

Updated
    1. trending_up 585 views
    2. thumb_up 0 thanks given
    3. group 2 followers
    1. forum 1 posts
    2. attach_file 0 attachments




 
Search this Thread

ACSIL_checking condition fulfillments in last 15 bars

  #1 (permalink)
klumpi
Budapest, Hungary
 
Posts: 1 since May 2023
Thanks Given: 0
Thanks Received: 0

Hi,

I created a code in ACSIL and I would like to ask some assistance how to code an additional condition. What I have done so far is I created three types of moving averages (RSI, EMA39, SMA) and defined a condition accordig to which the color of the bar ha to be changed into green once SMA9 crosses EMA39 from below. Now I want to add a new condition, according to which the crossover is valid only in case the value of RSI was below at 32 at least once in last 15 bars. How to modify the code with this condition? Thanks in advance

Here is the existing code:
#include "sierrachart.h"

SCDLLName("Crossover")

SCSFExport scsf_RSI(SCStudyInterfaceRef sc)
{
SCSubgraphRef RSI = sc.Subgraph[0];
SCSubgraphRef EMA39 = sc.Subgraph[1];
SCSubgraphRef SMA9 = sc.Subgraph[2];
SCSubgraphRef Cross = sc.Subgraph[3];
SCSubgraphRef Subgraph_Cross = sc.Subgraph[4];

if (sc.SetDefaults)
{
// Set the defaults
sc.GraphName = "Crossover";
sc.GraphRegion = 0;
//sc.Subgraph[0].Name = "RSI14";
//sc.Subgraph[1].Name = "EMA39";
//sc.Subgraph[2].Name = "SMA9";
//sc.Subgraph[3].Name = "Cross";

//sc.Subgraph[0].DrawStyle = DRAWSTYLE_LINE;
//sc.Subgraph[1].DrawStyle = DRAWSTYLE_LINE;
//sc.Subgraph[2].DrawStyle = DRAWSTYLE_LINE;
//sc.Subgraph[3].DrawStyle = DRAWSTYLE_LINE;

Subgraph_Cross.Name = "movavgcross";
Subgraph_Cross.DrawStyle = DRAWSTYLE_COLOR_BAR;
Subgraph_Cross.PrimaryColor = RGB(0,255,0);
sc.AutoLoop = 1;

return;
}
// RSI definíció.

sc.RSI(sc.BaseDataIn[SC_LAST], RSI, MOVAVGTYPE_WILDERS, 14);

// EMA39 definíció.

sc.ExponentialMovAvg(RSI, EMA39, sc.Index, 39);

//SMA9 definíció

sc.SimpleMovAvg(RSI, SMA9, sc.Index, 9);


// Do data processing
if
( (sc.CrossOver(SMA9, EMA39) == CROSS_FROM_BOTTOM)
)
Subgraph_Cross[sc.Index] = 1;
else
Subgraph_Cross[sc.Index] = 0;

}

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Quantum physics & Trading dynamics
The Elite Circle
What You Know vs How much you know about it
Traders Hideout
Zombie Indicator Help
NinjaTrader
static margin on the right side of a chart
NinjaTrader
ZombieSqueeze
Platforms and Indicators
 
  #2 (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

Create a condition to check if the RSI < 30. If so store the bar index in a persistent int (RSILessThan30). Then add another condition to your crossover conditional check. if current bar index - RSILessThan30 =< 15

Follow me on Twitter Reply With Quote




Last Updated on May 24, 2023


© 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