Login Page - Create Account

Support Board


Date/Time: Thu, 25 Apr 2024 09:16:14 +0000



[Programming Help] - Assistance with converting study alert code to acsil

View Count: 624

[2022-08-28 18:56:31]
Ticks - Posts: 174
I need some assistance to convert this study alert code found at the link below into ACSIL for use in a strat.
Renko Bar Charts: Renko Reversal Bar Alert Formula
For bullish:
if (place converted code )//AND(ID0.SG23[-1] > ID0.SG22[-1] , ID0.SG23 < ID0.SG22)
  {
    
  
  }

For bearish:
if (place converted code )//AND(ID0.SG23[-1] < ID0.SG22[-1] , ID0.SG23 > ID0.SG22)
  {
    
  
  }

Or if anyone has and is willing to share the ACSIL code to detecting the reversal bar on a Renko chart.
Date Time Of Last Edit: 2022-08-29 00:18:48
[2022-09-04 23:33:44]
Ticks - Posts: 174
Well, it's been a week with 45 views and still no sample code or suggestions.
This must be way harder to convert than I thought.
I guess even the coding experts here are stumped on this one.
[2022-09-05 07:10:59]
User431178 - Posts: 410
Assuming you are using autoloop

For bullish:
if (sc.BaseDataIn[SC_RENKO_CLOSE][sc.Index] > sc.BaseDataIn[SC_RENKO_OPEN][sc.Index]
&& sc.BaseDataIn[SC_RENKO_CLOSE][sc.Index - 1] < sc.BaseDataIn[SC_RENKO_OPEN][sc.Index -1])
{


}

For bearish:
if (sc.BaseDataIn[SC_RENKO_CLOSE][sc.Index] < sc.BaseDataIn[SC_RENKO_OPEN][sc.Index]
&& sc.BaseDataIn[SC_RENKO_CLOSE][sc.Index - 1] > sc.BaseDataIn[SC_RENKO_OPEN][sc.Index -1])
{


}


or you maybe you could use sc.FormattedEvaluate()


For bullish:
if (sc.FormattedEvaluate(sc.BaseDataIn[SC_RENKO_CLOSE][sc.Index], sc.BaseGraphValueFormat, GREATER_OPERATOR, sc.BaseDataIn[SC_RENKO_OPEN][sc.Index], sc.BaseGraphValueFormat)
&& sc.FormattedEvaluate(sc.BaseDataIn[SC_RENKO_CLOSE][sc.Index - 1], sc.BaseGraphValueFormat, LESS_OPERATOR, sc.BaseDataIn[SC_RENKO_OPEN][sc.Index - 1], sc.BaseGraphValueFormat))
{


}


For bearish:
if (sc.FormattedEvaluate(sc.BaseDataIn[SC_RENKO_CLOSE][sc.Index], sc.BaseGraphValueFormat, LESS_OPERATOR, sc.BaseDataIn[SC_RENKO_OPEN][sc.Index], sc.BaseGraphValueFormat)
&& sc.FormattedEvaluate(sc.BaseDataIn[SC_RENKO_CLOSE][sc.Index - 1], sc.BaseGraphValueFormat, GREATER_OPERATOR, sc.BaseDataIn[SC_RENKO_OPEN][sc.Index - 1], sc.BaseGraphValueFormat))
{


}

[2022-09-05 14:08:13]
Ticks - Posts: 174
@User431178
Thanks for the code posting.
I tried both of your methods and the code still steps inside the If statement on every tick.
Not when the Renko reversal bar closes.
I even tried adding in
&& sc.GetBarHasClosedStatus() == BHCS_BAR_HAS_CLOSED
with no success.

I'm building with SC and debugging the cpp file with VS.
[2022-09-05 14:29:09]
User907968 - Posts: 802
SCSFExport scsf_RenkoReversal(SCStudyInterfaceRef sc)
{
  auto& sg_RevBuy = sc.Subgraph[0];
  auto& sg_RevSell = sc.Subgraph[1];

  if (sc.SetDefaults)
  {
    sc.GraphName = "Renko Reversal";
    sc.GraphRegion = 0;
    sc.AutoLoop = 0;
    
    sg_RevBuy.Name = "Renko Buy Reversal";
    sg_RevBuy.DrawStyle = DRAWSTYLE_ARROW_UP;
    sg_RevBuy.LineWidth = 5;
    sg_RevBuy.PrimaryColor = COLOR_GREEN;

    sg_RevSell.Name = "Renko Sell Reversal";
    sg_RevSell.DrawStyle = DRAWSTYLE_ARROW_DOWN;
    sg_RevSell.LineWidth = 5;
    sg_RevSell.PrimaryColor = COLOR_RED;

    return;
  }

  for (auto index = sc.UpdateStartIndex; index < sc.ArraySize; ++index)
  {
    if (sc.GetBarHasClosedStatus(index) != BHCS_BAR_HAS_CLOSED)
      continue;

    if (sc.BaseDataIn[SC_RENKO_CLOSE][index] > sc.BaseDataIn[SC_RENKO_OPEN][index]
      && sc.BaseDataIn[SC_RENKO_CLOSE][index - 1] < sc.BaseDataIn[SC_RENKO_OPEN][index - 1])
    {
      sg_RevBuy[index] = sc.Low[index] - 5 * sc.TickSize;
      sg_RevSell[index] = 0.0f;
    }

    if (sc.BaseDataIn[SC_RENKO_CLOSE][index] < sc.BaseDataIn[SC_RENKO_OPEN][index]
      && sc.BaseDataIn[SC_RENKO_CLOSE][index - 1] > sc.BaseDataIn[SC_RENKO_OPEN][index - 1])
    {
      sg_RevSell[index] = sc.High[index] + 5 * sc.TickSize;
      sg_RevBuy[index] = 0.0f;
    }
  }
}

Try the above code.
Date Time Of Last Edit: 2022-09-05 14:30:57
imagerenko_reversal.png / V - Attached On 2022-09-05 14:28:26 UTC - Size: 61.76 KB - 85 views
[2022-09-05 14:50:40]
Ticks - Posts: 174
@User907968

That worked.
Thank you so much for the study code.
I had been working on this for weeks before finally admitting defeat and asking for help.
Too bad the board doesn't have a "Tip Jar" feature.

To pay it forward.
I attached your study code into a .cpp for future people needing help.
Date Time Of Last Edit: 2022-09-05 14:59:54
attachmentRenkoReversal.cpp - Attached On 2022-09-05 14:57:19 UTC - Size: 1.64 KB - 83 views
[2022-09-06 23:39:36]
OctoPi - Posts: 13
I believe you may get your coding needs solved in 15-20 minutes instead of weeks with our software.
Check it out, we are still looking for a few beta testers.

EASY Automated Back-testing. We are licensing the software for $0 for limited time.
[2022-09-30 18:44:14]
User600819 - Posts: 43
@TICKS

I have zero experience with cpp files. I tried to compile your cpp file, but I received an error message. Would it be possible to post the dll version? Thanks for your paying it forward!
[2022-09-30 23:35:13]
Ticks - Posts: 174
@User600819
Do not use "Remote Build" to compile the cpp file.
I have attached the dll.
It is compiled with version 2431.
If you have a version below that, you may have to complete the cpp compile with your version.

A screenshot of the study indicator is attached also.
Date Time Of Last Edit: 2022-10-01 01:30:46
attachmentRenkoReversal_64.dll - Attached On 2022-09-30 23:29:42 UTC - Size: 90 KB - 74 views
imagerenko reversal signal.PNG / V - Attached On 2022-09-30 23:39:24 UTC - Size: 74.47 KB - 67 views
[2022-10-01 00:10:13]
Infinite - Posts: 134
TICKS

could u share the dll with me or an actual CPP file that will compile.
[2022-10-01 00:22:41]
Ticks - Posts: 174
@Infinite

The dll is attached in post 9
If the cpp file I have also provided in post 6 does not compile for you.
You can use the code that User907968 posted, to create your own cpp file and compile it with your version of SC.

I have provided the compiled dll and the cpp that I used.
There is really not much else I can provide.

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

Login

Login Page - Create Account